-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ant
153 lines (119 loc) · 4.99 KB
/
build.ant
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!--
Rhizi build targets
-->
<project name="rhizi-server" default="pkg-deb" xmlns:if="ant:if">
<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>
<macrodef name="client-optimize">
<attribute name="root" />
<attribute name="build" />
<sequential>
<exec dir="@{root}" executable="/usr/bin/r.js" failonerror="true">
<arg line="-o @{build}" />
</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" />
<property name="remoteDeployServer" value="rhizi.net" />
<property name="targetDomain" value="rhizi.net" />
<property name="doClientOptimize" value="false" />
<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" />
<!-- note: defaults to not overwriting, so rhizi-server.conf is safe -->
<copy file="res/etc/rhizi-server.conf.example"
tofile="res/etc/rhizi-server.conf" />
<client-optimize if:true="${doClientOptimize}" root="src/client/" build="build.js" />
<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}" />
<copy file="res/etc/rhizi-server.conf"
tofile="${targetDeploymentDir}/etc/rhizi-server.conf" />
<rsync src="res/templates/" dst="${targetDeploymentDir}/templates" />
</parallel>
</target>
<target name="deploy-remote" depends="deploy-local">
<!-- [!] trailing '/' on rsync src targets critical -->
<local name="rsync_module" />
<property name="rsync_module" value="rhizi.net" />
<property name="filter_list_str"
value="-f '- __pycache__/' -f '- *.pyc'" />
<client-optimize if:true="${doClientOptimize}" root="src/client/" build="build.js" />
<!-- -l: traverse bin/ -> ../src-py link -->
<rsync src="${targetDeploymentDir}/"
extraopts="-lL --delete ${filter_list_str}"
dst="rsync://${remoteDeployServer}/${rsync_module}/" />
<parallel>
<!-- apply production patches -->
<rsync extraopts="--delete"
src="res/production-patch-set/${targetDomain}/rhizi-server.production.conf"
dst="rsync://${remoteDeployServer}/${rsync_module}/etc/rhizi-server.conf" />
</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>