From 3d21f5dc9aca244041871e95cb035f17943b0d73 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 16 May 2005 14:42:32 +0000 Subject: [PATCH] linux-rpm-build.mk: Add file --- make/linux-rpm-build.mk | 201 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 make/linux-rpm-build.mk diff --git a/make/linux-rpm-build.mk b/make/linux-rpm-build.mk new file mode 100644 index 00000000..678ab35e --- /dev/null +++ b/make/linux-rpm-build.mk @@ -0,0 +1,201 @@ +# abbreviations +define EXTRAVERSION +$(shell cat EXTRAVERSION) +endef +define COMPLETE_VERSION +$(shell cat COMPLETE_VERSION) +endef + +KERNEL_MAJOR = $(shell echo $(KERNEL_VERSION) | cut -d\. -f1) +KERNEL_MINOR = $(shell echo $(KERNEL_VERSION) | cut -d\. -f2) +KERNEL_RELEASE = $(shell echo $(KERNEL_VERSION) | cut -d\. -f3) +KERNEL_PKG_BASE = /home/samba/dat/share/exe/linux/os/$(KERNEL_MAJOR).$(KERNEL_MINOR)/linux-$(KERNEL_VERSION).tar +ifneq ($(wildcard $(KERNEL_PKG_BASE).*),) + ifneq ($(wildcard $(KERNEL_PKG_BASE).gz),) + KERNEL_PKG = $(KERNEL_PKG_BASE).gz + KERNEL_SRC_DIR = $(shell tar -tzf $(KERNEL_DIR)/$(KERNEL_PKG) | head -1) + endif + ifneq ($(wildcard $(KERNEL_PKG_BASE).bz2),) + KERNEL_PKG = $(KERNEL_PKG_BASE).bz2 + KERNEL_SRC_DIR = $(shell tar -tjf $(KERNEL_DIR)/$(KERNEL_PKG) | head -1) + endif +else + KERNEL_PKG = $(KERNEL_PKG_BASE).bz2 + KERNEL_SRC_DIR = linux-$(KERNEL_VERSION) +endif +#HOST = $(shell cd ../..; pwd | xargs basename) +WD := $(shell pwd) +TAG = $(shell echo V_$(KERNEL_VERSION)_$(RPM_RELEASE) | sed 's/\./_/g') +ARCH = $(shell $(RPMBUILD) --showrc | sed '/build arch / !d; s/.*build arch *://; s/ //g') + +RPMBUILD = $(shell which rpmbuild 2>/dev/null) +ifeq ($(RPMBUILD),) +RPMBUILD = $(shell which rpm 2>/dev/null) +endif + +#ifeq ($(wildcard RELEASE-$(KERNEL_VERSION)),) +#RPM_RELEASE := $(shell make newrelease; exit 1) +#else +#RPM_RELEASE_NUM := $(strip $(shell grep Id: RELEASE-$(KERNEL_VERSION) | sed "s/.*RELEASE-$(KERNEL_VERSION),v[ ]*[0-9]*\.\([0-9]*\)[^0-9]*.*/\1/")) +#ifeq ($(UNAME_SUFFIX),) +#RPM_RELEASE = $(RPM_RELEASE_NUM) +#else +#RPM_RELEASE = $(UNAME_SUFFIX)$(RPM_RELEASE_NUM) +#endif +#endif +BASE = $(KERNEL_BASE)-$(COMPLETE_VERSION) +TMP_INSTALL = $(KERNEL_BASE)-$(COMPLETE_VERSION) +BASE_RUN = $(KERNEL_BASE)-run-$(COMPLETE_VERSION) +BASE_DEVEL = $(KERNEL_BASE)-devel-$(COMPLETE_VERSION) + +ifeq ($(BOOT_LABEL),) +BOOT_LABEL = lx-$(COMPLETE_VERSION) +endif + +KERNEL_TGZ = $(notdir $(KERNEL_PKG)) +F_SPEC = $(BASE).spec +F_TGZ = $(BASE).tar.gz +F_SPM = $(BASE).src.rpm +F_RPM_RUN = $(BASE_RUN).$(ARCH).rpm +F_RPM_DEVEL = $(BASE_DEVEL).$(ARCH).rpm +F_RPMS = $(F_RPM_RUN) $(F_RPM_DEVEL) +F_BOOTFILES = $(addsuffix -$(COMPLETE_VERSION),$(addprefix $(TMP_INSTALL)/boot/,vmlinuz config System.map)) +F_CURRENT = $(addprefix CURRENT_, SRC RPM_SRC RPM_RUN_I386 RPM_DEVEL_I386) +F_ULDONE = $(addsuffix .uldone,$(F_RPMS) $(F_TGZ) $(F_SPM) current) +# note that order matters for F_ULDONE and F_RPMS (remote directory attributes) +KERNEL_INSTALL_PREFIX= $(shell pwd)/$(TMP_INSTALL) + +BUILD = sh $(MODDIR)/devutil/jcs/build_linux.sh \ + -c config-$(KERNEL_VERSION) \ + -t $(HOST) \ + -b $(WD) \ + -a i386 \ + -s $(KERNEL_SRC_DIR) \ + -i $(TMP_INSTALL) +MKSPEC := $(shell which mkspec-linux.sh) + +# exports +export KERNEL_VERSION +export KERNEL_INSTALL_PREFIX + +# first target +all: rpm + +# file rules +%.lxdone: config-$(KERNEL_VERSION) $(LOCAL_PRE_BUILD) linux-$(KERNEL_VERSION)/Makefile + $(BUILD) $(basename $@) + touch $@ + +$(TMP_INSTALL)/$(F_SPEC): linux-$(KERNEL_VERSION)/Makefile $(MKSPEC) Makefile + $(MKSPEC) -d $(TMP_INSTALL) -b $(KERNEL_BASE) -v $(KERNEL_VERSION) -r $(RPM_RELEASE) -a $(ARCH) -l $(BOOT_LABEL) > $@ + +$(TMP_INSTALL)/boot/%-$(KERNEL_VERSION)-$(RPM_RELEASE): build.lxdone $(LOCAL_AFTER_KERNEL_BUILD) + @echo -n + +.PRECIOUS: $(TMP_INSTALL)/boot/%-$(KERNEL_VERSION) + +$(TMP_INSTALL)/boot/%-$(KERNEL_VERSION)-$(RPM_RELEASE): $(TMP_INSTALL)/boot/%-$(KERNEL_VERSION) + cp $< $@ + +$(F_TGZ): Makefile build.lxdone $(F_BOOTFILES) $(TMP_INSTALL)/$(F_SPEC) + tar -czf $@ \ + $(F_BOOTFILES) \ + $(addprefix $(TMP_INSTALL)/, \ + lib \ + $(F_SPEC) \ + ) + +%.src.rpm: %.tar.gz + $(RPMBUILD) -ts $< + cp /usr/src/packages/SRPMS/$@ . + +rpm.done: $(F_SPM) + $(RPMBUILD) --rebuild $(F_SPM) + touch $@ + +%.$(ARCH).rpm: rpm.done + cp /usr/src/packages/RPMS/$(ARCH)/$@ . + +CURRENT_RPM_RUN_I386: $(F_RPM_RUN) + echo $(UPLOAD_PATH)/rpm/run/$(F_RPM_RUN) > $@ + +CURRENT_RPM_DEVEL_I386: $(F_RPM_RUN) + echo $(UPLOAD_PATH)/rpm/devel/$(F_RPM_DEVEL) > $@ + +CURRENT_RPM_SRC: $(F_RPM_RUN) + echo $(UPLOAD_PATH)/rpm/src/$(F_RPM_SRC) > $@ + +CURRENT_SRC: $(F_RPM_RUN) + echo $(UPLOAD_PATH)/src/$(F_TGZ) > $@ + +update.done: + cvs update -dP + make rpm + touch $@ + +upload.done: $(F_RPMS) + touch $@ + +%.tar.gz.uldone: %.tar.gz + upload.sh $< rsync_ssh://$(UPLOAD_HOST):$(UPLOAD_PATH)/src/$<:640:750:$(UPLOAD_OWNER).$(CUSTOMER) + touch $@ + +%.src.rpm.uldone: %.src.rpm + upload.sh $< rsync_ssh://$(UPLOAD_HOST):$(UPLOAD_PATH)/rpm/src/$<:640:750:$(UPLOAD_OWNER).$(CUSTOMER) + touch $@ + +%.rpm.uldone: %.rpm + upload.sh $< rsync_ssh://$(UPLOAD_HOST):$(UPLOAD_PATH)/rpm/$(shell echo $@ | sed 's/.*\(run\|devel\).*/\1/')/$<:640:750:$(UPLOAD_OWNER).$(CUSTOMER) + touch $@ + +current.uldone: $(F_CURRENT) + upload.sh $^ rsync_ssh://$(UPLOAD_HOST):$(UPLOAD_PATH)/:640:750:$(UPLOAD_OWNER).$(CUSTOMER) + touch $@ + +tag.done: + cvs tag $(TAG) + touch $@ + +copy-run.done: $(F_RPM_RUN) + scp $< root@$(HOST):/root/rpm/ + touch $@ +copy-devel.done: $(F_RPM_DEVEL) + scp $< root@$(HOST):/root/rpm/ + touch $@ + +ping: + ping $(HOST) +ssh: + ssh -l root $(HOST) + +# user targets +unpack: unpack.done +build: build.lxdone +driver: driver.done +tgz: $(F_TGZ) +spm: $(F_SPM) +rpm: $(F_RPMS) +upload: update.done rpm $(F_ULDONE) +tag: tag.done +install: build.lxdone driver.done install.lxdone +copy-run: copy-run.done +copy-devel: copy-devel.done +copy: copy-run copy-devel +patch: patches.done +shutdown: + ssh -l root $(HOST) "shutdown -h now" +reboot: + ssh -l root $(HOST) "reboot" +update-rpm: copy + ssh -l root $(HOST) rpm -U $(addprefix rpm/,$(F_RPMS)) +erase-rpm: + ssh -l root $(HOST) rpm -e $(KERNEL_BASE)-run $(KERNEL_BASE)-devel +dist: clean + cd ..;\ + tar -czf kernel.tar.gz `find kernel -type f -maxdepth 1 | grep -ve "setup\|trash\|CVS"` + mv ../kernel.tar.gz . +clean: + rm -rf $(TMP_INSTALL) + rm -rf install/* reiser.patch *~ *.done *.lxdone *.uldone *.patch *.rpm *.tar.gz *.tar $(SCOPE_DRIVER_BASE) + rm -rf linux linux-$(KERNEL_VERSION) CURRENT_* + rm -f toplevel-makefile EXTRAVERSION COMPLETE_VERSION