dbh201
2022-09-17 200706459fd3b917770621b9b2b5e13d02601a20
userland-unpack: support decompression of non-archive files

1 files modified
13 ■■■■ changed files
tools/userland-unpack 13 ●●●● patch | view | raw | blame | history
tools/userland-unpack
@@ -59,9 +59,13 @@
        ruby_ver = os.getenv('RUBY_VERSION', '')
        uncompress = "/usr/ruby/" + ruby_ver + "/bin/gem unpack"
    unpack = " | gtar -xf -"
    # if the file is just compressed, redirect stdout to ./filename with
    # one less extension.
    unpack = " > ./" + '.'.join(os.path.basename(filename).split('.')[:-1])
    if (re.search("(\.zip)$", filename) != None):
    if (re.search("(\.tar\.[^\.]+|\.tgz|\.txz|\.tbz2?)$",filename) != None):
        unpack = " | gtar -xf -"
    elif (re.search("(\.zip)$", filename) != None):
        unpack = ""
    elif (re.search("(\.oxt)$", filename) != None):
        unpack = ""
@@ -71,7 +75,7 @@
        unpack = ""
    if (verbose == True):
        print("command: %s %s %s" % (uncompress, filename, unpack))
        print("command: %s %s%s" % (uncompress, filename, unpack))
    return uncompress, unpack
@@ -114,6 +118,9 @@
    permissions = None
    relocate_to = None
    if len(sys.argv) == 1:
        usage()
    try:
        opts, args = getopt.getopt(sys.argv[1:], "fr:v",
            ["fix-permissions", "relocate-to=", "verbose"])