1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!/bin/bash -efu
# Switch the Standards-Version in debian/control.
shopt -s extglob
readonly SCRIPTNAME="$0"
readonly LIST='standards-version.list'
function print_usage_message_and_exit {
cat <<END >&$1
usage: $SCRIPTNAME [-?] RELEASE-CODENAME
example: $SCRIPTNAME bullseye
This helper script switches the Standard-Version in debian/control to
match the version distributed with the specified Debian release, such
as buster, bullseye or bookworm. One might find switching useful
during the preparation of a backports version of the package, among
other times. (Note however that an official backported package is not
to have a lowered Standards-Version, so if the Standards-Version is
switched for purpose of development and testing, then it probably needs
to be switched back before the package is finally built for official
upload. Still, temporary switching might -- or might not -- be helpful
for Lintian.)
END
# When the developer wrote this script, he was just starting to learn
# how to prepare official backports. It may be that the script is not
# very useful. That will be seen.
exit $(($1 - 1))
}
readonly -f print_usage_message_and_exit
(($# == 1)) || print_usage_message_and_exit 2
[ "$1" = '-?' -o "$1" = '--help' ] && print_usage_message_and_exit 1
readonly SCRIPT_DIR="$(dirname -- "$(realpath -e -- "$0")")"
readonly DEBIAN_DIR=$(realpath -e -- "$SCRIPT_DIR/..")
declare CODENAME STANDARDS_VER
declare -i HAS_FOUND=0
while read; do
CODENAME="$(sed -r 's/^\s*(\S+).*$/\1/' <<<"$REPLY")"
if [ "$CODENAME" = $1 ]; then
HAS_FOUND=1
STANDARDS_VER="$(sed -r 's/^\s*\S+\s*(\S+).*$/\1/' <<<"$REPLY")"
break
fi
done <"$SCRIPT_DIR/$LIST"
if ((!$HAS_FOUND)); then
echo $0 error: unknown release codename "'"$1"'"
exit 1
fi
readonly CODENAME STANDARDS_VER
sed -r 's/^(Standards-Version:)\s.*$/\1 '"$STANDARDS_VER"'/'\
-i "$DEBIAN_DIR/control"
|