Blob Blame History Raw
From 85cda6ae16722452e2e8ced77e73be44e4f4a2ad Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 21 Oct 2011 12:35:07 +0200
Subject: [PATCH] dracut.spec: apply patches with git

This will take all renames and mode changes.
---
 dracut.spec |   10 +++++++++-
 git2spec.pl |   21 +--------------------
 2 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/dracut.spec b/dracut.spec
index f9848ed..69809ca 100644
--- a/dracut.spec
+++ b/dracut.spec
@@ -24,7 +24,7 @@ URL: https://dracut.wiki.kernel.org/
 Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
 
 BuildArch: noarch
-BuildRequires: dash bash
+BuildRequires: dash bash git
 %if 0%{?fedora} || 0%{?rhel} > 6
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 %endif
@@ -155,6 +155,14 @@ This package contains tools to assemble the local initrd and host configuration.
 
 %prep
 %setup -q -n %{name}-%{version}
+git init
+git config user.email "dracut-maint@redhat.com"
+git config user.name "Fedora dracut team"
+git add .
+git commit -a -q -m "%{version} baseline."
+
+# Apply all the patches.
+git am -p1 %{patches}
 
 %build
 make
diff --git a/git2spec.pl b/git2spec.pl
index 2ea74c8..9db42aa 100755
--- a/git2spec.pl
+++ b/git2spec.pl
@@ -19,20 +19,12 @@ sub last_tag {
 sub create_patches {
     my $tag=shift;
     my $num=0;
-    open( GIT, 'git format-patch --no-renames -N --no-signature '.$tag.' |');
+    open( GIT, 'git format-patch -N --no-signature '.$tag.' |');
     @lines=<GIT>;
     close GIT;         # be done
     return @lines;
 };
 
-sub filter_patch {
-	my $patch=shift;
-	open(P, $patch);
-	@lines=<P>;
-	close(P);
-	grep (/^ 0 files changed/, @lines);
-}
-
 use POSIX qw(strftime);
 my $datestr = strftime "%Y%m%d", gmtime;
 
@@ -55,22 +47,11 @@ while(<>) {
 	print $_;
 	$num=1;
 	for(@patches) {
-	    next if filter_patch $_;
 	    print "Patch$num: $_";
 	    $num++;
 	}
 	print "\n";
     }
-    elsif (/^%setup/) {
-	print $_;
-	$num=1;
-	for(@patches) {
-	    next if filter_patch $_;
-	    print "%patch$num -p1\n";
-	    $num++;
-	}
-	print "\n";
-    }
     else {
 	print $_;
     }