diff --git a/make/linux-rpm.mk b/make/linux-rpm.mk new file mode 100644 index 00000000..a3672090 --- /dev/null +++ b/make/linux-rpm.mk @@ -0,0 +1,193 @@ +# generic utility modules +# (c) 2004 jannet it services +# contact@jannet.de +# $Id$ + +# config +#KERNEL_VERSION = 2.4.24 +#HOST = zwischenhuber +#CUSTOMER = jannet +#KERNEL_PKG = /home/samba/dat/share/exe/linux/os/$(basename $(KERNEL_VERSION))/linux-$(KERNEL_VERSION).tar.gz +#KERNEL_BASE = linux-$(CUSTOMER)-$(HOST) +#UPLOAD_HOST = ftp.jannet.de +#UPLOAD_PATH = /home/ftp/dat/pub/packages/$(CUSTOMER)/linux/$(HOST) +#UPLOAD_OWNER = $(shell whoami) + +# abbreviations +KERNEL_MINOR := $(shell echo $(KERNEL_VERSION) | cut -d\. -f2) +#HOST = $(shell cd ../..; pwd | xargs basename) +WD := $(shell pwd) +KERNEL_SRC_DIR = $(shell tar -tzf $(KERNEL_DIR)/$(KERNEL_PKG) | head -1) +TMP_INSTALL = $(KERNEL_BASE)-$(KERNEL_VERSION)-$(KERNEL_RELEASE) +TAG = $(shell echo V_$(KERNEL_VERSION)_$(KERNEL_RELEASE) | sed 's/\./_/g') + +ifeq ($(wildcard RELEASE-$(KERNEL_VERSION)),) +KERNEL_RELEASE := $(shell echo '\# $$Id$(KERNEL_VERSION),v 0.1$$' \ + > RELEASE-$(KERNEL_VERSION); \ + cvs add RELEASE-$(KERNEL_VERSION); \ + cvs commit -m "initial checkin" RELEASE-$(KERNEL_VERSION); \ + exit 1)) +else +KERNEL_RELEASE := $(strip $(shell grep Id: RELEASE-$(KERNEL_VERSION) | sed "s/.*RELEASE-$(KERNEL_VERSION),v[ ]*[0-9]*\.\([0-9]*\)[^0-9]*.*/\1/")) +endif + +BASE = $(KERNEL_BASE)-$(KERNEL_VERSION)-$(KERNEL_RELEASE) +BASE_RUN = $(KERNEL_BASE)-run-$(KERNEL_VERSION)-$(KERNEL_RELEASE) +BASE_DEVEL = $(KERNEL_BASE)-devel-$(KERNEL_VERSION)-$(KERNEL_RELEASE) + +F_SPEC = $(BASE).spec +F_TGZ = $(BASE).tar.gz +F_SPM = $(BASE).src.rpm +F_RPM_RUN = $(BASE_RUN).i386.rpm +F_RPM_DEVEL = $(BASE_DEVEL).i386.rpm +F_RPMS = $(F_RPM_RUN) $(F_RPM_DEVEL) +F_BOOTFILES = $(addsuffix -$(KERNEL_VERSION)-$(KERNEL_RELEASE),$(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 = 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 +$(KERNEL_PKG): + ftp -a ftp.kernel.org:/pub/linux/kernel/v$(basename $(KERNEL_VERSION))/$(notdir $(KERNEL_PKG)) + cp $(notdir $(KERNEL_PKG)) $@ + +config-$(KERNEL_VERSION): + cp $(shell ls config-$(basename $(KERNEL_VERSION)).* | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]\)$$/\1.\2.0\3/' | sort -g | sed 's/\.0/./; $$ !d') $@ + cvs add $@ + cvs commit + +unpack.done: $(KERNEL_PKG) + rm -rf linux-$(KERNEL_VERSION) + tar -xzf $(KERNEL_PKG) + touch $@ + +%.lxdone: unpack.done config-$(KERNEL_VERSION) + $(BUILD) $(basename $@) + touch $@ + +$(TMP_INSTALL)/$(F_SPEC): $(MKSPEC) Makefile + $(MKSPEC) -d $(TMP_INSTALL) -b $(KERNEL_BASE) -v $(KERNEL_VERSION) -r $(KERNEL_RELEASE) > $@ + +$(TMP_INSTALL)/boot/%-$(KERNEL_VERSION): build.lxdone $(LOCAL_AFTER_KERNEL_BUILD) + @echo -n + +.PRECIOUS: $(TMP_INSTALL)/boot/%-$(KERNEL_VERSION) + +$(TMP_INSTALL)/boot/%-$(KERNEL_VERSION)-$(KERNEL_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 + rpm -ts $< + cp /usr/src/packages/SRPMS/$@ . + +rpm.done: $(F_SPM) + rpm --rebuild $(F_SPM) + touch $@ + +%.i386.rpm: rpm.done + cp /usr/src/packages/RPMS/i386/$@ . + +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 $@ + +version: + date >> RELEASE-$(KERNEL_VERSION) + cvs commit -m "$(KERNEL_VERSION)" RELEASE-$(KERNEL_VERSION) + exit 1 + +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 +reboot: + ssh -l root $(HOST) "reboot" +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 install/* reiser.patch *~ *.done *.lxdone *.uldone *.patch *.rpm *.tar.gz *.tar $(SCOPE_DRIVER_BASE) + rm -rf linux linux-$(KERNEL_VERSION) $(TMP_INSTALL) CURRENT_*