vinaigrette/scripts/build_deb

111 lines
2.7 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
2022-01-10 21:50:21 +01:00
readonly ARCHS=$4
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
# ##### #
# Usage #
# ##### #
function usage()
2017-08-29 17:17:25 +02:00
{
cat << EOF
Usage:
$THISSCRIPT <distrib> <branch> <folder>
Arguments:
2023-05-04 20:29:29 +02:00
<distrib> buster or bullseye or bookworm
2022-01-10 02:07:43 +01:00
<branch> stable, testing, or unstable
<folder> the folder in which to build...
2022-01-10 21:50:21 +01:00
<archs> list of archs to build (or empty for autodetect). For example: amd63,armhf
2017-08-29 17:17:25 +02:00
EOF
}
function main()
{
2022-01-10 02:07:43 +01:00
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}')
2022-01-10 02:07:43 +01:00
boxed "Building ${PACKAGE} ${VERSION} ..."
2022-01-10 21:50:21 +01:00
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
2022-01-10 02:07:43 +01:00
then
archs="all"
else
archs="$REPO_ARCHS"
fi
for arch in $archs
do
2022-01-10 21:50:21 +01:00
sendxmpppy "⏳ Starting build for ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch ..."
2022-01-10 02:07:43 +01:00
if ! build $arch
then
2022-01-10 21:50:21 +01:00
sendxmpppy "❌ Failed build for ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch ?!"
critical "Failed to build ${PACKAGE}/${VERSION} for $DISTRIB/$BRANCH/$arch"
2022-01-10 02:07:43 +01:00
fi
2022-01-10 21:50:21 +01:00
if [[ $arch == "all" ]]
2022-01-10 02:07:43 +01:00
then
2022-01-10 21:50:21 +01:00
changearch="amd64"
2022-01-10 02:07:43 +01:00
else
2022-01-10 21:50:21 +01:00
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 ?!"
2022-01-10 02:07:43 +01:00
fi
done
}
2022-01-10 02:07:43 +01:00
function build()
{
2022-01-10 02:07:43 +01:00
local arch=$1
2022-01-10 21:50:21 +01:00
local opts=""
opts+=" -d $DISTRIB"
opts+=" --no-run-lintian"
opts+=" --no-run-piuparts"
opts+=" --no-run-autopkgtest"
if [[ "$arch" != "all" ]]
2022-01-10 02:07:43 +01:00
then
2022-01-10 21:50:21 +01:00
opts+=" --host=$arch"
fi
if [[ -n "$DEBUG" ]]
then
opts+="--anything-failed-commands='%s'"
2022-01-10 02:07:43 +01:00
fi
2022-01-10 21:50:21 +01:00
sbuild $opts
}
[[ "$1" =~ ^-h|--help$ ]] && (usage; exit 0) || main