Infer version information automatically

This commit is contained in:
Fabian Mastenbroek 2021-03-27 16:01:11 +01:00
parent 7d99d922dd
commit a19eeb34f1
No known key found for this signature in database
GPG key ID: 405FC6F81F0A7B85
3 changed files with 34 additions and 72 deletions

View file

@ -5,7 +5,7 @@ set -o pipefail
LINUX_REPOSITORY=linux
while getopts "R:t:b:v:r:h" OPTION; do
while getopts "R:t:v:r:h" OPTION; do
case $OPTION in
R)
LINUX_REPOSITORY=$OPTARG
@ -13,9 +13,6 @@ while getopts "R:t:b:v:r:h" OPTION; do
t)
LINUX_TAG=$OPTARG
;;
b)
LINUX_BASE=$OPTARG
;;
v)
LINUX_VERSION=$OPTARG
;;
@ -23,10 +20,9 @@ while getopts "R:t:b:v:r:h" OPTION; do
LINUX_PACKAGE_RELEASE=$OPTARG
;;
h)
echo "update.sh -rtbh"
echo "update.sh -Rrtvh"
echo " -R path to Linux Git repository"
echo " -t tag in Linux Git repository to pick"
echo " -b manual basis for this kernel"
echo " -v manual version for this kernel"
echo " -r manual release version for this kernel"
echo " -h this help message"
@ -45,18 +41,12 @@ echo "Fetching $LINUX_TAG from Linux Git repository..."
git --git-dir $LINUX_REPOSITORY/.git fetch origin --depth 1 $LINUX_TAG
git --git-dir $LINUX_REPOSITORY/.git checkout FETCH_HEAD
if [[ -z "$LINUX_BASE" ]]; then
# Parse the Ubuntu base from which our build is derived
UBUNTU_BASE=$(git --git-dir $LINUX_REPOSITORY/.git log -1 --pretty=%B | sed -n "s/^.*Ubuntu-\([0-9.-]*\).*$/\1/p")
LINUX_BASE="Ubuntu $UBUNTU_BASE"
fi
if [[ -z "$LINUX_VERSION" ]]; then
# Parse the Linux version from the Linux repository if it not provided by the user
LINUX_VERSION=$(dpkg-parsechangelog -l $LINUX_REPOSITORY/debian.master/changelog --show-field Version | sed -n "s/^\([0-9.]*\).*$/\1/p")
fi
echo "Using Linux $LINUX_VERSION based on $LINUX_BASE."
echo "Using Linux $LINUX_VERSION."
# Prepare Debian changelog
sed -e "s/@KVNAME@/$LINUX_VERSION/g" -e "s/@KVMAJMIN@/$LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR/g" < debian/control.in > debian/control
@ -79,18 +69,9 @@ else
echo "New package release"
fi
echo "Updating Makefile..."
# Update the Makefile with the proper version numbers
sed -i Makefile \
-e "s/^KERNEL_MAJ=[0-9]*$/KERNEL_MAJ=$LINUX_VERSION_MAJOR/" \
-e "s/^KERNEL_MIN=[0-9]*$/KERNEL_MIN=$LINUX_VERSION_MINOR/" \
-e "s/^KERNEL_PATCHLEVEL=[0-9]*$/KERNEL_PATCHLEVEL=$LINUX_VERSION_PATCH/" \
-e "s/^KREL=[0-9]*$/KREL=1/" \
-e "s/^PKGREL=[0-9]*$/PKGREL=$LINUX_PACKAGE_RELEASE/"
echo "Generating entry for change log..."
# Generate a changelog entry
debchange -v $LINUX_VERSION-$LINUX_PACKAGE_RELEASE -D edge --force-distribution -U -M "Update to Linux $LINUX_VERSION based on $LINUX_BASE."
debchange -v $LINUX_VERSION-$LINUX_PACKAGE_RELEASE -D edge --force-distribution -U -M "Update to Linux $LINUX_VERSION."
echo "Cleaning up"
rm -f debian/control