#!/bin/bash readonly THISSCRIPT=$0 readonly DISTRIB=$1 readonly BRANCH=$2 readonly FOLDER=$3 readonly ARCHS=$4 source /home/vinaigrette/config/config source /home/vinaigrette/scripts/common.sh # ##### # # Usage # # ##### # function usage() { cat << EOF Usage: $THISSCRIPT Arguments: buster or bullseye stable, testing, or unstable the folder in which to build... list of archs to build (or empty for autodetect). For example: amd63,armhf EOF } function main() { grep -q "^Codename: $DISTRIB$" $REPO_CONFIG || critical "Invalid distribution $DISTRIB" grep -q "^Components: .*$BRANCH.*$" $REPO_CONFIG || critical "Invalid branch $BRANCH" [[ -n "$FOLDER" ]] || critical "Need a folder in which to build" 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}') boxed "Building ${PACKAGE} ${VERSION} ..." if [[ -n "$ARCHS" ]] then archs="$(echo $ARCHS | tr ',' ' ')" # Architecture-agnostic packages have 'architecture: all' in their control files # others have 'architecture: any' elif grep -q "Architecture: all" $PKG_DIR/debian/control then archs="all" else archs="$REPO_ARCHS" fi for arch in $archs do sendxmpppy "⏳ Starting build for ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch ..." if ! build $arch then sendxmpppy "❌ Failed build for ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch ?!" critical "Failed to build ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch" fi if [[ $arch == "all" ]] then changearch="amd64" else changearch=$arch fi if reprepro --waitforlock 6 -b $REPO_DIR -C $BRANCH include $DISTRIB ${ROOT_DIR}/${PACKAGE}_${VERSION}_$changearch.changes then sendxmpppy "✔️ Completed build for ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch." else sendxmpppy "❌ Failed to include change of ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch ?!" fi done } function build() { local arch=$1 local opts="" opts+=" -d $DISTRIB" opts+=" --no-run-lintian" opts+=" --no-run-piuparts" opts+=" --no-run-autopkgtest" if [[ "$arch" != "all" ]] then opts+=" --host=$arch" fi if [[ -n "$DEBUG" ]] then opts+="--anything-failed-commands='%s'" fi sbuild $opts } [[ "$1" =~ ^-h|--help$ ]] && (usage; exit 0) || main