Skip to content

Commit da048f5

Browse files
committed
feat: Set localversion
Signed-off-by: Loïc Minier <[email protected]>
1 parent e627f60 commit da048f5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/build-linux-deb.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,29 @@ configure_kernel() {
8282
fi
8383
}
8484

85+
set_kernel_version() {
86+
# the default upstream algorithm for KERNELRELEASE from
87+
# linux/scripts/setlocalversion would be fine, but prepend flavor name for
88+
# the package names to be like linux-image-flavor-kernelrelease instead of
89+
# linux-image-kernelrelease
90+
91+
# produce a version based on latest tag name, number of commits on top, and
92+
# sha of latest commit, for instance: v6.16, v6.17-rc3-289-gfe3ad7,
93+
# v6.17-rc4
94+
localversion="$(git describe --tags --abbrev=1)"
95+
96+
# remove leading "v" and prepend flavor
97+
localversion="${FLAVOR}-${localversion#v}"
98+
99+
log_i "Local version is $localversion"
100+
101+
# create or update tag
102+
git tag --force "$localversion"
103+
104+
# create localversion file for linux/scripts/setlocalversion
105+
echo "$localversion" >localversion
106+
}
107+
85108
build_kernel() {
86109
echo "-${FLAVOR}" >localversion
87110
make -C linux "-j$(nproc)" \
@@ -99,6 +122,9 @@ get_kernel
99122
log_i "Configuring Linux with base config ${CONFIG} and config fragments $*"
100123
configure_kernel "$@"
101124

125+
log_i "Setting local kernel version for flavor ${FLAVOR}"
126+
set_kernel_version
127+
102128
log_i "Building Linux deb"
103129
build_kernel
104130

0 commit comments

Comments
 (0)