#!/bin/bash readonly THISSCRIPT=$0 readonly DISTRIB=$1 readonly BRANCH=$2 readonly FOLDER=$3 source /home/vinaigrette/config/config source /home/vinaigrette/scripts/common.sh export DEBSIGN_KEYID export DEBFULLNAME export DEBEMAIL readonly IMG="${PBUILDER_CHROOTS}/${DISTRIB}-amd64.tgz" # ##### # # Usage # # ##### # function usage() { cat << EOF Usage: $THISSCRIPT Arguments: stretch or buster stable, testing, or unstable the folder in which to build... EOF } function main() { 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} ..." 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