From 8cdf31a27a5b2e7b7c8828d0d45fc9536fddff53 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 18 Jun 2014 10:34:09 +0000 Subject: [PATCH] rpmdist.mk: Add support for git to rpm-release mechanics Signed-off-by: Jan Lindemann --- make/rpmdist.mk | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/make/rpmdist.mk b/make/rpmdist.mk index fd52a10c..f240531b 100644 --- a/make/rpmdist.mk +++ b/make/rpmdist.mk @@ -194,9 +194,16 @@ update-repo.dist: upload.dist # ------ hash stuff -define check_cvs_sync +ifeq ($(wildcard $(TOPDIR)/.git),) + +SCM_COMMIT = cvs commit +SCM_ADD = cvs add +SCM_PUSH = +SCM_PULL = cvs update -dP + +define check_scm_sync echo + checking cvs ;\ - cvs update -dP ;\ + $(SCM_PULL) ;\ cvs status > cvs_status.tmp 2>&1 ;\ if [ $$? != 0 ]; then \ $(CAT) cvs_status.tmp ;\ @@ -213,9 +220,36 @@ define check_cvs_sync fi endef +else + +SCM_COMMIT = git commit -a +SCM_ADD = git add +SCM_PUSH = git push +SCM_PULL = git pull + +define check_scm_sync + echo + checking git ;\ + $(SCM_PULL) || {\ + echo "$(SCM_PULL) failed, giving up" ;\ + exit 1 ;\ + } \ + git status -s > git_status.tmp 2>&1 ;\ + if [ $$? != 0 ]; then \ + $(CAT) git_status.tmp ;\ + echo -e "\n======== git status failed, giving up." >&2 ;\ + exit 1 ;\ + fi ;\ + if grep -qi "^ *M " git_status.tmp; then \ + echo + git copy has locally modified files, giving up >&2 ;\ + exit 1 ;\ + fi +endef + +endif + define increase_build_number if [ "$(CHECK_CVS_SYNC_BEFORE_RPM_RELEASE)" = true ]; then \ - $(check_cvs_sync) ;\ + $(check_scm_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)" ;\ @@ -224,10 +258,11 @@ define increase_build_number 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 ;\ + if ! /bin/bash $(MOD_SCRIPT_DIR)/list-cvs-files.sh | grep -q '^HASH$$'; then \ + $(SCM_ADD) HASH ;\ fi ;\ - cvs commit -m "$(MAJOR_MINOR_RELEASE)-$(shell expr $(BUILD_NUMBER) + 1)-dev" HASH VERSION + $(SCM_COMMIT) -m "$(MAJOR_MINOR_RELEASE)-$(shell expr $(BUILD_NUMBER) + 1)-dev" HASH VERSION + $(SCM_PUSH) endef define check_reinstall_old