Infer version information automatically
This commit is contained in:
parent
7d99d922dd
commit
a19eeb34f1
3 changed files with 34 additions and 72 deletions
11
Makefile
11
Makefile
|
@ -1,16 +1,11 @@
|
||||||
KERNEL_MAJ=5
|
|
||||||
KERNEL_MIN=11
|
|
||||||
KERNEL_PATCHLEVEL=0
|
|
||||||
|
|
||||||
KREL=1
|
|
||||||
|
|
||||||
PKGREL=1
|
PKGREL=1
|
||||||
PKGRELLOCAL=1
|
PKGRELLOCAL=1
|
||||||
PKGRELFULL=${PKGREL}
|
PKGRELFULL=${PKGREL}
|
||||||
|
|
||||||
KERNEL_MAJMIN=$(KERNEL_MAJ).$(KERNEL_MIN)
|
KERNEL_MAJMIN=$(shell ./scripts/version.sh -n)
|
||||||
KERNEL_VER=$(KERNEL_MAJMIN).$(KERNEL_PATCHLEVEL)
|
KERNEL_VER=$(shell ./scripts/version.sh -L)
|
||||||
|
|
||||||
|
KREL=1
|
||||||
EXTRAVERSION=-${KREL}
|
EXTRAVERSION=-${KREL}
|
||||||
|
|
||||||
# Append Linux flavor name to EXTRAVERSION
|
# Append Linux flavor name to EXTRAVERSION
|
||||||
|
|
|
@ -5,7 +5,7 @@ set -o pipefail
|
||||||
|
|
||||||
LINUX_REPOSITORY=linux
|
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
|
case $OPTION in
|
||||||
R)
|
R)
|
||||||
LINUX_REPOSITORY=$OPTARG
|
LINUX_REPOSITORY=$OPTARG
|
||||||
|
@ -13,9 +13,6 @@ while getopts "R:t:b:v:r:h" OPTION; do
|
||||||
t)
|
t)
|
||||||
LINUX_TAG=$OPTARG
|
LINUX_TAG=$OPTARG
|
||||||
;;
|
;;
|
||||||
b)
|
|
||||||
LINUX_BASE=$OPTARG
|
|
||||||
;;
|
|
||||||
v)
|
v)
|
||||||
LINUX_VERSION=$OPTARG
|
LINUX_VERSION=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
@ -23,10 +20,9 @@ while getopts "R:t:b:v:r:h" OPTION; do
|
||||||
LINUX_PACKAGE_RELEASE=$OPTARG
|
LINUX_PACKAGE_RELEASE=$OPTARG
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo "update.sh -rtbh"
|
echo "update.sh -Rrtvh"
|
||||||
echo " -R path to Linux Git repository"
|
echo " -R path to Linux Git repository"
|
||||||
echo " -t tag in Linux Git repository to pick"
|
echo " -t tag in Linux Git repository to pick"
|
||||||
echo " -b manual basis for this kernel"
|
|
||||||
echo " -v manual version for this kernel"
|
echo " -v manual version for this kernel"
|
||||||
echo " -r manual release version for this kernel"
|
echo " -r manual release version for this kernel"
|
||||||
echo " -h this help message"
|
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 fetch origin --depth 1 $LINUX_TAG
|
||||||
git --git-dir $LINUX_REPOSITORY/.git checkout FETCH_HEAD
|
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
|
if [[ -z "$LINUX_VERSION" ]]; then
|
||||||
# Parse the Linux version from the Linux repository if it not provided by the user
|
# 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")
|
LINUX_VERSION=$(dpkg-parsechangelog -l $LINUX_REPOSITORY/debian.master/changelog --show-field Version | sed -n "s/^\([0-9.]*\).*$/\1/p")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Using Linux $LINUX_VERSION based on $LINUX_BASE."
|
echo "Using Linux $LINUX_VERSION."
|
||||||
|
|
||||||
# Prepare Debian changelog
|
# 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
|
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"
|
echo "New package release"
|
||||||
fi
|
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..."
|
echo "Generating entry for change log..."
|
||||||
# Generate a changelog entry
|
# 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"
|
echo "Cleaning up"
|
||||||
rm -f debian/control
|
rm -f debian/control
|
||||||
|
|
|
@ -4,56 +4,46 @@ set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
LINUX_REPOSITORY=linux
|
LINUX_REPOSITORY=linux
|
||||||
LINUX_VERSION_MAJOR=$(sed -n "s/^KERNEL_MAJ=\([0-9]*$\)/\1/p" < Makefile | xargs)
|
LINUX_VERSION=$(sed -n "s/^VERSION = \([0-9]*$\)/\1/p" < linux/Makefile | xargs)
|
||||||
LINUX_VERSION_MINOR=$(sed -n "s/^KERNEL_MIN=\([0-9]*$\)/\1/p" < Makefile | xargs)
|
LINUX_PATCHLEVEL=$(sed -n "s/^PATCHLEVEL = \([0-9]*$\)/\1/p" < linux/Makefile | xargs)
|
||||||
LINUX_VERSION_PATCHLEVEL=$(sed -n "s/^KERNEL_PATCHLEVEL=\([0-9]*$\)/\1/p" < Makefile | xargs)
|
LINUX_SUBLEVEL=$(sed -n "s/^SUBLEVEL = \([0-9]*$\)/\1/p" < linux/Makefile | xargs)
|
||||||
LINUX_VERSION_PATCHLEVEL=${LINUX_VERSION_PATCHLEVEL:-0}
|
LINUX_VERSION_FULL=$LINUX_VERSION.$LINUX_PATCHLEVEL.$LINUX_SUBLEVEL
|
||||||
LINUX_VERSION=$LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR.$LINUX_VERSION_PATCHLEVEL
|
PACKAGE_VERSION=$(dpkg-parsechangelog -SVersion)
|
||||||
LINUX_PACKAGE_RELEASE=$(sed -n "s/^PKGREL=\(.*\)$/\1/p" < Makefile | xargs)
|
PACKAGE_RELEASE=$(echo $PACKAGE_VERSION | sed -n 's/^.*-\([0-9]*\).*$/\1/p' | xargs)
|
||||||
LINUX_FLAVOR=$(sed -n "s/^PVE_BUILD_TYPE ?=\(.*\)$/\1/p" < Makefile | xargs)
|
|
||||||
|
|
||||||
while getopts "MmnprfdLBh" OPTION; do
|
while getopts "MmnprdLh" OPTION; do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
M)
|
M)
|
||||||
echo $LINUX_VERSION_MAJOR
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
m)
|
|
||||||
echo $LINUX_VERSION_MINOR
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
n)
|
|
||||||
echo $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
p)
|
|
||||||
echo $LINUX_VERSION_PATCHLEVEL
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
r)
|
|
||||||
echo $LINUX_PACKAGE_RELEASE
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
f)
|
|
||||||
echo $LINUX_FLAVOR
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
L)
|
|
||||||
echo $LINUX_VERSION
|
echo $LINUX_VERSION
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
B)
|
m)
|
||||||
echo $(git --git-dir $LINUX_REPOSITORY/.git log -1 --pretty=%B | sed -n "s/^.*Ubuntu-\([0-9.-]*\).*$/\1/p")
|
echo $LINUX_PATCHLEVEL
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
n)
|
||||||
|
echo $LINUX_VERSION.$LINUX_PATCHLEVEL
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
echo $LINUX_SUBLEVEL
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
echo $PACKAGE_RELEASE
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
L)
|
||||||
|
echo $LINUX_VERSION_FULL
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo "version.sh [-Mmnprfh]]"
|
echo "version.sh [-Mmnprfh]"
|
||||||
echo " -M major version"
|
echo " -M major version"
|
||||||
echo " -m minor version"
|
echo " -m minor version"
|
||||||
echo " -n major minor version"
|
echo " -n major minor version"
|
||||||
echo " -p patch version"
|
echo " -p patch version"
|
||||||
echo " -r package release"
|
echo " -r package release"
|
||||||
echo " -f flavor name"
|
|
||||||
echo " -L Linux version"
|
echo " -L Linux version"
|
||||||
echo " -h this help message"
|
echo " -h this help message"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -65,8 +55,4 @@ while getopts "MmnprfdLBh" OPTION; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$LINUX_FLAVOR" ]]; then
|
echo "$PACKAGE_VERSION"
|
||||||
LINUX_FLAVOR_SUFFIX=-$LINUX_FLAVOR
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$LINUX_VERSION$LINUX_FLAVOR_SUFFIX-$LINUX_PACKAGE_RELEASE"
|
|
||||||
|
|
Loading…
Reference in a new issue