2020-09-16 20:24:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Script for parsing version information in the repository
|
2021-03-15 19:34:24 +00:00
|
|
|
set -e
|
2020-09-16 20:24:33 +00:00
|
|
|
set -o pipefail
|
|
|
|
|
2021-03-15 19:34:24 +00:00
|
|
|
LINUX_REPOSITORY=linux
|
2021-03-27 15:01:11 +00:00
|
|
|
LINUX_VERSION=$(sed -n "s/^VERSION = \([0-9]*$\)/\1/p" < linux/Makefile | xargs)
|
|
|
|
LINUX_PATCHLEVEL=$(sed -n "s/^PATCHLEVEL = \([0-9]*$\)/\1/p" < linux/Makefile | xargs)
|
|
|
|
LINUX_SUBLEVEL=$(sed -n "s/^SUBLEVEL = \([0-9]*$\)/\1/p" < linux/Makefile | xargs)
|
|
|
|
LINUX_VERSION_FULL=$LINUX_VERSION.$LINUX_PATCHLEVEL.$LINUX_SUBLEVEL
|
|
|
|
PACKAGE_VERSION=$(dpkg-parsechangelog -SVersion)
|
|
|
|
PACKAGE_RELEASE=$(echo $PACKAGE_VERSION | sed -n 's/^.*-\([0-9]*\).*$/\1/p' | xargs)
|
2020-09-16 20:24:33 +00:00
|
|
|
|
2021-03-27 15:01:11 +00:00
|
|
|
while getopts "MmnprdLh" OPTION; do
|
2020-09-16 20:24:33 +00:00
|
|
|
case $OPTION in
|
|
|
|
M)
|
2021-03-27 15:01:11 +00:00
|
|
|
echo $LINUX_VERSION
|
2020-09-16 20:24:33 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
m)
|
2021-03-27 15:01:11 +00:00
|
|
|
echo $LINUX_PATCHLEVEL
|
2020-09-16 20:24:33 +00:00
|
|
|
exit 0
|
2021-02-18 12:51:07 +00:00
|
|
|
;;
|
|
|
|
n)
|
2021-03-27 15:01:11 +00:00
|
|
|
echo $LINUX_VERSION.$LINUX_PATCHLEVEL
|
2021-02-18 12:51:07 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
2020-09-16 20:24:33 +00:00
|
|
|
p)
|
2021-03-27 15:01:11 +00:00
|
|
|
echo $LINUX_SUBLEVEL
|
2020-09-16 20:24:33 +00:00
|
|
|
exit 0
|
2021-02-18 12:51:07 +00:00
|
|
|
;;
|
2020-09-16 20:24:33 +00:00
|
|
|
r)
|
2021-03-27 15:01:11 +00:00
|
|
|
echo $PACKAGE_RELEASE
|
2020-09-16 20:24:33 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
L)
|
2021-03-27 15:01:11 +00:00
|
|
|
echo $LINUX_VERSION_FULL
|
2020-09-17 15:24:01 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
2020-09-16 20:24:33 +00:00
|
|
|
h)
|
2021-03-27 15:01:11 +00:00
|
|
|
echo "version.sh [-Mmnprfh]"
|
2020-09-16 20:24:33 +00:00
|
|
|
echo " -M major version"
|
|
|
|
echo " -m minor version"
|
2021-02-18 12:51:07 +00:00
|
|
|
echo " -n major minor version"
|
2020-09-16 20:24:33 +00:00
|
|
|
echo " -p patch version"
|
|
|
|
echo " -r package release"
|
|
|
|
echo " -L Linux version"
|
|
|
|
echo " -h this help message"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Incorrect options provided"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-03-27 15:01:11 +00:00
|
|
|
echo "$PACKAGE_VERSION"
|