vinaigrette/scripts/build_deb

93 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
2022-01-10 02:07:43 +01:00
#export DEBSIGN_KEYID
#export DEBFULLNAME
#export DEBEMAIL
# ##### #
# Usage #
# ##### #
function usage()
2017-08-29 17:17:25 +02:00
{
cat << EOF
Usage:
$THISSCRIPT <distrib> <branch> <folder>
Arguments:
2022-01-10 02:07:43 +01:00
<distrib> buster or bullseye
<branch> stable, testing, or unstable
<folder> the folder in which to build...
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} ..."
# Architecture-agnostic packages have 'architecture: all' in their control files
# others have 'architecture: any'
if 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 reprepro --waitforlock 6 -b $REPO_DIR -C $BRANCH include $DISTRIB ${ROOT_DIR}/${PACKAGE}_${VERSION}_$arch.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
}
2022-01-10 02:07:43 +01:00
function build()
{
2022-01-10 02:07:43 +01:00
local arch=$1
if [[ "$arch" == "all" ]]
then
local arch_opt=""
else
local arch_opt="--host=$arch"
fi
sbuild $arch_opt -d $DISTRIB # --anything-failed-commands='%s'
}
[[ "$1" =~ ^-h|--help$ ]] && (usage; exit 0) || main