2017-08-29 17:17:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-05-03 02:33:47 +02:00
|
|
|
readonly THISSCRIPT=$0
|
|
|
|
readonly DISTRIB=$1
|
|
|
|
readonly BRANCH=$2
|
|
|
|
readonly FOLDER=$3
|
2017-08-29 17:17:25 +02:00
|
|
|
|
2017-08-30 05:51:28 +02:00
|
|
|
source /home/vinaigrette/config/config
|
2017-08-29 17:17:25 +02:00
|
|
|
export DEBSIGN_KEYID
|
|
|
|
export DEBFULLNAME
|
|
|
|
export DEBEMAIL
|
|
|
|
|
2018-05-03 02:33:47 +02:00
|
|
|
IMG="${PBUILDER_IMAGES}/${DISTRIB}-amd64.tgz"
|
|
|
|
|
|
|
|
# ##### #
|
|
|
|
# Usage #
|
|
|
|
# ##### #
|
|
|
|
|
|
|
|
function usage()
|
2017-08-29 17:17:25 +02:00
|
|
|
{
|
2018-05-03 02:33:47 +02:00
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
$THISSCRIPT <distrib> <branch> <folder>
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
<distrib> stretch (can only build for stretch, no jessie)
|
|
|
|
<branch> stable, testing, or unstable
|
|
|
|
<folder> the folder in which to build...
|
2017-08-29 17:17:25 +02:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2018-05-03 02:33:47 +02:00
|
|
|
|
|
|
|
function main()
|
|
|
|
{
|
2018-05-03 03:21:34 +02:00
|
|
|
validate_arguments
|
2018-05-03 02:33:47 +02:00
|
|
|
retrieve_package_info
|
|
|
|
build_sources
|
|
|
|
add_to_reprepro
|
|
|
|
|
|
|
|
echo "Build will start soon. See 'rebuildd-job list | tail'"
|
|
|
|
sendxmpppy "Launched build ${PACKAGE}/${VERSION} for ${DISTRIB}/${BRANCH} ..."
|
|
|
|
}
|
|
|
|
|
|
|
|
# ################# #
|
|
|
|
# Check user inputs #
|
|
|
|
# ################# #
|
|
|
|
|
|
|
|
function validate_arguments()
|
|
|
|
{
|
|
|
|
# Distribution
|
|
|
|
if [[ ! $DISTRIB =~ ^stretch$ ]]; then
|
|
|
|
echo "Invalid distribution $DISTRIB"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
## Branch
|
|
|
|
if [[ ! $BRANCH =~ ^testing|stable|unstable$ ]]; then
|
|
|
|
echo "Invalid branch $BRANCH"
|
|
|
|
usage
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Folder
|
|
|
|
if [ -z "$FOLDER" ]; then
|
|
|
|
echo "Need a folder in which to build"
|
|
|
|
usage
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function retrieve_package_info()
|
|
|
|
{
|
|
|
|
readonly PKG_DIR=$(readlink -fn $FOLDER)
|
|
|
|
readonly ROOT_DIR=$(readlink -fn ${PKG_DIR}/../)
|
|
|
|
cd $PKG_DIR
|
|
|
|
|
|
|
|
readonly PACKAGE=$(dpkg-parsechangelog | awk '/^Source: / {print $2}')
|
|
|
|
readonly VERSION=$(dpkg-parsechangelog | awk '/^Version: / {print $2}')
|
|
|
|
readonly CHANGES_FILE=${ROOT_DIR}/${PACKAGE}_${VERSION}_source.changes
|
|
|
|
}
|
|
|
|
|
|
|
|
# ######################################## #
|
|
|
|
# Invoke pbuilder to build the sources ... #
|
|
|
|
# ######################################## #
|
|
|
|
|
|
|
|
function build_sources()
|
|
|
|
{
|
2018-05-03 03:21:34 +02:00
|
|
|
echo "---------------------------------------------------"
|
2018-05-03 02:33:47 +02:00
|
|
|
echo "Building source package of ${PACKAGE}_${VERSION}..."
|
|
|
|
echo "---------------------------------------------------"
|
|
|
|
|
|
|
|
sudo pbuilder execute --bindmounts ${ROOT_DIR} --basetgz ${IMG} -- ${BUILD_SOURCES} $PKG_DIR
|
|
|
|
|
|
|
|
if [ $? -ne 0 ] || [ ! -f ${CHANGES_FILE} ]; then
|
|
|
|
echo "An error occured while building source package"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_to_reprepro()
|
|
|
|
{
|
2018-05-03 03:21:34 +02:00
|
|
|
echo "---------------------------------------------------"
|
2018-05-03 02:33:47 +02:00
|
|
|
echo "Adding ${PACKAGE}_${VERSION} to ${DISTRIB}/${BRANCH}..."
|
|
|
|
echo "---------------------------------------------------"
|
|
|
|
$INCLUDE_CHANGES $DISTRIB $BRANCH $CHANGES_FILE
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "An error occured while including source package"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main
|