jw-pkg/make/rpmdist.mk
Jan Lindemann b81092f1d1 rpmdist.mk: Try to automatically update VERSION
First attempt at automated version update during make rpm-release
2007-08-22 11:37:55 +00:00

212 lines
6.3 KiB
Makefile

UPLOAD_SH = $(MOD_SCRIPT_DIR)/upload.sh
ifeq ($(RPM_PROJECT),)
RPM_PROJECT ?= $(PROJECT)
endif
MKSPEC_SH ?= $(MOD_SCRIPT_DIR)/mkspec_wrapper.sh $(TOPDIR)/make/mkspec.sh
FTP_SRC_GROUP ?= $(shell id -g)
FTP_SRC_USER ?= $(shell whoami)
FTP_RUN_GROUP ?= $(shell id -g)
FTP_RUN_USER ?= $(shell whoami)
FTP_DEV_GROUP ?= $(shell id -g)
FTP_DEV_USER ?= $(shell whoami)
FTP_HOST ?= ftp.jannet.de
FTP_FILE_MODE ?= 644
FTP_DIR_MODE ?= 755
FTP_HOST ?= ftp.jannet.de
FTP_HOST_LOGIN ?= root
RPM_PROJECT ?= $(PROJECT)
RPM_VERSION ?= $(DIST_VERSION)
RPM_ARCH ?= i586
RPMBUILD ?= rpmbuild
include $(MODDIR)/make/tag-defs.mk
CLEAN += $(wildcard *.spec *.rpm *~ *.rpmrc *.dist .*.swp)
DIST_SRC_DIR = dist/src/$(RPM_PROJECT)-$(RPM_VERSION)
DIST_PCKG_DIR = dist/pckg
#DIST_FILE = $(DIST_PCKG_DIR)/$(PROJECT)-$(DIST_VERSION).tar.gz
PCKG_TAR ?= $(RPM_PROJECT)-$(RPM_VERSION).tar.gz
PCKG_RPM_RUN_I386 ?= $(RPM_PROJECT)-run-$(RPM_VERSION).$(RPM_ARCH).rpm
PCKG_RPM_DEVEL_I386 ?= $(RPM_PROJECT)-devel-$(RPM_VERSION).$(RPM_ARCH).rpm
PCKG_RPM_SRC ?= $(RPM_PROJECT)-$(RPM_VERSION).src.rpm
include $(MODDIR)/make/upload-defs.mk
DIST_FILES = $(shell echo $(REMOTE_TARGETS) | sed 's/\b.*\///g; s/:.*\b//g')
GENERATED = $(sort $(shell find . -name '*.in' | \
sed "s/\.in$$//; s%$(DIST_SRC_DIR)%%; s%^[./]*%%"))
RPMS_DIR = /usr/src/packages/RPMS/$(RPM_ARCH)
SRPMS_DIR = /usr/src/packages/SRPMS
DIST_DIRS = $(DIST_SRC_DIR) $(DIST_PCKG_DIR)
DIST_PCKG_RPM = $(DIST_PCKG_DIR)/$(PCKG_RPM_RUN_I386) $(DIST_PCKG_DIR)/$(PCKG_RPM_DEVEL_I386)
include $(MODDIR)/make/tag-rules.mk
include $(MODDIR)/make/upload-rules.mk
all:
install:
clean: rpm-clean
distclean: rpm-clean
tgz: $(PCKG_TAR)
ftag: ftag.dist
rpm-upload-stable: rpm-upload-STABLE.dist
rpm-upload-rc: rpm-upload-RC.dist
rpm-clean: clean.rpm
rpm-uninstall: rpmuninstall.dist
rpm-install: rpminstall.dist
rpm-reinstall: rpm-uninstall rpm-clean rpm-install
clean.rpm:
rm -rf $(DIST_SRC_DIR) $(PCKG_TAR) *.dist
cpmod.dist:
for mod in $(SUBDIRS); do \
make -C $$mod distclean ;\
mkdir -p $(DIST_SRC_DIR)/$$mod ;\
tar -C $$mod \
--exclude=dist \
--exclude=pckg \
--exclude=Debug \
--exclude=CVS \
--exclude=old \
--exclude=v1.1 \
--exclude='*.o' \
--exclude='*~' \
--exclude=xml-flat \
--exclude=contrib \
-cf - . | tar -C $(DIST_SRC_DIR)/$$mod -xf - ;\
done
touch $@
cpfiles.dist:
mkdir -p $(DIST_SRC_DIR)
cp $(wildcard Makefile configure.ac.tmpl) $(DIST_SRC_DIR)
sh $(MKSPEC_SH) -V $(RPM_VERSION) -S $(notdir $(PCKG_TAR)) -N $(RPM_PROJECT) \
-R "$(RPM_REQUIRES_RUN)" -D "$(RPM_REQUIRES_DEVEL)" -P $(PROJECT) \
> $(DIST_SRC_DIR)/$(RPM_PROJECT)-$(RPM_VERSION).spec
echo $(RPM_VERSION) > $(DIST_SRC_DIR)/VERSION
touch $@
%.tar.gz: cpfiles.dist cpmod.dist
mkdir -p $(DIST_PCKG_DIR)
tar --anchored $(addprefix --exclude=,$(GENERATED))\
-czvf $@ -C $(dir $(DIST_SRC_DIR)) $(notdir $(DIST_SRC_DIR))
%.src.rpm: %.tar.gz
$(RPMBUILD) -ts $<
cp $(SRPMS_DIR)/$(notdir $@) $@
$(DIST_PCKG_RPM): $(DIST_PCKG_DIR)/$(PCKG_TAR)
if [ $< -nt $(RPMS_DIR)/$(notdir $@) ]; then $(RPMBUILD) -tb $<; fi
cp $(RPMS_DIR)/$(notdir $@) $@
$(DIST_PCKG_DIR)/CURRENT_%: $(TOPDIR)/VERSION
echo $(CURRENT_$*) > $@
build.dist: $(DIST_FILES)
rpminstall.dist: $(DIST_PCKG_RPM)
@set -e; for p in $^; do \
if ! /bin/rpm -q `basename $$p | sed "s/\.$(RPM_ARCH)\.rpm//"` > /dev/null 2>&1 ; then \
echo + installing $$p ;\
sudo /bin/rpm -U $$p; \
fi; \
done
touch $@
rpmuninstall.dist:
@set -e; for s in devel run; do \
if /bin/rpm -q $(RPM_PROJECT)-$$s > /dev/null 2>&1 ; then \
echo + removing $(RPM_PROJECT)-$$s ;\
sudo /bin/rpm -e $(RPM_PROJECT)-$$s --nodeps; \
fi; \
done
rm -f rpminstall.dist
upload-%.dist: %_$(PROJECT_CAPNAME)_RPM_RUN_I386
cvs commit $<
$(UPLOAD_SH) $< $(REMOTE_TARGET_PREFIX)$(PCKG_ROOT)/$<:640:750:$(FTP_RUN_USER).$(FTP_RUN_GROUP)
touch $@
update-repo.dist: upload.dist
ssh -l root $(FTP_HOST) /etc/cron.hourly/create_packet_descriptions.sh
touch $@
# ------ hash stuff
define cvs_files
for d in `find . | sed '/CVS\/Entries$$/ !d; s%CVS/Entries%%'`; do \
sed "/^\// !d; s%^/%%; s%/.*%%; s%^%$$d%" $$d/CVS/Entries ;\
done
endef
CHECK_CVS_STATUS_BEFORE_INCREASING_BUILD_NUMBER ?= true
define increase_build_number
if [ "$(CHECK_CVS_STATUS_BEFORE_INCREASING_BUILD_NUMBER)" = true ]; then \
echo + checking cvs ;\
cvs status > cvs_status.tmp 2>&1;\
if [ $$? != 0 ]; then \
cat cvs_status.tmp ;\
echo -e "\n======== cvs status failed, giving up." >&2 ;\
exit 1 ;\
fi ;\
if grep -qi "locally modified" cvs_status.tmp; then \
echo + tried to increase build number on cvs copy with locally modified files, giving up >&2 ;\
exit 1 ;\
fi ;\
if grep -qi "needs" cvs_status.tmp; then \
echo + tried to increase build number on out-of-date cvs copy, giving up >&2 ;\
exit 1 ;\
fi ;\
fi ;\
echo $(MAJOR_MINOR_RELEASE)-$(shell expr $(BUILD_NUMBER) + 1)-dev | tee VERSION ;\
echo $(HASH) > HASH ;\
if ! grep -q HASH CVS/Entries; then \
echo cvs add HASH ;\
fi ;\
echo cvs commit -m "o $(VERSION)" HASH VERSION
endef
HASH = $(shell $(cvs_files) | grep -v "CHANGES\|VERSION\|HASH\|MD5SUMS" | xargs md5sum | md5sum | sed 's/ .*//')
LAST_RPM_VERSION = $(shell cat $(TOPDIR)/LAST_RPM_VERSION >/dev/null 2>&1)
md5clean:
rm -f HASH
md5:
echo $(HASH) > HASH
rpm-update-release:
@if [ "`cat HASH`" != "$(HASH)" ]; then \
echo + source was modified ;\
$(increase_build_number) ;\
else \
echo + source is unmodified, new build unnecessary ;\
fi
rpm-check-release:
@if [ "`cat HASH`" != "$(HASH)" ]; then \
echo + source was modified ;\
else \
echo + source is unmodified, new build unnecessary ;\
fi
rpm-next-build:
$(increase_build_number)
rpm-release: rpm-update-release
if [ "$(VERSION)" != "$(LAST_RPM_VERSION)" ]; then ;\
echo make update-repo.dist ;\
cp VERSION LAST_RPM_VERSION ;\
if ! grep -q LAST_RPM_VERSION CVS/Entries; then
cvs add LAST_RPM_VERSION ;\
fi ;\
echo cvs commit -m "o $(VERSION)" LAST_RPM_VERSION ;\
fi