All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix 'make rpm' when CONFIG_LOCALVERSION_AUTO=y and using SCM tree
@ 2009-02-12 18:16 Josh Hunt
  2009-02-15  9:03 ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Hunt @ 2009-02-12 18:16 UTC (permalink / raw)
  To: sam; +Cc: linux-kbuild, linux-kernel, kiran, mingo

Running 'make rpm' fails when CONFIG_LOCALVERSION_AUTO=y and using a kernel source
tree under SCM.  This is due to KERNELRELEASE being different when the initial make
is run and when make is run from rpmbuild.

mkspec creates kernel.spec using KERNELRELEASE:

<mkspec>
echo "%files"
echo '%defattr (-, root, root)'
echo "%dir /lib/modules"
echo "/lib/modules/$KERNELRELEASE"
echo "/lib/firmware"
echo "/boot/*"
echo ""
</mkspec>

When CONFIG_LOCALVERSION_AUTO=y scripts/setlocalversion is called and grabs any
additional version info from SCM.  Next, the srctree is tarred up and SCM
information is excluded.

rpmbuild reruns make and in the process generates a new include/config/kernel.release
and thus a new KERNELRELEASE.  However this time the SCM information is gone so
KERNELRELEASE no longer has the additional version information.  When "make modules_install"
runs, it uses the new KERNELRELEASE value to determine where to install the modules.
This conflicts with where the spec file assumes they are going because of the
mis-matching KERNELRELEASE versions.

<snippet>
+ INSTALL_MOD_PATH=/var/tmp/kernel-2.6.29rc4tip01479g5d85422-root
+ make -j16 modules_install
  INSTALL crypto/aead.ko
  INSTALL crypto/cbc.ko
  INSTALL crypto/chainiv.ko
  INSTALL crypto/crc32c.ko
  INSTALL crypto/crypto_algapi.ko
  INSTALL crypto/crypto_blkcipher.ko
  INSTALL crypto/crypto_hash.ko
  INSTALL crypto/cryptomgr.ko
  INSTALL crypto/ecb.ko
  INSTALL crypto/eseqiv.ko
  INSTALL crypto/krng.ko
  INSTALL crypto/md5.ko
  INSTALL crypto/pcbc.ko
  INSTALL crypto/rng.ko
  INSTALL drivers/block/cciss.ko
  INSTALL drivers/hid/hid-dummy.ko
  INSTALL drivers/scsi/iscsi_tcp.ko
  INSTALL drivers/scsi/libiscsi.ko
  INSTALL drivers/scsi/libiscsi_tcp.ko
  INSTALL drivers/scsi/scsi_transport_iscsi.ko
  INSTALL drivers/scsi/scsi_wait_scan.ko
  INSTALL fs/lockd/lockd.ko
  INSTALL fs/nfs/nfs.ko
  INSTALL fs/nfsd/nfsd.ko
  INSTALL lib/libcrc32c.ko
  INSTALL net/sunrpc/sunrpc.ko
  DEPMOD  2.6.29-rc4-tip
+ cp arch/x86/boot/bzImage
/var/tmp/kernel-2.6.29rc4tip01479g5d85422-root/boot/vmlinuz-2.6.29-rc4-tip-01479-g5d85422
+ cp System.map
/var/tmp/kernel-2.6.29rc4tip01479g5d85422-root/boot/System.map-2.6.29-rc4-tip-01479-g5d85422
+ cp .config
/var/tmp/kernel-2.6.29rc4tip01479g5d85422-root/boot/config-2.6.29-rc4-tip-01479-g5d85422
+ cp vmlinux vmlinux.orig
+ bzip2 -9 vmlinux
+ mv vmlinux.bz2
/var/tmp/kernel-2.6.29rc4tip01479g5d85422-root/boot/vmlinux-2.6.29-rc4-tip-01479-g5d85422.bz2
+ mv vmlinux.orig vmlinux
+ /usr/lib/rpm/brp-compress
Processing files: kernel-2.6.29rc4tip01479g5d85422-2
error: File not found:
/var/tmp/kernel-2.6.29rc4tip01479g5d85422-root/lib/modules/2.6.29-rc4-tip-01479-g5d85422


