Update package-all.sh
- Remove subshells and instead use bash parameter expansion. - Utilize a function with a subshell to make adding additional packages easy.
This commit is contained in:
@@ -2,35 +2,33 @@
|
|||||||
# OpenRA master packaging script
|
# OpenRA master packaging script
|
||||||
|
|
||||||
if [ $# -ne "2" ]; then
|
if [ $# -ne "2" ]; then
|
||||||
echo "Usage: `basename $0` version outputdir"
|
echo "Usage: ${0##*/} version outputdir."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set the working dir to the location of this script
|
export GIT_TAG="$1"
|
||||||
cd $(dirname $0)
|
export BUILD_OUTPUT_DIR="$2"
|
||||||
|
|
||||||
pushd windows >/dev/null
|
# Set the working dir to the location of this script using bash parameter expansion
|
||||||
echo "Building Windows package"
|
cd "${0%/*}"
|
||||||
./buildpackage.sh "$1" "$2"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Windows package build failed."
|
|
||||||
fi
|
|
||||||
popd >/dev/null
|
|
||||||
|
|
||||||
pushd osx >/dev/null
|
#build packages using a subshell so directory changes do not persist beyond the function
|
||||||
echo "Building macOS package"
|
function build_package() (
|
||||||
./buildpackage.sh "$1" "$2"
|
function on_build() {
|
||||||
if [ $? -ne 0 ]; then
|
echo "$1 package build failed." 1>&2
|
||||||
echo "macOS package build failed."
|
}
|
||||||
fi
|
#trap function executes on any error in the following commands
|
||||||
popd >/dev/null
|
trap "on_build $1" ERR
|
||||||
|
set -e
|
||||||
|
echo "Building $1 package(s)."
|
||||||
|
cd "$1"
|
||||||
|
./buildpackage.sh "${GIT_TAG}" "${BUILD_OUTPUT_DIR}"
|
||||||
|
)
|
||||||
|
|
||||||
pushd linux >/dev/null
|
#exit on any non-zero exited (failed) command
|
||||||
echo "Building Linux packages"
|
set -e
|
||||||
./buildpackage.sh "$1" "$2"
|
build_package windows
|
||||||
if [ $? -ne 0 ]; then
|
build_package osx
|
||||||
echo "Linux package build failed."
|
build_package linux
|
||||||
fi
|
|
||||||
popd >/dev/null
|
|
||||||
|
|
||||||
echo "Package build done."
|
echo "Package build done."
|
||||||
|
|||||||
Reference in New Issue
Block a user