mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 05:00:06 -05:00
123 lines
2.7 KiB
Bash
Executable File
123 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
USAGE="`basename $0`
|
|
Run this script from the project root.
|
|
|
|
Without options, the default is to build a signed source package for uploading
|
|
to a Launchpad PPA.
|
|
|
|
Options:
|
|
|
|
-h --help
|
|
|
|
-b --binary
|
|
-nb --nobinary
|
|
-s --source
|
|
-ns --nosource
|
|
--signed
|
|
--unsigned"
|
|
|
|
# version for the debian package
|
|
VERSION=0.9.9.2b
|
|
PROJECT=fractorium
|
|
PROJECT_ROOT=$PWD
|
|
PPA_DIR="$HOME/PPA/$PROJECT-$VERSION"
|
|
TAR_NAME="$PROJECT-$VERSION.tar.gz"
|
|
|
|
if [ ! -d '.git' -o ! -f 'main.pro' ]; then
|
|
echo "Run `basename $0` from the project root."
|
|
exit 2
|
|
fi
|
|
|
|
# Set defaults.
|
|
OPT_BUILD_BINARY=0
|
|
OPT_BUILD_SOURCE=1
|
|
OPT_SIGNED=1
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-b|--binary) OPT_BUILD_BINARY=1;;
|
|
-nb|--nobinary) OPT_BUILD_BINARY=0;;
|
|
-s|--source) OPT_BUILD_SOURCE=1;;
|
|
-ns|--nosource) OPT_BUILD_SOURCE=0;;
|
|
--signed) OPT_SIGNED=1;;
|
|
--unsigned) OPT_SIGNED=0;;
|
|
-h|--help) echo "$USAGE"
|
|
exit 0;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
tarversion=$(tar --version | head -1 | sed -e 's/tar (GNU tar) \+\([0-9\.]\+\)$/\1/; s/[^0-9]//g; s/^\(.{3}\).*$/\1/;')
|
|
|
|
if [[ "$tarversion" -lt "128" ]]; then
|
|
echo "Tar >= 1.28 is required. Download the .deb from https://launchpad.net/ubuntu/+source/tar/ and install manually."
|
|
exit 2
|
|
fi
|
|
|
|
if [ ! -d "$PPA_DIR" ]; then
|
|
mkdir -p "$PPA_DIR"
|
|
else
|
|
echo -n "PPA work folder already exists: $PPA_DIR
|
|
Move this folder aside or remove it.
|
|
"
|
|
exit 2
|
|
fi
|
|
|
|
# tar 1.28 required for --exclude-vcs-ignores
|
|
|
|
# FIXME: somehow it didn't ignore the 'Bin' folder.
|
|
|
|
tar --exclude='package-linux.sh' \
|
|
--exclude='Bin' \
|
|
--exclude-vcs \
|
|
--exclude-vcs-ignores \
|
|
--exclude-backups \
|
|
-czf "$PPA_DIR/$TAR_NAME" .
|
|
|
|
[ $? -ne 0 ] && echo "Tar command failed." && exit 2
|
|
|
|
# TODO: find the option to specify single binary, so the question can be skipped.
|
|
|
|
cd "$PPA_DIR" &&\
|
|
bzr dh-make $PROJECT $VERSION $TAR_NAME &&\
|
|
cd fractorium/debian &&\
|
|
rm *.ex *.EX README.Debian README.source &&\
|
|
cd ..
|
|
|
|
[ $? -ne 0 ] && echo "bzr dh-make command failed." && exit 2
|
|
|
|
bzr add . &&\
|
|
bzr commit -m "Debian package $VERSION"
|
|
|
|
[ $? -ne 0 ] && echo "bzr command failed." && exit 2
|
|
|
|
# Build a source package.
|
|
|
|
# Launchpad only needs a signed source package. It will build its own binary on
|
|
# the servers.
|
|
|
|
if [ $OPT_BUILD_SOURCE -eq 1 ]; then
|
|
if [ $OPT_SIGNED -eq 1 ]; then
|
|
bzr builddeb -- -S
|
|
else
|
|
bzr builddeb -- -S -us -uc
|
|
fi
|
|
fi
|
|
|
|
[ $? -ne 0 ] && echo "bzr builddeb for source package failed." && exit 2
|
|
|
|
# Build an binary package.
|
|
|
|
if [ $OPT_BUILD_BINARY -eq 1 ]; then
|
|
if [ $OPT_SIGNED -eq 1 ]; then
|
|
bzr builddeb -- -b
|
|
else
|
|
bzr builddeb -- -b -us -uc
|
|
fi
|
|
fi
|
|
|
|
[ $? -ne 0 ] && echo "bzr builddeb for source package failed." && exit 2
|
|
|
|
|