Blame 0022-Makefile-git2spec.pl-use-git-describe.patch

Harald Hoyer e787af
From 5f8cd1a4bececb879b3b597e7751d8093d71a4bc Mon Sep 17 00:00:00 2001
Harald Hoyer e787af
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer e787af
Date: Thu, 11 Apr 2013 10:11:14 +0200
Harald Hoyer e787af
Subject: [PATCH] Makefile,git2spec.pl: use "git describe"
Harald Hoyer e787af
Harald Hoyer e787af
---
Harald Hoyer e787af
 Makefile    | 14 +++++++-------
Harald Hoyer e787af
 git2spec.pl | 19 ++-----------------
Harald Hoyer e787af
 2 files changed, 9 insertions(+), 24 deletions(-)
Harald Hoyer e787af
Harald Hoyer e787af
diff --git a/Makefile b/Makefile
Harald Hoyer e787af
index 40d44eb..6bda766 100644
Harald Hoyer e787af
--- a/Makefile
Harald Hoyer e787af
+++ b/Makefile
Harald Hoyer e787af
@@ -1,5 +1,6 @@
Harald Hoyer e787af
-VERSION=027
Harald Hoyer e787af
-GITVERSION=$(shell [ -d .git ] && git rev-list  --abbrev-commit  -n 1 HEAD  |cut -b 1-8)
Harald Hoyer e787af
+RELEASEDVERSION = -- will be replaced by "make dist" --
Harald Hoyer e787af
+VERSION = $(shell [ -d .git ] && git describe --abbrev=0 --tags || echo $(RELEASEDVERSION))
Harald Hoyer e787af
+GITVERSION = $(shell [ -d .git ] && { v=$$(git describe --tags); echo -$${v\#*-}; } )
Harald Hoyer e787af
 
Harald Hoyer e787af
 -include Makefile.inc
Harald Hoyer e787af
 
Harald Hoyer e787af
@@ -35,7 +36,7 @@ man8pages = dracut.8 \
Harald Hoyer e787af
 manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
Harald Hoyer e787af
 
Harald Hoyer e787af
 
Harald Hoyer e787af
-.PHONY: install clean archive rpm testimage test all check AUTHORS doc
Harald Hoyer e787af
+.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
Harald Hoyer e787af
 
Harald Hoyer e787af
 all: syncheck dracut-version.sh dracut-install
Harald Hoyer e787af
 
Harald Hoyer e787af
@@ -138,7 +139,7 @@ endif
Harald Hoyer e787af
 	install -m 0644 dracut-bash-completion.sh $(DESTDIR)${bashcompletiondir}/dracut
Harald Hoyer e787af
 
Harald Hoyer e787af
 dracut-version.sh:
Harald Hoyer e787af
-	@echo "DRACUT_VERSION=$(VERSION)-$(GITVERSION)" > dracut-version.sh
Harald Hoyer e787af
+	@echo "DRACUT_VERSION=$(VERSION)$(GITVERSION)" > dracut-version.sh
Harald Hoyer e787af
 
Harald Hoyer e787af
 clean:
Harald Hoyer e787af
 	$(RM) *~
Harald Hoyer e787af
@@ -151,15 +152,14 @@ clean:
Harald Hoyer e787af
 	$(RM) $(manpages) dracut.html
Harald Hoyer e787af
 	$(MAKE) -C test clean
Harald Hoyer e787af
 
Harald Hoyer e787af
-archive: dracut-$(VERSION)-$(GITVERSION).tar.bz2
Harald Hoyer e787af
-
Harald Hoyer e787af
 dist: dracut-$(VERSION).tar.bz2
Harald Hoyer e787af
 
Harald Hoyer e787af
 dracut-$(VERSION).tar.bz2: doc
Harald Hoyer e787af
 	git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ > dracut-$(VERSION).tar
Harald Hoyer e787af
 	mkdir -p dracut-$(VERSION)
Harald Hoyer e787af
 	cp $(manpages) dracut.html dracut-$(VERSION)
Harald Hoyer e787af
-	tar -rf dracut-$(VERSION).tar dracut-$(VERSION)/*.[0-9] dracut-$(VERSION)/dracut.html
Harald Hoyer e787af
+	sed 's/^RELEASEDVERSION =.*/RELEASEDVERSION = $(VERSION)/' Makefile > dracut-$(VERSION)/Makefile
Harald Hoyer e787af
+	tar --owner=root --group=root -rf dracut-$(VERSION).tar dracut-$(VERSION)/*.[0-9] dracut-$(VERSION)/dracut.html dracut-$(VERSION)/Makefile
Harald Hoyer e787af
 	rm -fr dracut-$(VERSION).tar.bz2 dracut-$(VERSION)
Harald Hoyer e787af
 	bzip2 -9 dracut-$(VERSION).tar
Harald Hoyer e787af
 	rm -f dracut-$(VERSION).tar
Harald Hoyer e787af
diff --git a/git2spec.pl b/git2spec.pl
Harald Hoyer e787af
index 9f12577..0d8adb4 100755
Harald Hoyer e787af
--- a/git2spec.pl
Harald Hoyer e787af
+++ b/git2spec.pl
Harald Hoyer e787af
@@ -1,21 +1,5 @@
Harald Hoyer e787af
 #!/usr/bin/perl
Harald Hoyer e787af
 
Harald Hoyer e787af
-sub last_tag {
Harald Hoyer e787af
-    open( GIT, 'git log  --pretty=format:%H |');
Harald Hoyer e787af
-  LINE: while( <GIT> ) {
Harald Hoyer e787af
-      open( GIT2, "git tag --contains $_ |");
Harald Hoyer e787af
-      while( <GIT2> ) {
Harald Hoyer e787af
-	  chomp;
Harald Hoyer e787af
-	  last LINE if /..*/;
Harald Hoyer e787af
-      }
Harald Hoyer e787af
-      close GIT2;
Harald Hoyer e787af
-  }
Harald Hoyer e787af
-    $tag=$_;
Harald Hoyer e787af
-    close GIT2;
Harald Hoyer e787af
-    close GIT;         # be done
Harald Hoyer e787af
-    return $tag;
Harald Hoyer e787af
-};
Harald Hoyer e787af
-
Harald Hoyer e787af
 sub create_patches {
Harald Hoyer e787af
     my $tag=shift;
Harald Hoyer e787af
     my $pdir=shift;
Harald Hoyer e787af
@@ -31,7 +15,8 @@ my $datestr = strftime "%Y%m%d", gmtime;
Harald Hoyer e787af
 
Harald Hoyer e787af
 my $tag=shift;
Harald Hoyer e787af
 my $pdir=shift;
Harald Hoyer e787af
-$tag=&last_tag if not defined $tag;
Harald Hoyer e787af
+$tag=`git describe --abbrev=0 --tags` if not defined $tag;
Harald Hoyer e787af
+chomp($tag);
Harald Hoyer e787af
 my @patches=&create_patches($tag, $pdir);
Harald Hoyer e787af
 my $num=$#patches + 2;
Harald Hoyer e787af
 $tag=~s/[^0-9]+?([0-9]+)/$1/;