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 |
david_williams | e8df75a | 2008-06-23 03:30:07 +0000 | [diff] [blame] | 76 | line="david_williams@build.eclipse.org mkdir -p ${stagingDirectory}/*" /> |
david_williams | 22b02ab | 2008-06-23 03:15:35 +0000 | [diff] [blame] | 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}" |
david_williams | 9e1c90f | 2009-02-10 03:14:32 +0000 | [diff] [blame] | 92 | failonerror="true" |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 93 | append="true"> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 94 | <arg |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 95 | line="${buildDirectory}/${buildLabel}/${archiveName} david_williams@build.eclipse.org:${stagingDirectory}" /> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 96 | </exec> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 97 | |
| 98 | <!-- make sure it has correct permissions --> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 99 | <exec |
| 100 | executable="ssh" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 101 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 102 | append="true"> |
| 103 | <arg |
| 104 | line="david_williams@build.eclipse.org /bin/chmod ugo+rw ${outputFile} " /> |
| 105 | </exec> |
david_williams | 0838480 | 2008-02-09 22:06:18 +0000 | [diff] [blame] | 106 | |
| 107 | |
| 108 | <!-- establish Original Attributes --> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 109 | <!-- this first count is just to confirm there is only one file there ... |
| 110 | in future, we may want to fail here, if not --> |
| 111 | <exec |
| 112 | executable="ssh" |
david_williams | 9e1c90f | 2009-02-10 03:14:32 +0000 | [diff] [blame] | 113 | failonerror="true" |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 114 | outputProperty="originalNFiles"> |
| 115 | <arg |
david_williams | 61c8310 | 2008-02-10 02:42:37 +0000 | [diff] [blame] | 116 | line="david_williams@build.eclipse.org ls -l ${stagingDirectory} | wc -l" /> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 117 | </exec> |
| 118 | <echo |
| 119 | message="original Number of Files: ${originalNFiles}" /> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 120 | |
| 121 | |
david_williams | 0838480 | 2008-02-09 22:06:18 +0000 | [diff] [blame] | 122 | <exec |
| 123 | executable="ssh" |
david_williams | 9e1c90f | 2009-02-10 03:14:32 +0000 | [diff] [blame] | 124 | failonerror="true" |
david_williams | 0838480 | 2008-02-09 22:06:18 +0000 | [diff] [blame] | 125 | outputProperty="originalAttributes"> |
| 126 | <arg |
| 127 | line="david_williams@build.eclipse.org ls -l ${outputFile}" /> |
| 128 | </exec> |
| 129 | <echo |
| 130 | message="original: ${originalAttributes}" /> |
| 131 | |
| 132 | |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 133 | |
| 134 | <!--invoke sign script and wait--> |
| 135 | <echo |
| 136 | message="invoke sign script and wait" /> |
| 137 | <exec |
| 138 | executable="ssh" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 139 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 140 | append="true"> |
| 141 | <arg |
| 142 | line="david_williams@build.eclipse.org /usr/bin/sign ${outputFile} nomail" /> |
| 143 | </exec> |
| 144 | |
| 145 | <!--Wait for signed build to be available --> |
| 146 | <antcall |
david_williams | 21c8beb | 2008-02-10 05:15:22 +0000 | [diff] [blame] | 147 | target="waitForChangedAttributes"/> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 148 | |
| 149 | <!--copy zip back to build machine --> |
| 150 | <echo |
| 151 | message="copy zip back to build machine" /> |
| 152 | <exec |
| 153 | executable="scp" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 154 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 155 | append="true"> |
| 156 | <arg |
| 157 | line="david_williams@build.eclipse.org:${outputFile} ${buildDirectory}/${buildLabel}" /> |
| 158 | </exec> |
| 159 | |
| 160 | <!--delete files on build.eclipse.org--> |
| 161 | <echo |
| 162 | message="delete temp files on build.eclipse.org" /> |
| 163 | <exec |
| 164 | executable="ssh" |
david_williams | 7e3c272 | 2008-02-09 22:12:31 +0000 | [diff] [blame] | 165 | output="${signingHistory}" |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 166 | append="true"> |
| 167 | <arg |
david_williams | 875ac77 | 2008-02-09 21:38:05 +0000 | [diff] [blame] | 168 | line="david_williams@build.eclipse.org /bin/rm -rf ${outputFile}" /> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 169 | </exec> |
david_williams | 717c2fc | 2008-06-23 03:57:58 +0000 | [diff] [blame] | 170 | |
| 171 | <echo |
| 172 | message="delete signing directory we created on build.eclipse.org" /> |
| 173 | <exec |
| 174 | executable="ssh" |
| 175 | output="${signingHistory}" |
| 176 | append="true"> |
| 177 | <arg |
| 178 | line="david_williams@build.eclipse.org /bin/rm -rf ${stagingDirectory}" /> |
| 179 | </exec> |
| 180 | |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 181 | </target> |
| 182 | |
| 183 | |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 184 | <!-- |
| 185 | ======= Utility tasks ======== |
| 186 | --> |
| 187 | |
| 188 | <!-- |
| 189 | == compareAttributes == |
| 190 | The compareAttributes task and the waitForChangedAttributes task call each other repeatedly, |
| 191 | until attributes are cheanged. |
| 192 | TODO: we might have to adjust "outer" timeouts, if this takes a lot longer, |
| 193 | and we might want to have our own time or loop checks here. |
| 194 | --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 195 | <target |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 196 | name="compareAttributes"> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 197 | <!--poll file for change in attributes--> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 198 | <exec |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 199 | executable="ssh" |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 200 | outputProperty="polledNFiles"> |
| 201 | <arg |
david_williams | 61c8310 | 2008-02-10 02:42:37 +0000 | [diff] [blame] | 202 | line="david_williams@build.eclipse.org ls -l ${stagingDirectory} | wc -l" /> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 203 | </exec> |
| 204 | <echo |
| 205 | message="Polled Number of Files: ${polledNFiles}" /> |
| 206 | <exec |
| 207 | executable="ssh" |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 208 | outputProperty="polledAttributes"> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 209 | <arg |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 210 | line="david_williams@build.eclipse.org ls -l ${outputFile}" /> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 211 | </exec> |
| 212 | <echo |
david_williams | 2018d68 | 2008-02-09 21:45:31 +0000 | [diff] [blame] | 213 | message="original: ${originalAttributes}" /> |
david_williams | 4849c48 | 2008-02-10 05:09:32 +0000 | [diff] [blame] | 214 | <echo |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 215 | message="polled: ${polledAttributes}" /> |
| 216 | |
| 217 | <!-- |
| 218 | We compare number of files, and attributes, for added safety. May not be necessary. |
| 219 | There should only be 1 files there, for the "count of lines" from ls -l command is 2, |
| 220 | one for "total bytes". |
| 221 | |
| 222 | Once there signing process starts, there will be a directory and file make in the |
| 223 | staging area ... where the work is done ... and then that renamed to original name, |
| 224 | hence replacing it, and it will have a new "owner" and a new file size. |
| 225 | --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 226 | <condition |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 227 | property="attributesChanged"> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 228 | <and> |
david_williams | d460938 | 2008-02-10 04:56:36 +0000 | [diff] [blame] | 229 | <equals |
| 230 | arg1="2" |
| 231 | arg2="${polledNFiles}" |
| 232 | trim="true" /> |
| 233 | <not> |
| 234 | <equals |
| 235 | arg1="${originalAttributes}" |
| 236 | arg2="${polledAttributes}" |
| 237 | trim="true" /> |
| 238 | </not> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 239 | </and> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 240 | </condition> |
david_williams | 4849c48 | 2008-02-10 05:09:32 +0000 | [diff] [blame] | 241 | |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 242 | <antcall |
david_williams | 21c8beb | 2008-02-10 05:15:22 +0000 | [diff] [blame] | 243 | target="waitForChangedAttributes"/> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 244 | </target> |
david_williams | e631c2d | 2008-02-10 02:36:35 +0000 | [diff] [blame] | 245 | |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 246 | |
| 247 | <!-- |
| 248 | == waitForChangedAttributes == |
| 249 | Wait and then compare attributes of file to see if changed. |
| 250 | --> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 251 | <target |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 252 | name="waitForChangedAttributes" |
| 253 | unless="attributesChanged"> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 254 | <!-- increase, say to 120 or so, after testing --> |
| 255 | <sleep |
david_williams | f157fb3 | 2008-07-29 17:23:59 +0000 | [diff] [blame] | 256 | seconds="180" /> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 257 | <antcall |
david_williams | 6fd6ba1 | 2008-02-10 04:37:30 +0000 | [diff] [blame] | 258 | target="compareAttributes" |
| 259 | inheritAll="false"> |
david_williams | e6be8c0 | 2008-02-09 21:54:44 +0000 | [diff] [blame] | 260 | <param |
david_williams | 1429bca | 2008-02-09 22:27:48 +0000 | [diff] [blame] | 261 | name="originalAttributes" |
| 262 | value="${originalAttributes}" /> |
david_williams | 68a136b | 2008-02-10 04:44:39 +0000 | [diff] [blame] | 263 | <param |
| 264 | name="stagingDirectory" |
| 265 | value="${stagingDirectory}"/> |
| 266 | <param |
| 267 | name="outputFile" |
david_williams | 21c8beb | 2008-02-10 05:15:22 +0000 | [diff] [blame] | 268 | value="${outputFile}"/> |
david_williams | e6be8c0 | 2008-02-09 21:54:44 +0000 | [diff] [blame] | 269 | </antcall> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 270 | </target> |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 271 | |
| 272 | <!-- |
| 273 | == check.sign == |
| 274 | The property 'sign' is the critical attribute that determines if signing will be done. |
| 275 | If false, or absent, signing is not done. |
| 276 | We do not only rely on absence, so the "master properties" can set to false, and individual |
| 277 | 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] | 278 | component properties - currently used "SKIP_JAR_SIGNING" instead, but that |
david_williams | d82102c | 2008-02-10 17:26:21 +0000 | [diff] [blame] | 279 | doesn't feel quite right, so may change in future. SKIP_JAR_SIGNING can be |
| 280 | set as env variable or ant variable. |
david_williams | b0f0e6c | 2008-02-10 06:22:40 +0000 | [diff] [blame] | 281 | --> |
david_williams | 130f38a | 2008-02-09 21:17:29 +0000 | [diff] [blame] | 282 | <target |
david_williams | 39601d1 | 2008-02-09 00:06:57 +0000 | [diff] [blame] | 283 | name="check.sign"> |
| 284 | <echo |
| 285 | message="sign: ${sign}" /> |
david_williams | 7093484 | 2008-02-10 08:22:16 +0000 | [diff] [blame] | 286 | <echo |
david_williams | fb048be | 2008-02-23 07:15:21 +0000 | [diff] [blame] | 287 | message="env skip jar signing: ${env.SKIP_JAR_SIGNING}" /> |
| 288 | <echo |
| 289 | message="skip jar signing: ${SKIP_JAR_SIGNING}" /> |
david_williams | 39601d1 | 2008-02-09 00:06:57 +0000 | [diff] [blame] | 290 | <condition |
| 291 | property="doSign"> |
david_williams | 2171a5b | 2008-02-10 08:15:08 +0000 | [diff] [blame] | 292 | <and> |
| 293 | <equals |
| 294 | arg1="${sign}" |
| 295 | arg2="true" |
| 296 | trim="true" |
| 297 | casesensitive="false" /> |
| 298 | <not> |
| 299 | <equals |
david_williams | 7093484 | 2008-02-10 08:22:16 +0000 | [diff] [blame] | 300 | arg1="${env.SKIP_JAR_SIGNING}" |
| 301 | arg2="true" |
david_williams | 2171a5b | 2008-02-10 08:15:08 +0000 | [diff] [blame] | 302 | trim="true" |
| 303 | casesensitive="false" /> |
| 304 | </not> |
david_williams | d82102c | 2008-02-10 17:26:21 +0000 | [diff] [blame] | 305 | <not> |
| 306 | <equals |
| 307 | arg1="${SKIP_JAR_SIGNING}" |
| 308 | arg2="true" |
| 309 | trim="true" |
| 310 | casesensitive="false" /> |
| 311 | </not> |
david_williams | 2171a5b | 2008-02-10 08:15:08 +0000 | [diff] [blame] | 312 | </and> |
david_williams | 39601d1 | 2008-02-09 00:06:57 +0000 | [diff] [blame] | 313 | </condition> |
| 314 | </target> |
david_williams | e39ca40 | 2008-02-07 05:58:31 +0000 | [diff] [blame] | 315 | </project> |