From ba0ce06d4dd8ea2472c5b7939fef9a47a3f4cd42 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 26 Nov 2007 21:40:29 +0000 Subject: [PATCH] revert the logic, rpms depends on srpm (*) for usual packges CODESPECS -> MAKE -> CODEBASE -> SOURCES -> SRPM -> RPM (*) for packages containing 'srpm' CODESPECS -> MAKE -> CODEBASE -> make srpm -> SRPM -> RPM (*) needed to rename SPECS into CODESPECS for timestamps consistency spec files get overwritten when rebuilding from source rpm --- Makefile | 75 ++++++++++++++++++++++++++++++---------------------- planetlab.mk | 19 ++++++++++--- 2 files changed, 58 insertions(+), 36 deletions(-) diff --git a/Makefile b/Makefile index 51d8b56c..6a47c3a7 100644 --- a/Makefile +++ b/Makefile @@ -188,8 +188,7 @@ include $(ALLMKS) # mention $(ALL) here rather than rpms # this is because the inter-package dependencies are expressed like # util-vserver: util-python -all: $(ALL) -all: srpms +all: rpms endif endif @@ -217,7 +216,7 @@ SOURCES/myplc-release: # define stage1_variables $(1)_spec = $(notdir $($(1)-SPEC)) -$(1)_specpath = SPECS/$(notdir $($(1)-SPEC)) +$(1)_specpath = CODESPECS/$(notdir $($(1)-SPEC)) $(1)_module = $(firstword $($(1)-MODULES)) endef @@ -244,7 +243,7 @@ $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package)))) # cannot use variables in such rules, we need to inline everything, sigh define target_spec $($(1)_specpath): - mkdir -p SPECS + mkdir -p CODESPECS (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $($(1)_specpath) echo "%define distroname $(DISTRO)" >> $($(1)_specpath) echo "%define distrorelease $(RELEASE)" >> $($(1)_specpath) @@ -272,7 +271,8 @@ spec2make: spec2make.c # Base rpmbuild in the current directory export HOME := $(shell pwd) .rpmmacros: - echo "%_topdir $(HOME)" > $@ + rm -f $@ + echo "%_topdir $(HOME)" >> $@ echo "%_tmppath $(HOME)/tmp" >> $@ ### run spec2make on the spec file and include the result @@ -369,47 +369,58 @@ CODEBASES/%: $(call extract_single_module,$(package))) @(echo -n "XXXXXXXXXXXXXXX -- END CODEBASE $(package) : $@ " ; date) -### rpmbuild invokation -ALLRPMS:=$(foreach package,$(ALL),$($(package)-RPM)) -# same as above, mention $(ALL) and not $(ALLRPMS) -rpms: $(ALL) - @echo $(words $(ALLRPMS)) binary rpms OK -.PHONY: rpms - -# usage: build_binary_rpm package -# xxx hacky - invoke createrepo if DEPENDFILES mentions RPMS/yumgroups.xml -define target_binary_rpm -$($(1)-RPM): $($(1)_specpath) $($(1)-TARBALL) .rpmmacros - mkdir -p BUILD RPMS tmp - @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date) - $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPENDFILES)), createrepo --quiet -g yumgroups.xml RPMS/ , ) - $(if $($(1)-RPMBUILD),\ - $($(1)-RPMBUILD) $($(1)-RPMFLAGS) -bb $($(1)_specpath), \ - $(RPMBUILD) $($(1)-RPMFLAGS) -bb $($(1)_specpath)) - @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date) -endef - -$(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package)))) - ### source rpms ALLSRPMS:=$(foreach package,$(ALL),$($(package)-SRPM)) srpms: $(ALLSRPMS) @echo $(words $(ALLSRPMS)) source rpms OK .PHONY: srpms -# usage: build_source_rpm package +# usage: target_source_rpm package +# select upon the package name, whether it contains srpm or not define target_source_rpm -$($(1)-SRPM): $($(1)_specpath) $($(1)-TARBALL) .rpmmacros +ifeq "$(subst srpm,,$(1))" "$(1)" +$($(1)-SRPM): $($(1)_specpath) .rpmmacros $($(1)-TARBALL) mkdir -p BUILD SRPMS tmp @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) " ; date) $(if $($(1)-RPMBUILD),\ $($(1)-RPMBUILD) $($(1)-RPMFLAGS) -bs $($(1)_specpath), $(RPMBUILD) $($(1)-RPMFLAGS) -bs $($(1)_specpath)) @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date) +else +$($(1)-SRPM): $($(1)_specpath) .rpmmacros $($(1)-CODEBASE) + mkdir -p BUILD SRPMS tmp + @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) " ; date) + make -C $($(1)-CODEBASE) srpm && \ + rm -f SRPMS/$(notdir $($(1)-SRPM)) && \ + ln $($(1)-CODEBASE)/$(notdir $($(1)-SRPM)) SRPMS/$(notdir $($(1)-SRPM)) + @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date) +endif endef $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package)))) +### rpmbuild invokation +ALLRPMS:=$(foreach package,$(ALL),$($(package)-RPM)) +# same as above, mention $(ALL) and not $(ALLRPMS) +rpms: $(ALLRPMS) + @echo $(words $(ALLRPMS)) binary rpms OK +.PHONY: rpms + +# usage: build_binary_rpm package +# xxx hacky - invoke createrepo if DEPENDFILES mentions RPMS/yumgroups.xml +define target_binary_rpm +$($(1)-RPM): $($(1)-SRPM) + mkdir -p BUILD RPMS SPECS tmp + @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date) + $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPENDFILES)), createrepo --quiet -g yumgroups.xml RPMS/ , ) + $(if $($(1)-RPMBUILD),\ + $($(1)-RPMBUILD) $($(1)-RPMFLAGS) --rebuild $($(1)-SRPM), \ + $(RPMBUILD) $($(1)-RPMFLAGS) --rebuild $($(1)-SRPM)) + @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date) +endef + +$(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package)))) + ### RPMS/yumgroups.xml ifndef YUMGROUPS YUMGROUPS := groups/$(PLDISTRO).xml @@ -508,9 +519,9 @@ clean-help: ### brute force clean distclean1: - rm -rf pldistro.mk .rpmmacros spec2make SPECS MAKE + rm -rf pldistro.mk .rpmmacros spec2make CODESPECS MAKE distclean2: - rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp + rm -rf CODEBASES SOURCES BUILD RPMS SRPMS SPECS tmp distclean: distclean1 distclean2 .PHONY: distclean1 distclean2 distclean @@ -556,7 +567,7 @@ help: @echo "Run make in two stages:" @echo "" @echo "make stage1=true PLDISTRO=onelab" - @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/" + @echo " -> extracts all spec files in CODESPECS/ and mk files in MAKE/" @echo " as well as save PLDISTRO for subsequent runs" @echo "" @echo "Then you can use the following targets" diff --git a/planetlab.mk b/planetlab.mk index e791f006..4acdf9c3 100644 --- a/planetlab.mk +++ b/planetlab.mk @@ -14,21 +14,32 @@ # until we are able to build the new kernel layout: # use the old exploded-tree, 2.6.20-based, version on fc4, 6 & 7 # and the new one on f8 - that requires the build-id patch + +# +# use a package name with srpm in it: +# in this case the srpm is created by running make srpm in the codebase # + ifeq "$(RELEASE)" "8" -kernel-$(HOSTARCH)-MODULES := linux-patches -kernel-$(HOSTARCH)-SPEC := kernel-2.6-planetlab.spec +srpm-kernel-$(HOSTARCH)-MODULES := linux-patches +srpm-kernel-$(HOSTARCH)-SPEC := kernel-2.6-planetlab.spec +ifeq ($(HOSTARCH),i386) +srpm-kernel-$(HOSTARCH)-RPMFLAGS:= --target i686 +else +srpm-kernel-$(HOSTARCH)-RPMFLAGS:= --target $(HOSTARCH) +endif +KERNELS += srpm-kernel-$(HOSTARCH) + else kernel-$(HOSTARCH)-MODULES := linux-tree kernel-$(HOSTARCH)-SPEC := scripts/kernel-2.6-planetlab.spec -endif ifeq ($(HOSTARCH),i386) kernel-$(HOSTARCH)-RPMFLAGS:= --target i686 else kernel-$(HOSTARCH)-RPMFLAGS:= --target $(HOSTARCH) endif - KERNELS += kernel-$(HOSTARCH) +endif kernel: $(KERNELS) kernel-clean: $(foreach package,$(KERNELS),$(package)-clean) -- 2.43.0