Re: [ketchup] patch to allow for moving of .gitignore in 2.6.14

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

 



On Sun, 30 Oct 2005, David Weinehall wrote:
>
> Uhm, this patch assumes that you're using bash as /bin/sh.
> Not everyone does.  (I haven't checked the rest of the system calls
> in ketchup though, maybe this is a more generic problem?)

OK, if I work any more on ketchup, I'm going to convert the whole damn
thing into perl! ;-} (and call it "mustard").

Is this patch better? It even tests the version of tar and if it is less
than 1.15 it uses --strip-path (the old name) and if it is 1.15 or greater
it uses --strip-components (the new name).  And if it fails the version
test all together, it goes back to the old (broken) method of just moving
the contents.

Is this robust enough for you?

-- Steve

Index: Ketchup-d9503020b3c1/ketchup
===================================================================
--- Ketchup-d9503020b3c1.orig/ketchup	2005-10-29 17:02:26.000000000 -0400
+++ Ketchup-d9503020b3c1/ketchup	2005-10-29 23:41:32.000000000 -0400
@@ -477,16 +477,37 @@
     qprint("Unpacking %s" % os.path.basename(file))
     if options["dry-run"]: return ver

-    err = os.system("tar xjf %s" % file)
-    if err:
+    f = os.popen('tar --version', 'r')
+    if not f:
         error("Unpacking failed: ", err)
         sys.exit(-1)

-    err = os.system("mv linux*/* . ; rmdir linux*")
+    strip = ""
+    line = f.readline()
+    while line:
+        m = re.match(r'.*?(\d+)\.(\d+)', line)
+        if m:
+            v1 = int(m.group(1))
+            v2 = int(m.group(2))
+            if v1 > 1 or (v1 == 1 and v2 >= 15):
+                strip = "--strip-components 1 "
+            else:
+                strip = "--strip-path 1 "
+	    break
+        line = f.readline()
+    f.close()
+
+    err = os.system("tar %s-xjf %s" % (strip, file))
     if err:
         error("Unpacking failed: ", err)
         sys.exit(-1)

+    if not len(strip):
+        err = os.system("mv linux*/* . ; rmdir linux*")
+        if err:
+            error("Unpacking failed: ", err)
+            sys.exit(-1)
+
     return ver

 def find_ver(ver):
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux