vinaigrette/scripts/build_deb

91 lines
2.3 KiB
Text
Raw Normal View History

2017-08-29 17:17:25 +02:00
#!/bin/bash
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
source /home/vinaigrette/scripts/common.sh
2017-08-29 17:17:25 +02:00
export DEBSIGN_KEYID
export DEBFULLNAME
export DEBEMAIL
2020-05-07 17:11:46 +02:00
readonly IMG="${PBUILDER_CHROOTS}/${DISTRIB}-amd64.tgz"
# ##### #
# Usage #
# ##### #
function usage()
2017-08-29 17:17:25 +02:00
{
cat << EOF
Usage:
$THISSCRIPT <distrib> <branch> <folder>
Arguments:
<distrib> stretch or buster
<branch> stable, testing, or unstable
<folder> the folder in which to build...
2017-08-29 17:17:25 +02:00
EOF
}
function main()
{
2018-05-03 03:21:34 +02:00
validate_arguments
retrieve_package_info
build_sources
add_to_reprepro
success "Build will start soon. See 'rebuildd-job list | tail'"
sendxmpppy "Added builds for ${PACKAGE}/${VERSION} for ${DISTRIB}/${BRANCH} ..."
}
# ################# #
# Check user inputs #
# ################# #
function validate_arguments()
{
[[ $DISTRIB =~ ^stretch|buster$ ]] || critical "Invalid distribution $DISTRIB"
[[ $BRANCH =~ ^testing|stable|unstable$ ]] || critical "Invalid branch $BRANCH"
[[ ! -z "$FOLDER" ]] || critical "Need a folder in which to build"
}
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()
{
boxed "Building source package of ${PACKAGE} ${VERSION} ..."
2019-01-30 19:50:30 +01:00
pbuilder execute --bindmounts ${ROOT_DIR} --basetgz ${IMG} -- ${BUILD_SOURCES} $PKG_DIR \
|| critical "An error occured while building source package"
[[ -f ${CHANGES_FILE} ]] || critical "An error occured while building source package (no change file available)"
}
function add_to_reprepro()
{
boxed "Adding ${PACKAGE}_${VERSION} to ${DISTRIB}/${BRANCH}..."
$INCLUDE_CHANGES $DISTRIB $BRANCH $CHANGES_FILE || critical "An error occured while including source package"
}
[[ "$1" =~ ^-h|--help$ ]] && (usage; exit 0) || main