jw-pkg/make/rpmdist.mk

219 lines
6.8 KiB
Makefile
Raw Normal View History

CREATE_DEVEL ?= true
UPLOAD_SH = $(MOD_SCRIPT_DIR)/upload.sh
RPM_PROJECT ?= $(FLAVOUR_PREFIX)$(PROJECT)
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)
LAST_RPM_VERSION_FILE = $(TOPDIR)/LAST_RPM_VERSION$(FLAVOUR_SUFFIX)
LAST_RPM_VERSION ?= $(shell sed 's/-dev$$//' $(LAST_RPM_VERSION_FILE) 2>/dev/null)
RPM_ARCH ?= i586
RPMBUILD ?= rpmbuild
CHECK_CVS_SYNC_BEFORE_RPM_RELEASE ?= true
HASH = $(shell $(cvs_files) | \
grep -v "CHANGES\|VERSION\|HASH\|MD5SUMS\|_RPM_RUN" | \
xargs md5sum | md5sum | sed 's/ .*//')
include $(MODDIR)/make/tag-defs.mk
2002-07-10 12:24:05 +00:00
DIST_DIR = dist
DIST_SRC_DIR = $(DIST_DIR)/src/$(RPM_PROJECT)-$(RPM_VERSION)
DIST_PCKG_DIR = $(DIST_DIR)/pckg
#DIST_FILE = $(DIST_PCKG_DIR)/$(PROJECT)-$(DIST_VERSION).tar.gz
2002-07-01 18:26:01 +00:00
PCKG_TAR ?= $(RPM_PROJECT)-$(RPM_VERSION).tar.gz
PCKG_RPM_RUN_I386 ?= $(RPM_PROJECT)-run-$(RPM_VERSION).$(RPM_ARCH).rpm
ifeq ($(CREATE_DEVEL),true)
PCKG_RPM_DEVEL_I386 ?= $(RPM_PROJECT)-devel-$(RPM_VERSION).$(RPM_ARCH).rpm
endif
PCKG_RPM_SRC ?= $(RPM_PROJECT)-$(RPM_VERSION).src.rpm
2010-07-03 16:20:28 +00:00
include $(MODDIR)/make/upload-defs-rpm.mk
2002-07-01 18:26:01 +00:00
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)
2002-07-01 18:26:01 +00:00
SRPMS_DIR = /usr/src/packages/SRPMS
2004-11-29 21:56:13 +00:00
DIST_DIRS = $(DIST_SRC_DIR) $(DIST_PCKG_DIR)
DIST_PCKG_RPM = $(DIST_PCKG_DIR)/$(PCKG_RPM_RUN_I386)
ifeq ($(CREATE_DEVEL),true)
DIST_PCKG_RPM += $(DIST_PCKG_DIR)/$(PCKG_RPM_DEVEL_I386)
endif
RPM_REQUIRES_DEVEL += $(RPM_PROJECT)-run = $(RPM_VERSION)
unexport RPM_VERSION VERSION DIST_SRC_DIR
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
2007-08-23 17:55:13 +00:00
rpm-clean: clean.rpm
rpm-uninstall: config rpmuninstall.dist
2007-08-24 20:14:21 +00:00
rpm-build: config rpmbuild.dist
rpm-install: config rpminstall.dist
2007-08-21 19:56:26 +00:00
rpm-reinstall: rpm-uninstall rpm-clean rpm-install
clean.rpm:
rm -rf $(DIST_DIR) *.dist CURRENT_RPM_SRC
src-dir.dist:
2002-07-01 18:26:01 +00:00
mkdir -p $(DIST_SRC_DIR)
touch $@
cpfiles.dist: src-dir.dist
rm -rf $(DIST_SRC_DIR)/*
$(cvs_files) | grep -v VERSION | cpio -o -H newc | ( cd $(DIST_SRC_DIR); cpio --make-directories -i)
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
2002-07-10 12:24:05 +00:00
echo $(RPM_VERSION) > $(DIST_SRC_DIR)/VERSION
2002-07-01 18:26:01 +00:00
touch $@
%.tar.gz: $(RPM_EXTRA_FILES) cpfiles.dist
2002-07-01 18:26:01 +00:00
mkdir -p $(DIST_PCKG_DIR)
tar --anchored $(addprefix --exclude=,$(GENERATED)) \
-czvf $@ -C $(dir $(DIST_SRC_DIR)) $(notdir $(DIST_SRC_DIR))
2004-07-29 11:38:49 +00:00
2002-07-01 18:26:01 +00:00
%.src.rpm: %.tar.gz
$(RPMBUILD) -ts $<
2002-07-01 18:26:01 +00:00
cp $(SRPMS_DIR)/$(notdir $@) $@
2004-11-29 21:56:13 +00:00
$(DIST_PCKG_RPM): $(DIST_PCKG_DIR)/$(PCKG_TAR)
if [ $< -nt $(RPMS_DIR)/$(notdir $@) ]; then $(RPMBUILD) -tb $<; fi
cp $(RPMS_DIR)/$(notdir $@) $@
2002-07-03 20:33:20 +00:00
$(DIST_PCKG_DIR)/CURRENT_%: $(TOPDIR)/VERSION
2002-07-01 18:26:01 +00:00
echo $(CURRENT_$*) > $@
2007-08-24 20:14:21 +00:00
rpmbuild.dist: $(DIST_PCKG_RPM) $(DIST_FILES)
touch $@
2004-11-29 21:56:13 +00:00
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
2004-11-29 21:56:13 +00:00
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 ;\
2009-04-09 08:51:05 +00:00
sudo /bin/rpm -e $(RPM_PROJECT)-$$s --nodeps --allmatches; \
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
2007-12-19 20:52:10 +00:00
$(CVS_RSH) -l root $(FTP_HOST) $(UPDATE_REPO_SH)
touch $@
# ------ hash stuff
define check_cvs_sync
echo + checking cvs ;\
cvs update -dP ;\
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 + cvs copy has locally modified files, giving up >&2 ;\
exit 1 ;\
fi ;\
if grep -qi "needs" cvs_status.tmp; then \
echo + cvs copy is out-of-date, giving up >&2 ;\
exit 1 ;\
fi
endef
define increase_build_number
if [ "$(CHECK_CVS_SYNC_BEFORE_RPM_RELEASE)" = true ]; then \
$(check_cvs_sync) ;\
fi ;\
if [ "$(LAST_RPM_VERSION)" != "$(RPM_VERSION)" ]; then \
echo "+ no need to increase build number of $(RPM_VERSION), last rpm has $(LAST_RPM_VERSION)" ;\
exit 0 ;\
fi ;\
2007-08-28 16:16:34 +00:00
echo -n "+ increasing build number to " ;\
echo $(MAJOR_MINOR_RELEASE)-$(shell expr $(BUILD_NUMBER) + 1)-dev | tee VERSION ;\
echo $(HASH) > HASH ;\
if ! grep -q HASH CVS/Entries; then \
cvs add HASH ;\
fi ;\
cvs commit -m "$(MAJOR_MINOR_RELEASE)-$(shell expr $(BUILD_NUMBER) + 1)-dev" HASH VERSION
endef
define check_reinstall_old
(make rpm-uninstall && make rpm-install)
endef
md5:
echo $(HASH) > HASH
rpm-next-build:
@$(increase_build_number)
rpm-update-release:
@if [ "`cat HASH`" != "$(HASH)" ]; then \
echo + source was modified ;\
$(increase_build_number) ;\
elif ! $(check_reinstall_old); then \
echo "+ old rpm is uninstallable" ;\
$(increase_build_number) ;\
fi
rpm-check-release:
@if [ "`cat HASH`" != "$(HASH)" ]; then \
echo + source was modified ;\
else \
echo + source is unmodified ;\
fi
rpm-release: rpm-update-release
@if [ "$(LAST_RPM_VERSION)" != "$(RPM_VERSION)" ]; then \
$(check_cvs_sync) ;\
echo "+ version $(RPM_VERSION) doesn't match latest released rpm version "\
"$(LAST_RPM_VERSION), building a new release" ;\
make rpm-clean update-repo.dist || exit 1;\
cp VERSION $(LAST_RPM_VERSION_FILE) ;\
if ! grep -q $(LAST_RPM_VERSION_FILE) CVS/Entries; then \
cvs add $(LAST_RPM_VERSION_FILE) ;\
fi ;\
cvs commit -m "o $(shell cat $(LAST_RPM_VERSION_FILE))" $(LAST_RPM_VERSION_FILE) ;\
else \
echo "+ version matches latest released rpm version" ;\
fi