forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kbuild: Fix off-by-one error when generate a new version
When build on, for example, x86 using `make O=... -j64` the version in the built kernel comes from include/generated/compile.h, which is: #define UTS_VERSION "torvalds#351 SMP Fri Jan 24 18:46:34 EET 2020" While at the end the x86 specific Makefile prints the contents of the .version file: Kernel: arch/x86/boot/bzImage is ready (torvalds#352) Obviously the latter is not true. This happens because we first check compile.h and update it and then generate new version, which is incorrect flow: CHK include/generated/compile.h UPD include/generated/compile.h ... GEN .version In order to fix this, move the version generation from link-vmlinux.sh to scripts/version.sh and re-use it in init/Makefile. Additionally provide a unified way to get the current version of the build and use this in few callers. This will respect the KBUILD_BUILD_VERSION in case it's provided. Signed-off-by: Andy Shevchenko <[email protected]>
- Loading branch information
1 parent
6d5a828
commit c66b9bc
Showing
8 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh -e | ||
|
||
show_version() { | ||
local dotversion="$1"; shift | ||
|
||
# Check if special build version is requested | ||
if [ -n "$KBUILD_BUILD_VERSION" ]; then | ||
echo "$KBUILD_BUILD_VERSION" | ||
else | ||
cat $dotversion 2>/dev/null || echo 1 | ||
fi | ||
} | ||
|
||
update_version() { | ||
local dotversion="$1"; shift | ||
|
||
# Don't update local version if special build version is requested | ||
if [ -n "$KBUILD_BUILD_VERSION" ]; then return; fi | ||
|
||
if [ -r $dotversion ]; then | ||
local version="$(expr 0$(cat $dotversion) + 1)" | ||
echo "$version" > $dotversion | ||
else | ||
rm -f $dotversion | ||
echo "1" > $dotversion | ||
fi | ||
} | ||
|
||
VERSION_FILE_NAME=".version" | ||
|
||
show= | ||
update= | ||
while [ "$#" -ge "1" ]; do | ||
case "$1" in | ||
--show) show=1 ;; | ||
--update) update=1 ;; | ||
--) break ;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ -n "$1" ]; then VERSION_FILE_NAME="$1"; fi | ||
|
||
if [ -n "$show" ]; then show_version "$VERSION_FILE_NAME"; fi | ||
if [ -n "$update" ]; then update_version "$VERSION_FILE_NAME"; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters