blob: 836ef4492d81cefdd1443d864389c4f777456267 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<project
name="signJarsInArchive"
default="signJarsInArchive"
basedir=".">
<!-- = = = standard properties pattern = = = -->
<!--
Note to be cross-platform, "environment variables" are only appropriate for
some variables, e.g. ones we set, since properties are case sensitive, even if
the environment variables on your operating system are not, e.g. it will
be ${env.Path} not ${env.PATH} on Windows -->
<property
environment="env" />
<!--
Let users override standard properties, if desired.
If directory, file, or some properties do not exist,
then standard properties will be used.
-->
<property
file="${env.LOCAL_BUILD_PROPERTIES_DIR}/${ant.project.name}.properties" />
<!-- = = = end standard properties pattern = = = -->
<!-- Our specific directory in the signing area -->
<property
name="stagingDirectory"
value="/opt/public/download-staging.priv/webtools" />
<property
name="signingHistory"
value="${buildDirectory}/signing-${archiveName}.log" />
<!-- Fail fast if variables are not provided as expected -->
<fail
unless="buildDirectory"
message="buildDirectory must be specified by caller" />
<fail
unless="archiveName"
message="archiveName must be specified by caller" />
<fail
unless="buildLabel"
message="buildLabel must be specified by caller" />
<fail
unless="buildId"
message="buildId must be specified by caller" />
<fail
unless="wtp.builder.home"
message="wtp.builder.home must be specified by caller" />
<!-- Primary task -->
<target
name="signJarsInArchive"
depends="check.sign"
if="doSign">
<property
name="packtmp"
value="${buildDirectory}/packtmp" />
<property
name="outputFile"
value="${stagingDirectory}/${archiveName}" />
<mkdir
dir="${packtmp}" />
<move
file="${buildDirectory}/${buildLabel}/${archiveName}"
tofile="${packtmp}/${archiveName}" />
<!-- add pack.properties file that specifies effort level -->
<exec
executable="zip">
<arg
line="-r ${packtmp}/${archiveName} ${wtp.builder.home}/scripts/build/pack.properties" />
</exec>
<!--push drop to staging directory-->
<echo
message="push drop to staging directory" />
<!-- this first one creates or replaces file, any others should append -->
<exec
executable="scp"
output="${signingHistory}">
<arg
line="${packtmp}/${archiveName} david_williams@build.eclipse.org:${stagingDirectory}" />
</exec>
<exec
executable="ssh"
output="${signingHistory}"
append="true">
<arg
line="david_williams@build.eclipse.org /bin/chmod ugo+rw ${outputFile} " />
</exec>
<!-- establish Original Attributes -->
<exec
executable="ssh"
outputProperty="originalAttributes">
<arg
line="david_williams@build.eclipse.org ls -l ${outputFile}" />
</exec>
<echo
message="original: ${originalAttributes}" />
<!--invoke sign script and wait-->
<echo
message="invoke sign script and wait" />
<exec
executable="ssh"
output="${signingHistory}"
append="true">
<arg
line="david_williams@build.eclipse.org /usr/bin/sign ${outputFile} nomail" />
</exec>
<!--Wait for signed build to be available -->
<antcall
target="waitForChangedAttributes">
<param
name="sshline"
value="david_williams@build.eclipse.org ls -l ${outputFile}" />
<param
name="originalAttributes"
value="${originalAttributes}" />
</antcall>
<!--copy zip back to build machine -->
<echo
message="copy zip back to build machine" />
<exec
executable="scp"
output="${signingHistory}"
append="true">
<arg
line="david_williams@build.eclipse.org:${outputFile} ${buildDirectory}/${buildLabel}" />
</exec>
<!--delete files on build.eclipse.org-->
<echo
message="delete temp files on build.eclipse.org" />
<exec
executable="ssh"
output="${signingHistory}"
append="true">
<arg
line="david_williams@build.eclipse.org /bin/rm -rf ${outputFile}" />
</exec>
</target>
<!-- Utility tasks -->
<target
name="compareAttributes">
<!--poll file for change in attributes-->
<exec
executable="ssh"
outputProperty="polledAttributes">
<arg
line="${sshline}" />
</exec>
<echo
message="original: ${originalAttributes}" />
<condition
property="attributesChanged">
<equals
arg1="${originalAttributes}"
arg2="${polledAttributes}"
trim="true" />
</condition>
<echo
message="polled: ${polledAttributes}" />
<antcall
target="writeDiffResult" />
<sleep
seconds="120" />
<antcall
target="waitForChangedAttributes">
<param
name="originalAttributes"
value="${originalAttributes}" />
</antcall>
</target>
<target
name="writeDiffResult"
if="attributesChanged">
<echo
message="original: ${originalAttributes}"
file="${buildDirectory}/attribDiff.txt" />
<echo
message="new: ${polledAttributes}"
file="${buildDirectory}/attribDiff.txt"
append="true" />
</target>
<target
name="waitForChangedAttributes"
unless="attributesChanged">
<antcall
target="compareAttributes">
<param
name="originalAttributes"
value="${originalAttributes}" />
</antcall>
</target>
<target
name="check.sign">
<echo
message="sign: ${sign}" />
<condition
property="doSign">
<equals
arg1="${sign}"
arg2="true"
trim="true"
casesensitive="false" />
</condition>
</target>
</project>