Skip to content

Commit 25b080b

Browse files
committed
kbuild: rpm-pkg: fix version number handling
The "Release:" field of the spec file is determined based on the .version file. However, the .version file is not copied to the source tar file. So, when we build the kernel from the source package, the UTS_VERSION always indicates #1. This does not match with "rpm -q". The kernel UTS_VERSION and "rpm -q" do not agree for binrpm-pkg, either. Please note the kernel has already been built before the spec file is created. Currently, mkspec invokes mkversion. This script returns an incremented version. So, the "Release:" field of the spec file is greater than the version in the kernel by one. For the source package build (where .version file is missing), we can give KBUILD_BUILD_VERSION=%{release} to the build command. For the binary package build, we can simply read out the .version file because it contains the version number that was used for building the kernel image. We can remove scripts/mkversion because scripts/package/Makefile need not touch the .version file. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent cc18abb commit 25b080b

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

scripts/mkversion

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/package/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ rpm-pkg rpm: FORCE
5050
$(MAKE) clean
5151
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
5252
$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
53-
$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
54-
mv -f $(objtree)/.tmp_version $(objtree)/.version
5553
rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
5654
rm $(KERNELPATH).tar.gz kernel.spec
5755

@@ -60,9 +58,6 @@ rpm-pkg rpm: FORCE
6058
binrpm-pkg: FORCE
6159
$(MAKE) KBUILD_SRC=
6260
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
63-
$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
64-
mv -f $(objtree)/.tmp_version $(objtree)/.version
65-
6661
rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
6762
$(UTS_MACHINE) -bb $(objtree)/binkernel.spec
6863
rm binkernel.spec

scripts/package/mkspec

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ __KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
2727
echo "Name: kernel"
2828
echo "Summary: The Linux Kernel"
2929
echo "Version: $__KERNELRELEASE"
30-
# we need to determine the NEXT version number so that uname and
31-
# rpm -q will agree
32-
echo "Release: `. $srctree/scripts/mkversion`"
30+
echo "Release: $(cat .version 2>/dev/null || echo 1)"
3331
echo "License: GPL"
3432
echo "Group: System Environment/Kernel"
3533
echo "Vendor: The Linux Community"
@@ -77,7 +75,7 @@ fi
7775
echo "%build"
7876

7977
if ! $PREBUILT; then
80-
echo "make clean && make %{?_smp_mflags}"
78+
echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}"
8179
echo ""
8280
fi
8381

0 commit comments

Comments
 (0)