git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
ABAlex Bennee <kernel-hacker@bennee.com>
Date
Feb 8, 2009, 16:51 UTC
Message-ID
<b2cdc9f30902080851j724e9fa9s35ff159b775ad614@mail.gmail.com>
2009/2/7 James Davidson <james@greycastle.net>:
Show 7 quoted lines
> 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
Next: Federico Mena Quintero
Message 1 of 2 in “Re: [PATCH] rpm2git (was RPM to GIT tree integration?)”
  1. Alex BenneeFeb 8, 2009
  2. Federico Mena QuinteroFeb 9, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.