Skip to contentSkip to conversation

RPM build target fixes

PATCH In review Alexander Hoogerhuis 2 participants 5 messages Mar 9, 2002 – Mar 10, 2002 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RPM build target fixes

Attached is a patch to make life easier for building RPMs from the source.

Basically it adds:

* .spec files are named with version included
* a .spec file is placed in %_topdir/SPECS on sucessful build so you can do a rpm -bb kernel-x.y.z.spec to recreate the packages.
* a tarball with current source and config is placed in %_topdir/SOURCE after a sucessful build, and also contains a .spec file so anyone can do a rpm -ta tarball.tar.gz.
* a source RPM is left in %_topdir/SRPMS after a successful build.
* a binary RPM is left in %_topdir/RPMS/%_arch for easy install.

Created against 2.4.19-pre2-ac3, but should apply cleanly to any 2.4.18 or better.

Makefile +30 -10
@@ -522,7 +522,13 @@
 #	If you do a make spec before packing the tarball you can rpm -ta it
 #
 spec:
-	. scripts/mkspec >kernel.spec
+	RPMDIR=$(shell rpm --eval \%_topdir) ; \
+	[ -f $(TOPDIR)/kernel-*.spec ] && \
+		rm $(TOPDIR)/kernel-*.spec ; \
+	[ -f $$RPMDIR/SPECS/kernel-$(VERSION).$(PATCHLEVEL).*$(EXTRAVERSION).spec ] && \
+		rm $$RPMDIR/SPECS/kernel-$(VERSION).$(PATCHLEVEL).*$(EXTRAVERSION).spec ; \
+	. scripts/mkspec >$(TOPDIR)/kernel-$(KERNELRELEASE).spec ; \
+	. scripts/mkspec >$$RPMDIR/SPECS/kernel-$(KERNELRELEASE).spec ; 
 
 #
 #	Build a tar ball, generate an rpm from it and pack the result
@@ -533,12 +539,26 @@
 #
 rpm:	clean spec
 	find . \( -size 0 -o -name .depend -o -name .hdepend \) -type f -print | xargs rm -f
-	set -e; \
-	cd $(TOPDIR)/.. ; \
-	ln -sf $(TOPDIR) $(KERNELPATH) ; \
-	tar -cvz --exclude CVS -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
-	rm $(KERNELPATH) ; \
-	cd $(TOPDIR) ; \
-	. scripts/mkversion > .version ; \
-	rpm -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \
-	rm $(TOPDIR)/../$(KERNELPATH).tar.gz
+	RPMDIR=$(shell rpm --eval \%_topdir) ; \
+	. scripts/mkversion > .version.tmp ; \
+	mv .version.tmp .version ; \
+        cd $$RPMDIR/SOURCES ; \
+        ln -sf $(TOPDIR) $(KERNELPATH) ; \
+        tar -cz --exclude CVS -f $$RPMDIR/SOURCES/$(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
+        rm $(KERNELPATH) ; \
+        rm $(TOPDIR)/kernel-$(KERNELRELEASE).spec ; \
+        cd $(TOPDIR) ; \
+        rpm -ba $$RPMDIR/SPECS/kernel-$(KERNELRELEASE).spec ; \
+        if [ $$? -ne 0 ]; then \
+                RPMARCH=(shell rpm --eval \%_arch) ; \
+                [ -f $$RPMDIR/SPECS/kernel-$(KERNELRELEASE).spec ] && \
+                        rm $$RPMDIR/SPECS/kernel-$(KERNELRELEASE).spec ; \
+                [ -f $$RPMDIR/SRPMS/$(KERNELPATH).src.rpm ] && \
+                        rm $$RPMDIR/SRPMS/$(KERNELPATH).src.rpm ; \
+                [ -f $$RPMDIR/RPMS/$$RPMARCH/$(KERNELPATH).$$RPMARCH.rpm ] && \
+                        rm $$RPMDIR/RPMS/$$RPMARCH/$(KERNELPATH).$$RPMARCH.rpm ; \
+                [ -f $$RPMDIR/SOURCES/$(KERNELPATH).tar.gz ] && \
+                        rm $$RPMDIR/SOURCES/$(KERNELPATH).tar.gz ; \
+                [ -d $$RPMDIR/BUILD/$(KERNELPATH) ] && \
+                        rm -rf $$RPMDIR/BUILD/$(KERNELPATH) ; \
+        fi ;

ttfn,
A

Signature · 3 lines
Alexander Hoogerhuis                               | [email protected]
CCNP - CCDP - MCNE - CCSE                          | +47 908 21 485
"You have zero privacy anyway. Get over it."  --Scott McNealy
#1 lore raw
Quoted 1 line

* .spec files are named with version included

Thats exactly the opposite of what is expected

Alan

#2 lore raw
Quoted 4 lines · Alan Cox
Quoted 1 line

* .spec files are named with version included

Thats exactly the opposite of what is expected

How so? Given that it actually cleans up after itself you are not left with multiple .spec files in any directory? Or have I missed something?

Quoted 1 line

Alan

ttfn,
A

Signature · 3 lines
Alexander Hoogerhuis                               | [email protected]
CCNP - CCDP - MCNE - CCSE                          | +47 908 21 485
"You have zero privacy anyway. Get over it."  --Scott McNealy
#3 lore raw
Quoted 4 lines
Quoted 1 line

Thats exactly the opposite of what is expected

How so? Given that it actually cleans up after itself you are not left with multiple .spec files in any directory? Or have I missed something?

Most source rpm packages come with a [packagename.spec] file without a version.

#4 lore raw
Quoted 8 lines · Alan Cox
Quoted 4 lines
Quoted 1 line

Thats exactly the opposite of what is expected

How so? Given that it actually cleans up after itself you are not left with multiple .spec files in any directory? Or have I missed something?

Most source rpm packages come with a [packagename.spec] file without a version.

OK, so the .spec in the tarball should be without (for rpm -ta), and the one left in %_topdir/SPECS should carry it?

Basically why I made the .spec files carry the version was that I have several trees (linux-2.4-[ac|plain|clean|mystuff] and linux-2.5-[dj|plain|clean]) and that way I can build the trees without interfering with eachoter, as all the .spec files, tarballs, RPMs and SRPMs will actually be named something like kernel-$version-$extraversion. That way, if you build two trees they wont stamp on eachother.

ttfn,
A

Signature · 3 lines
Alexander Hoogerhuis                               | [email protected]
CCNP - CCDP - MCNE - CCSE                          | +47 908 21 485
"You have zero privacy anyway. Get over it."  --Scott McNealy