blob: bb98807a2bf283240c1bb45ab0abba6f74fd14b4 [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>
<!--copy zip file to staging directory-->
<!--make positive that staging area is completely clean-->
<echo
message="delete any possible files in staging area " />
<!-- this first output creates or replaces signingHistory file, all subsequent ones should append -->
<exec
executable="ssh"
output="${signingHistory}">
<arg
line="david_williams@build.eclipse.org /bin/rm -rf ${stagingDirectory}/*" />
</exec>
<echo
message="copying zip file to staging directory" />
<exec
executable="scp"
output="${signingHistory}"
append="true">
<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 -->
<!-- this first count is just to confirm there is only one file there ...
in future, we may want to fail here, if not -->
<exec
executable="ssh"
outputProperty="originalNFiles">
<arg
line="david_williams@build.eclipse.org ls -l ${stagingDirectory} | wc -l" />
</exec>
<echo
message="original Number of Files: ${originalNFiles}" />
<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="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="polledNFiles">
<arg
line="david_williams@build.eclipse.org ls -l ${stagingDirectory} | wc -l" />
</exec>
<echo
message="Polled Number of Files: ${polledNFiles}" />
<exec
executable="ssh"
outputProperty="polledAttributes">
<arg
line="david_williams@build.eclipse.org ls -l ${outputFile}" />
</exec>
<echo
message="original: ${originalAttributes}" />
<condition
property="attributesChanged">
<and>
<equals
arg1="1"
arg2="${polledNFiles}"
trim="true" />
<equals
arg1="${originalAttributes}"
arg2="${polledAttributes}"
trim="true" />
</and>
</condition>
<echo
message="polled: ${polledAttributes}" />
<sleep
seconds="120" />
<antcall
target="waitForChangedAttributes">
<param
name="originalAttributes"
value="${originalAttributes}" />
</antcall>
</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>