summaryrefslogtreecommitdiffstats
path: root/0022-Makefile-git2spec.pl-use-git-describe.patch
blob: df18bf0255c6c3be991937da82643fe762a71d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 5f8cd1a4bececb879b3b597e7751d8093d71a4bc Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 11 Apr 2013 10:11:14 +0200
Subject: [PATCH] Makefile,git2spec.pl: use "git describe"

---
 Makefile    | 14 +++++++-------
 git2spec.pl | 19 ++-----------------
 2 files changed, 9 insertions(+), 24 deletions(-)

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