dracut/0022-Makefile-git2spec.pl-use-git-describe.patch

96 lines
3.0 KiB
Diff
Raw Normal View History

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/;