RPM build errors:
    File not found:
/var/tmp/kernel-2.6.29rc4tip01479g5d85422-root/lib/modules/2.6.29-rc4-tip-01479-g5d85422
make[1]: *** [rpm] Error 1
make: *** [rpm] Error 2
</snippet>

I have tested this patch on git -tip, Linus' git tree, and the kernel.org tar files, both
with and without CONFIG_LOCALVERSION_AUTO=y.

Signed-off-by: Josh Hunt <josh@scalex86.org>

Index: linux-2.6/Makefile
===================================================================
--- linux-2.6.orig/Makefile     2009-02-10 12:09:16.000000000 -0800
+++ linux-2.6/Makefile  2009-02-11 15:01:33.000000000 -0800
@@ -907,8 +907,17 @@
 # Other SCMs can edit scripts/setlocalversion and add the appropriate
 # checks as needed.
 ifdef CONFIG_LOCALVERSION_AUTO
-       _localver-auto = $(shell $(CONFIG_SHELL) \
+
+
+scmversion = $(shell cat .autoversion 2> /dev/null)
+
+ifeq ($(scmversion),)
+       _localver-auto = $(shell  $(CONFIG_SHELL) \
                          $(srctree)/scripts/setlocalversion
$(srctree))
+else
+       _localver-auto = $(shell cat .autoversion 2> /dev/null)
+endif
+
        localver-auto  = $(LOCALVERSION)$(_localver-auto)
 endif

Index: linux-2.6/scripts/package/Makefile
===================================================================
--- linux-2.6.orig/scripts/package/Makefile     2009-02-10
12:09:50.000000000 -0800
+++ linux-2.6/scripts/package/Makefile  2009-02-11 16:33:55.000000000
-0800
@@ -35,10 +35,17 @@
 rpm-pkg rpm: $(objtree)/kernel.spec FORCE
        $(MAKE) clean
        $(PREV) ln -sf $(srctree) $(KERNELPATH)
+
+       set -e; \
+       $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion >
$(objtree)/.autoversion
+
        $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz
$(KERNELPATH)/.
        $(PREV) rm $(KERNELPATH)

        set -e; \
+       rm $(objtree)/.autoversion
+
+       set -e; \
        $(CONFIG_SHELL) $(srctree)/scripts/mkversion >
$(objtree)/.tmp_version
        set -e; \
        mv -f $(objtree)/.tmp_version $(objtree)/.version


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix 'make rpm' when CONFIG_LOCALVERSION_AUTO=y and using SCM tree
  2009-02-12 18:16 [PATCH] Fix 'make rpm' when CONFIG_LOCALVERSION_AUTO=y and using SCM tree Josh Hunt
@ 2009-02-15  9:03 ` Sam Ravnborg
  2009-02-17  0:10   ` Josh Hunt
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2009-02-15  9:03 UTC (permalink / raw)
  To: Josh Hunt; +Cc: linux-kbuild, linux-kernel, kiran, mingo

On Thu, Feb 12, 2009 at 10:16:05AM -0800, Josh Hunt wrote:
> Running 'make rpm' fails when CONFIG_LOCALVERSION_AUTO=y and using a kernel source
> tree under SCM.  This is due to KERNELRELEASE being different when the initial make
> is run and when make is run from rpmbuild.
...

I had to hand apply your patch and ended up with the following.

Changes:
- renamed from autoversion to scmversion
- simpler logic in top-level Makefile
- removed "set -e;" in scripts/package/Makefile - they are not needed

Please test.

	Sam

diff --git a/Makefile b/Makefile
index 22d7584..3824446 100644
--- a/Makefile
+++ b/Makefile
@@ -903,12 +903,18 @@ localver = $(subst $(space),, $(string) \
 # and if the SCM is know a tag from the SCM is appended.
 # The appended tag is determined by the SCM used.
 #
-# Currently, only git is supported.
-# Other SCMs can edit scripts/setlocalversion and add the appropriate
-# checks as needed.
+# .scmversion is used when generating rpm packages so we do not loose
+# the version information from the SCM when we do the build of the kernel
+# from the copied source
 ifdef CONFIG_LOCALVERSION_AUTO
-	_localver-auto = $(shell $(CONFIG_SHELL) \
-	                  $(srctree)/scripts/setlocalversion $(srctree))
+
+ifeq ($(wildcard .scmversion),)
+        _localver-auto = $(shell $(CONFIG_SHELL) \
+                         $(srctree)/scripts/setlocalversion $(srctree))
+else
+        _localver-auto = $(shell cat .scmversion 2> /dev/null)
+endif
+
 	localver-auto  = $(LOCALVERSION)$(_localver-auto)
 endif
 
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 8c6b7b0..fa4a0a1 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -35,9 +35,10 @@ $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
 rpm-pkg rpm: $(objtree)/kernel.spec FORCE
 	$(MAKE) clean
 	$(PREV) ln -sf $(srctree) $(KERNELPATH)
+	$(CONFIG_SHELL) $(srctree)/scripts/setlocalversion > $(objtree)/.scmversion
 	$(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
 	$(PREV) rm $(KERNELPATH)
-
+	rm -f $(objtree)/.scmversion
 	set -e; \
 	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
 	set -e; \

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix 'make rpm' when CONFIG_LOCALVERSION_AUTO=y and using SCM tree
  2009-02-15  9:03 ` Sam Ravnborg
@ 2009-02-17  0:10   ` Josh Hunt
  0 siblings, 0 replies; 3+ messages in thread
From: Josh Hunt @ 2009-02-17  0:10 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kbuild, linux-kernel, kiran, mingo

On Sun, Feb 15, 2009 at 10:03:01AM +0100, Sam Ravnborg wrote:
> 
> I had to hand apply your patch and ended up with the following.

Sorry, not sure what happened there. 

> 
> Changes:
> - renamed from autoversion to scmversion
> - simpler logic in top-level Makefile
> - removed "set -e;" in scripts/package/Makefile - they are not needed
> 
> Please test.

The changes look good. All tested and works fine.

I'm still a little new to this - let me know if I need to resubmit
with your changes or if I need to provide anything else. 

Thanks
Josh

> 
> diff --git a/Makefile b/Makefile
> index 22d7584..3824446 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -903,12 +903,18 @@ localver = $(subst $(space),, $(string) \
>  # and if the SCM is know a tag from the SCM is appended.
>  # The appended tag is determined by the SCM used.
>  #
> -# Currently, only git is supported.
> -# Other SCMs can edit scripts/setlocalversion and add the appropriate
> -# checks as needed.
> +# .scmversion is used when generating rpm packages so we do not loose
> +# the version information from the SCM when we do the build of the kernel
> +# from the copied source
>  ifdef CONFIG_LOCALVERSION_AUTO
> -	_localver-auto = $(shell $(CONFIG_SHELL) \
> -	                  $(srctree)/scripts/setlocalversion $(srctree))
> +
> +ifeq ($(wildcard .scmversion),)
> +        _localver-auto = $(shell $(CONFIG_SHELL) \
> +                         $(srctree)/scripts/setlocalversion $(srctree))
> +else
> +        _localver-auto = $(shell cat .scmversion 2> /dev/null)
> +endif
> +
>  	localver-auto  = $(LOCALVERSION)$(_localver-auto)
>  endif
>  
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 8c6b7b0..fa4a0a1 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -35,9 +35,10 @@ $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
>  rpm-pkg rpm: $(objtree)/kernel.spec FORCE
>  	$(MAKE) clean
>  	$(PREV) ln -sf $(srctree) $(KERNELPATH)
> +	$(CONFIG_SHELL) $(srctree)/scripts/setlocalversion > $(objtree)/.scmversion
>  	$(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
>  	$(PREV) rm $(KERNELPATH)
> -
> +	rm -f $(objtree)/.scmversion
>  	set -e; \
>  	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>  	set -e; \
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-02-17  0:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-12 18:16 [PATCH] Fix 'make rpm' when CONFIG_LOCALVERSION_AUTO=y and using SCM tree Josh Hunt
2009-02-15  9:03 ` Sam Ravnborg
2009-02-17  0:10   ` Josh Hunt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.