Commit 13407678 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

scripts: zip the packages for dist

parent 7cddca2f
...@@ -12,9 +12,11 @@ cd $DIR ...@@ -12,9 +12,11 @@ cd $DIR
# Determine the version that we're building based on the contents # Determine the version that we're building based on the contents
# of packer/version.go. # of packer/version.go.
VERSION=$(grep "const Version " packer/version.go | sed -E 's/.*"(.+)"$/\1/') VERSION=$(grep "const Version " packer/version.go | sed -E 's/.*"(.+)"$/\1/')
VERSIONDIR="${VERSION}"
PREVERSION=$(grep "const VersionPrerelease " packer/version.go | sed -E 's/.*"(.+)"$/\1/') PREVERSION=$(grep "const VersionPrerelease " packer/version.go | sed -E 's/.*"(.+)"$/\1/')
if [ ! -z $PREVERSION ]; then if [ ! -z $PREVERSION ]; then
PREVERSION="${PREVERSION}.$(date -u +%s)" PREVERSION="${PREVERSION}.$(date -u +%s)"
VERSIONDIR="${VERSIONDIR}-${PREVERSION}"
fi fi
echo "Version: ${VERSION} ${PREVERSION}" echo "Version: ${VERSION} ${PREVERSION}"
...@@ -31,6 +33,21 @@ xc() { ...@@ -31,6 +33,21 @@ xc() {
xc xc
} }
# This function waits for all background tasks to complete
waitAll() {
RESULT=0
for job in `jobs -p`; do
wait $job
if [ $? -ne 0 ]; then
RESULT=1
fi
done
if [ $RESULT -ne 0 ]; then
exit $RESULT
fi
}
# Make sure that if we're killed, we kill all our subprocseses # Make sure that if we're killed, we kill all our subprocseses
trap "kill 0" SIGINT SIGTERM EXIT trap "kill 0" SIGINT SIGTERM EXIT
...@@ -48,13 +65,25 @@ for PLUGIN in $(find ./plugin -mindepth 1 -maxdepth 1 -type d); do ...@@ -48,13 +65,25 @@ for PLUGIN in $(find ./plugin -mindepth 1 -maxdepth 1 -type d); do
) & ) &
done done
# Wait for all the background tasks to finish waitAll
RESULT="0"
for job in `jobs -p`; do # Zip all the packages
wait $job mkdir -p ./pkg/${VERSIONDIR}/dist
if [ $? -ne 0 ]; then for PLATFORM in $(find ./pkg/${VERSIONDIR} -mindepth 1 -maxdepth 1 -type d); do
RESULT="1" PLATFORM_NAME=$(basename ${PLATFORM})
ARCHIVE_NAME="${VERSIONDIR}_${PLATFORM_NAME}"
if [ $PLATFORM_NAME = "dist" ]; then
continue
fi fi
(
pushd ${PLATFORM}
zip ${DIR}/pkg/${VERSIONDIR}/dist/${ARCHIVE_NAME}.zip ./*
popd
) &
done done
exit $RESULT waitAll
exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment