summaryrefslogtreecommitdiff
path: root/build.ant
blob: f073be4f59d8c7c1579715a628c1c02a56c4506c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!-- 

 Rhizi build targets

-->
<project name="rhizi-server" default="pkg-deb">

   <macrodef name="rsync">
      <attribute name="src" />
      <attribute name="dst" />
      <attribute name="extraOpts" default="" />
      <sequential>
         <exec dir="${basedir}" executable="/usr/bin/rsync" failonerror="true">
            <arg line="-avz @{extraOpts}" />
            <arg value="@{src}" />
            <arg value="@{dst}" />

            <!-- note: RSYNC_CONNECT_PROG has not effect when dst is local dir path -->
            <env key="RSYNC_CONNECT_PROG"
                 value="ssh root@%H nc 127.0.0.1 873" />
         </exec>
      </sequential>
   </macrodef>

   <property name="pkg_name" value="rhizi-server" />
   <property name="pkg_version" value="0.1.0" />
   <property name="buildDir" value="build/${pkg_name}-${pkg_version}" />
   <property name="targetDeploymentDir" value="deploy-local" />

   <tstamp>
      <format property="versionQualifier" pattern="yyyyMMddHHmm" />
   </tstamp>

   <target name="clean" description="remove all work folders">
      <delete dir="dist" />
      <delete dir="build" />
   </target>

   <target name="deploy-local.clean">

      <mkdir dir="${targetDeploymentDir}" description="bootstap if missing" />

      <!-- bin/ -> link: avoid specifying followsymlinks on the following delete task -->
      <symlink action="delete" link="deploy-local/bin" />
      <delete verbose="true" includeemptydirs="true">
         <fileset dir="${targetDeploymentDir}"
                  includes="**/*"
                  defaultexcludes="false" />
      </delete>
   </target>

   <target name="deploy-local"
           depends="deploy-local.clean"
           description="locally deploy webapp">

      <!-- [!] trailing '/' on rsync src targets critical -->

      <local name="src_client" />
      <local name="src_server" />
      <property name="src_client" value="src/client" />
      <property name="src_server" value="src/server" />

      <mkdir dir="${targetDeploymentDir}/static" />

      <parallel>
         <rsync src="${src_client}/" dst="${targetDeploymentDir}/static" />
         <rsync src="res/client/" dst="${targetDeploymentDir}/static" />

         <symlink action="single"
                  overwrite="true"
                  link="${targetDeploymentDir}/bin"
                  resource="${basedir}/${src_server}" />

         <rsync src="res/etc" dst="${targetDeploymentDir}" />
         <rsync src="res/templates/" dst="${targetDeploymentDir}/templates" />
      </parallel>

   </target>

   <target name="deploy-remote" depends="deploy-local">
      <!-- [!] trailing '/' on rsync src targets critical -->

      <local name="dstServer" />
      <local name="rsync_module" />
      <property name="dstServer" value="rz_0.unige.ch" />
      <property name="rsync_module" value="rhizi.net" />

      <!-- -l: traverse bin/ -> ../src-py link -->
      <rsync src="${targetDeploymentDir}/"
             extraopts="-lL"
             dst="rsync://${dstServer}/${rsync_module}/" />

      <parallel>
         <!-- apply production patches -->
         <rsync src="res/production-patch-set/rhizi-server.production.conf"
                dst="rsync://${dstServer}/${rsync_module}/etc/rhizi-server.conf" />
         <rsync src="res/production-patch-set/rz_config.js"
                dst="rsync://${dstServer}/${rsync_module}/static/" />
      </parallel>
   </target>

   <target name="deploy-remote.htpasswd.db" description="manual invocation">
      <rsync src="${src_server}/res/production-patch-set/htpasswd.db"
             dst="root@rz_0.unige.ch:/srv/www/rhizi/auth/" />
   </target>

   <target name="pkg-deb" depends="clean" description="package as .deb">
      <mkdir dir="dist" />
      <mkdir dir="${buildDir}" />

      <exec dir="${basedir}" executable="/usr/bin/git">
         <arg value="clone" />
         <arg line="--depth 1" />
         <arg value="file://${basedir}" />
         <arg value="${buildDir}" />
      </exec>

      <copy todir="${buildDir}/debian">
         <fileset dir="debian" />
      </copy>

      <exec dir="${buildDir}" executable="/usr/bin/debuild">
         <arg value="-b" />
         <arg value="-us" />
         <arg value="-uc" />
      </exec>
   </target>

   <target name="pkg-deb.list">
      <exec dir="${buildDir}" executable="/usr/bin/dpkg">
         <arg line="-c rhizi-server_0.1.0_amd64.deb" />
      </exec>
   </target>

</project>