[linux] 03/05: debian/patches/features/all/rt/genpatch.py: Use upstream tarball directly

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Sun Jun 5 18:23:54 UTC 2016


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch master
in repository linux.

commit 964980804a63177b89bc59967b87cbe183c06953
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Sun Jun 5 18:25:28 2016 +0100

    debian/patches/features/all/rt/genpatch.py: Use upstream tarball directly
---
 debian/changelog                           |  1 +
 debian/patches/features/all/rt/genpatch.py | 55 +++++++++++++++++++-----------
 2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 904cb5d..00ecdbd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,7 @@ linux (4.6.1-1~exp1) UNRELEASED; urgency=medium
   * debian/patches/features/all/rt/genpatch.py: Use Python 3
   * debian/patches/features/all/rt/genpatch.py: Fix mapping of -rt version to
     upstream version
+  * debian/patches/features/all/rt/genpatch.py: Use upstream tarball directly
 
  -- Ben Hutchings <ben at decadent.org.uk>  Sat, 04 Jun 2016 18:33:11 +0100
 
diff --git a/debian/patches/features/all/rt/genpatch.py b/debian/patches/features/all/rt/genpatch.py
index e94e67e..021bc4c 100755
--- a/debian/patches/features/all/rt/genpatch.py
+++ b/debian/patches/features/all/rt/genpatch.py
@@ -1,8 +1,8 @@
 #!/usr/bin/python3
 
-import errno, os, os.path, re, shutil, subprocess, sys
+import errno, os, os.path, re, shutil, subprocess, sys, tempfile
 
-def main(source_dir, version):
+def main(source, version=None):
     patch_dir = 'debian/patches'
     rt_patch_dir = 'features/all/rt'
     series_name = 'series-rt'
@@ -43,12 +43,12 @@ def main(source_dir, version):
             series_fh.write('\n')
             new_series.add(name)
 
-        if os.path.isdir(os.path.join(source_dir, '.git')):
+        if os.path.isdir(os.path.join(source, '.git')):
             # Export rebased branch from stable-rt git as patch series
             up_ver = re.sub(r'-rt\d+$', '', version)
             args = ['git', 'format-patch', 'v%s..v%s-rebase' % (up_ver, version)]
             env = os.environ.copy()
-            env['GIT_DIR'] = os.path.join(source_dir, '.git')
+            env['GIT_DIR'] = os.path.join(source, '.git')
             child = subprocess.Popen(args,
                                      cwd=os.path.join(patch_dir, rt_patch_dir),
                                      env=env, stdout=subprocess.PIPE)
@@ -63,22 +63,36 @@ def main(source_dir, version):
                         origin = 'https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit?id=%s' % match.group(1)
                         add_patch(name, source_patch, origin)
         else:
+            # Get version and upstream version
+            if version is None:
+                match = re.search(r'(?:^|/)patches-(.+)\.tar\.[gx]z$', source)
+                assert match, 'no version specified or found in filename'
+                version = match.group(1)
             match = re.match(r'^(\d+\.\d+)(?:\.\d+|-rc\d+)?-rt\d+$', version)
             assert match, 'could not parse version string'
             up_ver = match.group(1)
 
-            # Copy patch series
-            origin = 'https://www.kernel.org/pub/linux/kernel/projects/rt/%s/patches-%s.tar.xz' % (up_ver, version)
-            with open(os.path.join(source_dir, 'series'), 'r') as \
-                    source_series_fh:
-                for line in source_series_fh:
-                    name = line.strip()
-                    if name != '' and name[0] != '#':
-                        with open(os.path.join(source_dir, name)) as source_patch:
-                            add_patch(name, source_patch, origin)
-                    else:
-                        # Leave comments and empty lines unchanged
-                        series_fh.write(line)
+            temp_dir = tempfile.mkdtemp(prefix='rt-genpatch', dir='debian')
+            try:
+                # Unpack tarball
+                subprocess.check_call(['tar', '-C', temp_dir, '-xaf', source])
+                source_dir = os.path.join(temp_dir, 'patches')
+                assert os.path.isdir(source_dir), 'tarball does not contain patches directory'
+
+                # Copy patch series
+                origin = 'https://www.kernel.org/pub/linux/kernel/projects/rt/%s/patches-%s.tar.xz' % (up_ver, version)
+                with open(os.path.join(source_dir, 'series'), 'r') as \
+                        source_series_fh:
+                    for line in source_series_fh:
+                        name = line.strip()
+                        if name != '' and name[0] != '#':
+                            with open(os.path.join(source_dir, name)) as source_patch:
+                                add_patch(name, source_patch, origin)
+                        else:
+                            # Leave comments and empty lines unchanged
+                            series_fh.write(line)
+            finally:
+                shutil.rmtree(temp_dir)
 
     for name in new_series:
         if name in old_series:
@@ -90,8 +104,9 @@ def main(source_dir, version):
         print('Obsoleted patch', os.path.join(patch_dir, name))
 
 if __name__ == '__main__':
-    if len(sys.argv) != 3:
-        print('Usage: %s DIR RT-VERSION' % sys.argv[0], file=sys.stderr)
-        print('DIR is either a git repo or quilt directory containing the given RT-VERSION.', file=sys.stderr)
+    if not (1 <= len(sys.argv) <= 2):
+        print('Usage: %s {TAR [RT-VERSION] | REPO RT-VERSION}' % sys.argv[0], file=sys.stderr)
+        print('TAR is a tarball of patches.', file=sys.stderr)
+        print('REPO is a git repo containing the given RT-VERSION.', file=sys.stderr)
         sys.exit(2)
-    main(sys.argv[1], sys.argv[2])
+    main(*sys.argv[1:])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list