#!/bin/bash readonly THISSCRIPT=$0 readonly DISTRIB=$1 readonly BRANCH=$2 readonly FOLDER=$3 source /home/vinaigrette/config/config export DEBSIGN_KEYID export DEBFULLNAME export DEBEMAIL IMG="${PBUILDER_IMAGES}/${DISTRIB}-amd64.tgz" # ##### # # Usage # # ##### # function usage() { cat << EOF Usage: $THISSCRIPT Arguments: stretch (can only build for stretch, no jessie) stable, testing, or unstable the folder in which to build... EOF } function main() { validate_arguments retrieve_package_info build_sources add_to_reprepro echo "Build will start soon. See 'rebuildd-job list | tail'" sendxmpppy "Added builds for ${PACKAGE}/${VERSION} in branch ${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() { echo "---------------------------------------------------" 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() { echo "---------------------------------------------------" 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