# Re: [PATCH] rpm2git (was RPM to GIT tree integration?)

2 messages from 2009-02-08 to 2009-02-09. Participants: Alex Bennee, Federico Mena Quintero.
Thread: https://gitlist.dev/t/17655

## Alex Bennee, 2009-02-08 16:51

Subject: Re: [PATCH] rpm2git (was RPM to GIT tree integration?)
Message-ID: <b2cdc9f30902080851j724e9fa9s35ff159b775ad614@mail.gmail.com>
URL: https://gitlist.dev/e/b2cdc9f30902080851j724e9fa9s35ff159b775ad614%40mail.gmail.com

```
2009/2/7 James Davidson <james@greycastle.net>:
> On Fri Feb 06, 2009 at 05:05:49PM +0000, Alex Bennee <kernel-hacker@bennee.com> wrote:
>> This is a wild shot in the dark but I thought I'd better ask in case
>> some one has. Has anyone created a script/tool that can take a src RPM and
>> apply it's patches (in sequence) to an existing GIT tree?
>
> This may be what you are looking for:
> http://www.gnome.org/~federico/news-2008-07.html#rpm2git

Pretty much what I wanted although the script breaks on fancy SPEC's
that use variables to evaluate version (like Fedora Core's kernel).
The attached patch allows the specification of the branch by hand.
CC'd to federico.

--
Alex, homepage: http://www.bennee.com/~alex/
CV: http://www.bennee.com/~alex/cv.php


From dd1b69bacb376882da3f820c09451fb764b44116 Mon Sep 17 00:00:00 2001
From: Alex Bennee <alex@bennee.com>
Date: Sun, 8 Feb 2009 16:45:34 +0000
Subject: [PATCH] Allow the specification of an exact branch.

Complex RPMs like the Fedora Core kernel evalulate version on the fly. Allow
the user to overide the simple grep of the spec file
---
 Makefile             |    2 +-
 rpm2git.in           |   19 ++++++++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)
 mode change 100644 => 100755 rpm2git-patch-helper
 mode change 100644 => 100755 rpm2git.in

diff --git a/Makefile b/Makefile
index 38e836e..d08f20a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-PREFIX=/usr/local
+PREFIX=${HOME}/
 LIBDIR=$(PREFIX)/lib
 BINDIR=$(PREFIX)/bin
 
diff --git a/rpm2git-patch-helper b/rpm2git-patch-helper
old mode 100644
new mode 100755
diff --git a/rpm2git.in b/rpm2git.in
old mode 100644
new mode 100755
index e834398..4496c36
--- a/rpm2git.in
+++ b/rpm2git.in
@@ -241,8 +241,8 @@ def rpm2git (from_ref, specfile, dest_branch_name):
 def main (args):
     option_parser = optparse.OptionParser (
         usage=
-"""usage: %prog --from-ref=<refname> --spec=<specfile> --dest-branch-prefix=<name>
-example: %prog --from-ref=NAUTILUS_2_23_1 --spec=/usr/src/packages/SPECS/nautilus.spec --dest-branch-prefix=opensuse""")
+"""usage: %prog --from-ref=<rexfname> --spec=<specfile> --dest-branch-prefix=<name>
+example: %prog --from-ref=NAUTILUS_2_23_1 --spec=/usr/src/packages/SPECS/nautilus.spec [--dest-branch-prefix=opensuse|--dest-branch=name]""")
 
     option_parser.add_option ("",
                               "--from-ref", dest="from_ref",
@@ -253,6 +253,10 @@ example: %prog --from-ref=NAUTILUS_2_23_1 --spec=/usr/src/packages/SPECS/nautilu
                               metavar="FILE",
                               help="Specfile to use to extract patches and version/release info")
     option_parser.add_option ("",
+                              "--dest-branch", dest="dest_branch_name",
+                              metavar="string",
+                              help="name of branch that will be generated")
+    option_parser.add_option ("",
                               "--dest-branch-prefix", dest="dest_branch_prefix",
                               metavar="string",
                               help="Prefix to use for the branch name that will be generated")
@@ -269,7 +273,8 @@ example: %prog --from-ref=NAUTILUS_2_23_1 --spec=/usr/src/packages/SPECS/nautilu
 
     (options, args) = option_parser.parse_args (args)
 
-    if not (options.from_ref and options.spec and options.dest_branch_prefix) or len (args) != 1:
+    if not (options.from_ref and options.spec and
+            (options.dest_branch_prefix or options.dest_branch_name)):
         print_err ("Invalid usage; type '%s --help' for instructions" % sys.argv[0])
         return 1
 
@@ -285,10 +290,10 @@ example: %prog --from-ref=NAUTILUS_2_23_1 --spec=/usr/src/packages/SPECS/nautilu
 
     log ("----- rpm2git start -----")
 
-    dest_branch_name = make_dest_branch_name_from_specfile (options.spec, options.dest_branch_prefix)
-    if dest_branch_name == None:
-        log ("could not generate destination branch name; aborting")
-        return 1
+    if options.dest_branch_name:
+        dest_branch_name = options.dest_branch_name
+    else :
+        dest_branch_name = make_dest_branch_name_from_specfile (options.spec, options.dest_branch_prefix)
 
     log ("Will use destination branch name = %s", dest_branch_name)
     
-- 
1.6.0.6


```

## Federico Mena Quintero, 2009-02-09 21:14

Subject: Re: [PATCH] rpm2git (was RPM to GIT tree integration?)
Message-ID: <1234214050.328.567.camel@cacharro.xalalinux.org>
URL: https://gitlist.dev/e/1234214050.328.567.camel%40cacharro.xalalinux.org
In-Reply-To: <b2cdc9f30902080851j724e9fa9s35ff159b775ad614@mail.gmail.com>

```
On Sun, 2009-02-08 at 16:51 +0000, Alex Bennee wrote:

> Pretty much what I wanted although the script breaks on fancy SPEC's
> that use variables to evaluate version (like Fedora Core's kernel).
> The attached patch allows the specification of the branch by hand.
> CC'd to federico.

Very nice, thanks!  I just pushed this to gitorious, with a few
stylistic changes.

  Federico

```
