]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Makefile: simplify "make rpm"
authorHarald Hoyer <harald@redhat.com>
Tue, 31 May 2011 14:34:37 +0000 (16:34 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 31 May 2011 14:34:37 +0000 (16:34 +0200)
Makefile
dracut.spec
git2spec.pl [new file with mode: 0755]

index a861d6094eb2f04c23324751c391b5e6f3279e77..778c78c0efd42b2f57874cf81a2eb0397176a1b3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=011
+VERSION=010
 GITVERSION=$(shell [ -d .git ] && git rev-list  --abbrev-commit  -n 1 HEAD  |cut -b 1-8)
 
 prefix ?= /usr
@@ -10,9 +10,10 @@ mandir ?= ${prefix}/share/man
 
 manpages = dracut.8 dracut.kernel.7 dracut.conf.5 dracut-catimages.8  dracut-gencmdline.8
 
-.PHONY: install clean archive rpm testimage test all check AUTHORS
+.PHONY: install clean archive rpm testimage test all check AUTHORS doc
 
-all: syncheck $(manpages) dracut.html
+doc: $(manpages) dracut.html
+all: syncheck
 
 %: %.xml
        xsltproc -o $@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
@@ -23,7 +24,7 @@ dracut.html: dracut.xml $(manpages)
                --stringparam html.stylesheet http://docs.redhat.com/docs/en-US/Common_Content/css/default.css \
                http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
 
-install:
+install: doc
        mkdir -p $(DESTDIR)$(pkglibdir)
        mkdir -p $(DESTDIR)$(sbindir)
        mkdir -p $(DESTDIR)$(sysconfdir)
@@ -64,22 +65,15 @@ dracut-$(VERSION).tar.bz2:
 dracut-$(VERSION).tar.gz:
        git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz
 
-dracut-$(VERSION)-$(GITVERSION).tar.bz2:
-       git archive --format=tar HEAD --prefix=dracut-$(VERSION)-$(GITVERSION)/ |bzip2 > dracut-$(VERSION)-$(GITVERSION).tar.bz2
-
-
-rpm: clean dracut-$(VERSION).tar.bz2
-       rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" -ba dracut.spec 
-       rm -fr BUILD BUILDROOT
-
-gitrpm: dracut-$(VERSION)-$(GITVERSION).tar.bz2
-       echo "%define gittag $(GITVERSION)" > dracut.spec.git
-       cat dracut.spec >> dracut.spec.git
-       mv dracut.spec dracut.spec.bak
-       mv dracut.spec.git dracut.spec
-       rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" --define "gittag $(GITVERSION)" -ba dracut.spec || :
-       mv dracut.spec.bak dracut.spec
-       rm -fr BUILD BUILDROOT
+rpm: dracut-$(VERSION).tar.bz2
+       mkdir -p rpmbuild
+       cp dracut-$(VERSION).tar.bz2 rpmbuild
+       cd rpmbuild; ../git2spec.pl $(VERSION) < ../dracut.spec > dracut.spec; \
+       rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
+               --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
+               --define "_rpmdir $$PWD" -ba dracut.spec || :; \
+       cd ..;
+       rm -fr rpmbuild
 
 syncheck:
        @ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \
index 413ec4e9202b14855475b92a8172a2e9b0f5cc49..edf8d264f315abfe63fcc7e657e3542e58e8e4e5 100644 (file)
@@ -6,17 +6,9 @@
 %define with_nbd 0
 %endif
 
-%if %{defined gittag}
-%define rdist .git%{gittag}%{?dist}
-%define dashgittag -%{gittag}
-%else
-%define rdist %{?dist}
-%endif
-
 Name: dracut
-Version: 011
-%define release_prefix 0%{?rdist}
-Release: %{release_prefix}
+Version: xxx
+Release: xxx
 
 Summary: Initramfs generator using udev
 %if 0%{?fedora}
@@ -28,8 +20,8 @@ Group: System/Base
 License: GPLv2+
 URL: https://dracut.wiki.kernel.org/
 # Source can be generated by
-# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{?dashgittag};sf=tgz
-Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}%{?dashgittag}.tar.bz2
+# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz
+Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
 
 BuildArch: noarch
 BuildRequires: dash bash
@@ -162,7 +154,7 @@ Requires: %{name} = %{version}-%{release}
 This package contains tools to assemble the local initrd and host configuration.
 
 %prep
-%setup -q -n %{name}-%{version}%{?dashgittag}
+%setup -q -n %{name}-%{version}
 
 %build
 make
diff --git a/git2spec.pl b/git2spec.pl
new file mode 100755 (executable)
index 0000000..6e0bff8
--- /dev/null
@@ -0,0 +1,66 @@
+#!/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 $num=0;
+    open( GIT, 'git format-patch -M -N --no-signature '.$tag.' |');
+    @lines=<GIT>;
+    close GIT;         # be done
+    return @lines;
+};
+use POSIX qw(strftime);
+my $datestr = strftime "%Y%m%d", gmtime;
+
+my $tag=shift;
+$tag=&last_tag if not defined $tag;
+my @patches=&create_patches($tag);
+my $num=$#patches + 2;
+$tag=~s/[^0-9]+?([0-9]+)/$1/;
+my $release="$num.git$datestr";
+$release="1" if $num == 1;
+
+while(<>) {
+    if (/^Version:/) {
+       print "Version: $tag\n";
+    }
+    elsif (/^Release:/) {
+       print "Release: $release\n";
+    }
+    elsif ((/^Source0:/) || (/^Source:/)) {
+       print $_;
+       $num=1;
+       for(@patches) {
+           print "Patch$num: $_";
+           $num++;
+       }
+       print "\n";
+    }
+    elsif (/^%setup/) {
+       print $_;
+       $num=1;
+       for(@patches) {
+           print "%patch$num -p1\n";
+           $num++;
+       }
+       print "\n";
+    }
+    else {
+       print $_;
+    }
+}