[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] linux-tools: Add xz support



This patch supports xz-compressed upstream (vanilla) tarball source
to generate an xz-compressed linux-tools orig-tarball.

Furthermore, patches are now allowed in xz-format, too.

As suggested by Ben I have replaced all occurences of tar with "-a"
option for compressing/decompressing tarballs.

>From man tar(1):

     -a, --auto-compress
                use archive suffix to determine the compression program

After applying this patch, follow these instructions (here: Linux-v3.5):

  $ cd linux-tools/
  $ make -f debian/rules debian/control-real
  $ ./debian/bin/genorig.py /path/to/linux-3.5.tar.xz
  $ fakeroot debian/rules orig
  $ debuild

Tested against linux-tools SVN trunk revision 19348.

Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
---
 debian/bin/genorig.py |   18 ++++++++----------
 debian/rules          |    4 ++--
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/debian/bin/genorig.py b/debian/bin/genorig.py
index 30a2e75..2465209 100755
--- a/debian/bin/genorig.py
+++ b/debian/bin/genorig.py
@@ -66,7 +66,7 @@ class Main(object):
         self.log('Using source name %s, version %s, dfsg %s\n' % (source, version.upstream, self.version_dfsg))
 
         self.orig = '%s-%s' % (source, version.upstream)
-        self.orig_tar = '%s_%s.orig.tar.gz' % (source, version.upstream)
+        self.orig_tar = '%s_%s.orig.tar.xz' % (source, version.upstream)
         self.tag = 'v' + re.sub(r"^(\d+\.\d+)\.0", r"\1",
                                 version.upstream.replace('~', '-'))
 
@@ -92,7 +92,7 @@ class Main(object):
                                          '--prefix=temp/', self.tag],
                                         cwd=input_repo,
                                         stdout=subprocess.PIPE)
-        extract_proc = subprocess.Popen(['tar', '-xf', '-'], cwd=self.dir,
+        extract_proc = subprocess.Popen(['tar', '-xaf', '-'], cwd=self.dir,
                                         stdin=archive_proc.stdout)
 
         ret1 = archive_proc.wait()
@@ -102,15 +102,11 @@ class Main(object):
 
     def upstream_extract(self, input_tar):
         self.log("Extracting tarball %s\n" % input_tar)
-        match = re.match(r'(^|.*/)(?P<dir>linux-\d+\.\d+(\.\d+)?(-\S+)?)\.tar(\.(?P<extension>(bz2|gz)))?$', input_tar)
+        match = re.match(r'(^|.*/)(?P<dir>linux-\d+\.\d+(\.\d+)?(-\S+)?)\.tar(\.(?P<extension>(bz2|gz|xz)))?$', input_tar)
         if not match:
             raise RuntimeError("Can't identify name of tarball")
 
-        cmdline = ['tar', '-xf', input_tar, '-C', self.dir]
-        if match.group('extension') == 'bz2':
-            cmdline.append('-j')
-        elif match.group('extension') == 'gz':
-            cmdline.append('-z')
+        cmdline = ['tar', '-xaf', input_tar, '-C', self.dir]
 
         if subprocess.Popen(cmdline).wait():
             raise RuntimeError("Can't extract tarball")
@@ -119,7 +115,7 @@ class Main(object):
 
     def upstream_patch(self, input_patch):
         self.log("Patching source with %s\n" % input_patch)
-        match = re.match(r'(^|.*/)patch-\d+\.\d+\.\d+(-\S+?)?(\.(?P<extension>(bz2|gz)))?$', input_patch)
+        match = re.match(r'(^|.*/)patch-\d+\.\d+\.\d+(-\S+?)?(\.(?P<extension>(bz2|gz|xz)))?$', input_patch)
         if not match:
             raise RuntimeError("Can't identify name of patch")
         cmdline = []
@@ -127,6 +123,8 @@ class Main(object):
             cmdline.append('bzcat')
         elif match.group('extension') == 'gz':
             cmdline.append('zcat')
+        elif match.group('extension') == 'xz':
+            cmdline.append('xzcat')
         else:
             cmdline.append('cat')
         cmdline.append(input_patch)
@@ -177,7 +175,7 @@ class Main(object):
         except OSError:
             pass
         self.log("Generate tarball %s\n" % out)
-        cmdline = ['tar -czf', out, '-C', self.dir, self.orig]
+        cmdline = ['tar -caf', out, '-C', self.dir, self.orig]
         try:
             if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
                 raise RuntimeError("Can't patch source")
diff --git a/debian/rules b/debian/rules
index 28304f7..3a21ac5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -20,7 +20,7 @@ $(STAMPS_DIR):
 	@[ -d $@ ] || mkdir $@
 
 DIR_ORIG = ../orig/$(SOURCE)-$(VERSION)
-TAR_ORIG_NAME = $(SOURCE)_$(VERSION).orig.tar.gz
+TAR_ORIG_NAME = $(SOURCE)_$(VERSION).orig.tar.xz
 TAR_ORIG = $(firstword $(wildcard ../$(TAR_ORIG_NAME)) $(wildcard ../orig/$(TAR_ORIG_NAME)))
 
 orig: $(DIR_ORIG)
@@ -31,7 +31,7 @@ ifeq ($(TAR_ORIG),)
 	$(error Cannot find orig tarball $(TAR_ORIG_NAME))
 else
 	mkdir -p ../orig
-	tar -C ../orig -xzf $(TAR_ORIG)
+	tar -C ../orig -xaf $(TAR_ORIG)
 endif
 
 maintainerclean:
-- 
1.7.10.4


Reply to: