summaryrefslogtreecommitdiff
path: root/build.ant
blob: a9e8ad8362aa70c70fce763fec0e18ab355d3091 (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
<!-- 
 Rhizi build targets
-->
<project name="rhizi-server" default="pkg-deb">

   <macrodef name="rsync">
      <attribute name="src" />
      <attribute name="dst" />
      <sequential>
         <exec dir="${basedir}" executable="/usr/bin/rsync">
            <arg value="-avz" />
            <arg value="@{src}" />
            <arg value="@{dst}" />
         </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}" />

   <fail unless="rzRootDir"
         message="'rzRootDir' arg missing - must point to root rhizi code dir" />

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

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

   <target name="deploy-local" description="locally deploy webapp">
      <local name="src_client" />
      <local name="src_server" />
      <local name="dst" />

      <property name="src_client" value="${rzRootDir}/rhizi-client" />
      <property name="src_server" value="${rzRootDir}/rhizi-server" />
      <property name="dst" value="${rzRootDir}/rhizi-server/deploy-local" />

      <parallel>
         <!-- [!] trailing '/' critical -->
         <rsync src="${src_client}/src/" dst="${dst}/static" />
         <rsync src="${src_client}/res" dst="${dst}/static" />
         <rsync src="${src_client}/lib" dst="${dst}/static" />

         <rsync src="${src_server}/src-py" dst="${dst}" />
         <rsync src="${src_server}/res/etc" dst="${dst}" />
         <rsync src="${src_server}/res/templates/" dst="${dst}/templates" />
      </parallel>

   </target>

   <target name="deploy-remote" depends="deploy-local">

      <local name="src_server" />
      <local name="src_client" />
      <local name="dstPath" />
      <local name="dstServer" />
      <property name="src_client" value="${rzRootDir}/rhizi-client" />
      <property name="src_server" value="${rzRootDir}/rhizi-server" />
      <property name="dstPath" value="/srv/www/rhizi/rhizi.net" />
      <property name="dstServer" value="rz_0.unige.ch" />

      <parallel>
         <rsync src="${src_server}/deploy-local/"
                dst="root@${dstServer}:${dstPath}" />

         <!-- apply production patches -->
         <rsync src="${src_server}/res/production-patch-set/rhizi-server.production.conf"
                dst="root@${dstServer}:/etc/rhizi/rhizi-server.conf" />
         <rsync src="${src_server}/res/production-patch-set/rz_config.js"
                dst="root@${dstServer}:${dstPath}/static" />
         <rsync src="${src_server}/res/production-patch-set/htpasswd.db"
                dst="root@${dstServer}:${dstPath}/../auth/" />

      </parallel>
   </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>