david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <project |
| 3 | name="signJarsInArchive" |
| 4 | default="signJarsInArchive" |
| 5 | basedir="."> |
| 6 | |
| 7 | <!-- = = = standard properties pattern = = = --> |
| 8 | <!-- |
| 9 | Note to be cross-platform, "environment variables" are only appropriate for |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 10 | some variables, such as ones we create and set, since properties are case sensitive, even if |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 11 | the environment variables on your operating system are not, e.g. it will |
| 12 | be ${env.Path} not ${env.PATH} on Windows --> |
| 13 | <property |
| 14 | environment="env" /> |
| 15 | |
| 16 | <!-- |
| 17 | Let users override standard properties, if desired. |
| 18 | If directory, file, or some properties do not exist, |
| 19 | then standard properties will be used. |
| 20 | --> |
| 21 | <property |
| 22 | file="${env.LOCAL_BUILD_PROPERTIES_DIR}/${ant.project.name}.properties" /> |
| 23 | |
| 24 | <!-- = = = end standard properties pattern = = = --> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 25 | |
| 26 | <!-- Our specific directory in the signing area --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 27 | <property |
| 28 | name="stagingDirectory" |
david_williams | 81846f9 | 2008-06-23 02:13:58 +0000 | [diff] [blame] | 29 | value="/opt/public/download-staging.priv/webtools/${archiveName}" /> |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 30 | <property |
| 31 | name="signingHistory" |
| 32 | value="${buildDirectory}/signing-${archiveName}.log" /> |
| 33 | |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 34 | |
| 35 | <!-- Fail fast if variables are not provided as expected --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 36 | <fail |
| 37 | unless="buildDirectory" |
| 38 | message="buildDirectory must be specified by caller" /> |
| 39 | <fail |
| 40 | unless="archiveName" |
| 41 | message="archiveName must be specified by caller" /> |
| 42 | <fail |
| 43 | unless="buildLabel" |
| 44 | message="buildLabel must be specified by caller" /> |
| 45 | <fail |
| 46 | unless="buildId" |
| 47 | message="buildId must be specified by caller" /> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 48 | |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 49 | |
| 50 | <!-- |
| 51 | ======= Primary task ======== |
| 52 | --> |
| 53 | |
| 54 | <!-- |
| 55 | == signJarsInArchive == |
| 56 | --> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 57 | <target |
| 58 | name="signJarsInArchive" |
| 59 | depends="check.sign" |
| 60 | if="doSign"> |
david_williams | 22b02ab | 2008-06-23 03:15:35 +0000 | [diff] [blame^] | 61 | |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 62 | <property |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 63 | name="outputFile" |
david_williams | 875ac77 | 2008-02-09 21:38:05 +0000 | [diff] [blame] | 64 | value="${stagingDirectory}/${archiveName}" /> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 65 | |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 66 | <!--copy zip file to staging directory--> |
david_williams | 22b02ab | 2008-06-23 03:15:35 +0000 | [diff] [blame^] | 67 | <!-- but first make positive that staging area is completely clean, incase used before. In future, might want to fail if it's not? --> |
| 68 | |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 69 | <echo |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 70 | message="deleting any possible files in staging area " /> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 71 | <!-- this first output creates or replaces signingHistory file, all subsequent ones should append --> |
david_williams | 22b02ab | 2008-06-23 03:15:35 +0000 | [diff] [blame^] | 72 | <exec |
| 73 | executable="ssh" |
| 74 | output="${signingHistory}"> |
| 75 | <arg |
| 76 | line="david_williams@build.eclipse.org mkdir -P ${stagingDirectory}/*" /> |
| 77 | </exec> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 78 | <exec |
| 79 | executable="ssh" |
david_williams | 22b02ab | 2008-06-23 03:15:35 +0000 | [diff] [blame^] | 80 | output="${signingHistory}" |
| 81 | append="true"> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 82 | <arg |
| 83 | line="david_williams@build.eclipse.org /bin/rm -rf ${stagingDirectory}/*" /> |
| 84 | </exec> |
| 85 | |
| 86 | |
| 87 | <echo |
| 88 | message="copying zip file to staging directory" /> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 89 | <exec |
| 90 | executable="scp" |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 91 | output="${signingHistory}" |
| 92 | append="true"> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 93 | <arg |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 94 | line="${buildDirectory}/${buildLabel}/${archiveName} david_williams@build.eclipse.org:${stagingDirectory}" /> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 95 | </exec> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 96 | |
| 97 | <!-- make sure it has correct permissions --> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 98 | <exec |
| 99 | executable="ssh" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 100 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 101 | append="true"> |
| 102 | <arg |
| 103 | line="david_williams@build.eclipse.org /bin/chmod ugo+rw ${outputFile} " /> |
| 104 | </exec> |
david_williams | 0838480 | 2008-02-09 22:06:18 +0000 | [diff] [blame] | 105 | |
| 106 | |
| 107 | <!-- establish Original Attributes --> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 108 | <!-- this first count is just to confirm there is only one file there ... |
| 109 | in future, we may want to fail here, if not --> |
| 110 | <exec |
| 111 | executable="ssh" |
| 112 | outputProperty="originalNFiles"> |
| 113 | <arg |
david_williams | 61c8310 | 2008-02-10 02:42:37 +0000 | [diff] [blame] | 114 | line="david_williams@build.eclipse.org ls -l ${stagingDirectory} | wc -l" /> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 115 | </exec> |
| 116 | <echo |
| 117 | message="original Number of Files: ${originalNFiles}" /> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 118 | |
| 119 | |
david_williams | 0838480 | 2008-02-09 22:06:18 +0000 | [diff] [blame] | 120 | <exec |
| 121 | executable="ssh" |
| 122 | outputProperty="originalAttributes"> |
| 123 | <arg |
| 124 | line="david_williams@build.eclipse.org ls -l ${outputFile}" /> |
| 125 | </exec> |
| 126 | <echo |
| 127 | message="original: ${originalAttributes}" /> |
| 128 | |
| 129 | |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 130 | |
| 131 | <!--invoke sign script and wait--> |
| 132 | <echo |
| 133 | message="invoke sign script and wait" /> |
| 134 | <exec |
| 135 | executable="ssh" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 136 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 137 | append="true"> |
| 138 | <arg |
| 139 | line="david_williams@build.eclipse.org /usr/bin/sign ${outputFile} nomail" /> |
| 140 | </exec> |
| 141 | |
| 142 | <!--Wait for signed build to be available --> |
| 143 | <antcall |
david_williams | 21c8beb | 2008-02-10 05:15:22 +0000 | [diff] [blame] | 144 | target="waitForChangedAttributes"/> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 145 | |
| 146 | <!--copy zip back to build machine --> |
| 147 | <echo |
| 148 | message="copy zip back to build machine" /> |
| 149 | <exec |
| 150 | executable="scp" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 151 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 152 | append="true"> |
| 153 | <arg |
| 154 | line="david_williams@build.eclipse.org:${outputFile} ${buildDirectory}/${buildLabel}" /> |
| 155 | </exec> |
| 156 | |
| 157 | <!--delete files on build.eclipse.org--> |
| 158 | <echo |
| 159 | message="delete temp files on build.eclipse.org" /> |
| 160 | <exec |
| 161 | executable="ssh" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 162 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 163 | append="true"> |
| 164 | <arg |
david_williams | 875ac77 | 2008-02-09 21:38:05 +0000 | [diff] [blame] | 165 | line="david_williams@build.eclipse.org /bin/rm -rf ${outputFile}" /> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 166 | </exec> |
| 167 | </target> |
| 168 | |
| 169 | |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 170 | <!-- |
| 171 | ======= Utility tasks ======== |
| 172 | --> |
| 173 | |
| 174 | <!-- |
| 175 | == compareAttributes == |
| 176 | The compareAttributes task and the waitForChangedAttributes task call each other repeatedly, |
| 177 | until attributes are cheanged. |
| 178 | TODO: we might have to adjust "outer" timeouts, if this takes a lot longer, |
| 179 | and we might want to have our own time or loop checks here. |
| 180 | --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 181 | <target |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 182 | name="compareAttributes"> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 183 | <!--poll file for change in attributes--> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 184 | <exec |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 185 | executable="ssh" |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 186 | outputProperty="polledNFiles"> |
| 187 | <arg |
david_williams | 61c8310 | 2008-02-10 02:42:37 +0000 | [diff] [blame] | 188 | line="david_williams@build.eclipse.org ls -l ${stagingDirectory} | wc -l" /> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 189 | </exec> |
| 190 | <echo |
| 191 | message="Polled Number of Files: ${polledNFiles}" /> |
| 192 | <exec |
| 193 | executable="ssh" |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 194 | outputProperty="polledAttributes"> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 195 | <arg |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 196 | line="david_williams@build.eclipse.org ls -l ${outputFile}" /> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 197 | </exec> |
| 198 | <echo |
david_williams | 2018d68 | 2008-02-09 21:45:31 +0000 | [diff] [blame] | 199 | message="original: ${originalAttributes}" /> |
david_williams | 4849c48 | 2008-02-10 05:09:32 +0000 | [diff] [blame] | 200 | <echo |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 201 | message="polled: ${polledAttributes}" /> |
| 202 | |
| 203 | <!-- |
| 204 | We compare number of files, and attributes, for added safety. May not be necessary. |
| 205 | There should only be 1 files there, for the "count of lines" from ls -l command is 2, |
| 206 | one for "total bytes". |
| 207 | |
| 208 | Once there signing process starts, there will be a directory and file make in the |
| 209 | staging area ... where the work is done ... and then that renamed to original name, |
| 210 | hence replacing it, and it will have a new "owner" and a new file size. |
| 211 | --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 212 | <condition |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 213 | property="attributesChanged"> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 214 | <and> |
david_williams | d460938 | 2008-02-10 04:56:36 +0000 | [diff] [blame] | 215 | <equals |
| 216 | arg1="2" |
| 217 | arg2="${polledNFiles}" |
| 218 | trim="true" /> |
| 219 | <not> |
| 220 | <equals |
| 221 | arg1="${originalAttributes}" |
| 222 | arg2="${polledAttributes}" |
| 223 | trim="true" /> |
| 224 | </not> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 225 | </and> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 226 | </condition> |
david_williams | 4849c48 | 2008-02-10 05:09:32 +0000 | [diff] [blame] | 227 | |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 228 | <antcall |
david_williams | 21c8beb | 2008-02-10 05:15:22 +0000 | [diff] [blame] | 229 | target="waitForChangedAttributes"/> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 230 | </target> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 231 | |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 232 | |
| 233 | <!-- |
| 234 | == waitForChangedAttributes == |
| 235 | Wait and then compare attributes of file to see if changed. |
| 236 | --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 237 | <target |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 238 | name="waitForChangedAttributes" |
| 239 | unless="attributesChanged"> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 240 | <!-- increase, say to 120 or so, after testing --> |
| 241 | <sleep |
| 242 | seconds="60" /> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 243 | <antcall |
david_williams | 6fd6ba1 | 2008-02-10 04:37:30 +0000 | [diff] [blame] | 244 | target="compareAttributes" |
| 245 | inheritAll="false"> |
david_williams | e6be8c0 | 2008-02-09 21:54:44 +0000 | [diff] [blame] | 246 | <param |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 247 | name="originalAttributes" |
| 248 | value="${originalAttributes}" /> |
david_williams | 68a136b | 2008-02-10 04:44:39 +0000 | [diff] [blame] | 249 | <param |
| 250 | name="stagingDirectory" |
| 251 | value="${stagingDirectory}"/> |
| 252 | <param |
| 253 | name="outputFile" |
david_williams | 21c8beb | 2008-02-10 05:15:22 +0000 | [diff] [blame] | 254 | value="${outputFile}"/> |
david_williams | e6be8c0 | 2008-02-09 21:54:44 +0000 | [diff] [blame] | 255 | </antcall> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 256 | </target> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 257 | |
| 258 | <!-- |
| 259 | == check.sign == |
| 260 | The property 'sign' is the critical attribute that determines if signing will be done. |
| 261 | If false, or absent, signing is not done. |
| 262 | We do not only rely on absence, so the "master properties" can set to false, and individual |
| 263 | components remain set to 'true' (for example, to have quick local builds, without changing |
david_williams | 6d09414 | 2008-02-10 18:12:20 +0000 | [diff] [blame] | 264 | component properties - currently used "SKIP_JAR_SIGNING" instead, but that |
david_williams | d82102c | 2008-02-10 17:26:21 +0000 | [diff] [blame] | 265 | doesn't feel quite right, so may change in future. SKIP_JAR_SIGNING can be |
| 266 | set as env variable or ant variable. |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 267 | --> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 268 | <target |
david_williams | 39601d1 | 2008-02-09 00:06:57 +0000 | [diff] [blame] | 269 | name="check.sign"> |
| 270 | <echo |
| 271 | message="sign: ${sign}" /> |
david_williams | 7093484 | 2008-02-10 08:22:16 +0000 | [diff] [blame] | 272 | <echo |
david_williams | fb048be | 2008-02-23 07:15:21 +0000 | [diff] [blame] | 273 | message="env skip jar signing: ${env.SKIP_JAR_SIGNING}" /> |
| 274 | <echo |
| 275 | message="skip jar signing: ${SKIP_JAR_SIGNING}" /> |
david_williams | 39601d1 | 2008-02-09 00:06:57 +0000 | [diff] [blame] | 276 | <condition |
| 277 | property="doSign"> |
david_williams | 2171a5b | 2008-02-10 08:15:08 +0000 | [diff] [blame] | 278 | <and> |
| 279 | <equals |
| 280 | arg1="${sign}" |
| 281 | arg2="true" |
| 282 | trim="true" |
| 283 | casesensitive="false" /> |
| 284 | <not> |
| 285 | <equals |
david_williams | 7093484 | 2008-02-10 08:22:16 +0000 | [diff] [blame] | 286 | arg1="${env.SKIP_JAR_SIGNING}" |
| 287 | arg2="true" |
david_williams | 2171a5b | 2008-02-10 08:15:08 +0000 | [diff] [blame] | 288 | trim="true" |
| 289 | casesensitive="false" /> |
| 290 | </not> |
david_williams | d82102c | 2008-02-10 17:26:21 +0000 | [diff] [blame] | 291 | <not> |
| 292 | <equals |
| 293 | arg1="${SKIP_JAR_SIGNING}" |
| 294 | arg2="true" |
| 295 | trim="true" |
| 296 | casesensitive="false" /> |
| 297 | </not> |
david_williams | 2171a5b | 2008-02-10 08:15:08 +0000 | [diff] [blame] | 298 | </and> |
david_williams | 39601d1 | 2008-02-09 00:06:57 +0000 | [diff] [blame] | 299 | </condition> |
| 300 | </target> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 301 | </project> |