dbh201
2022-09-13 fab151b1b1e49134184362668e416310db9864c1
userland-unpack;prep-unpack.mk: fixes and improvements

userland-unpack now supports decompression of non-archive files.
prep-unpack.mk now allows SOURCE_DIR to be manually set.
3 files modified
23 ■■■■ changed files
make-rules/prep-unpack.mk 9 ●●●● patch | view | raw | blame | history
make-rules/shared-macros.mk 1 ●●●● patch | view | raw | blame | history
tools/userland-unpack 13 ●●●● patch | view | raw | blame | history
make-rules/prep-unpack.mk
@@ -36,8 +36,13 @@
ifdef COMPONENT_ARCHIVE$(1)
ifdef COMPONENT_SRC$(1)
CLEAN_PATHS += $$(COMPONENT_SRC$(1))
SOURCE_DIR$(1) = $$(COMPONENT_DIR)/$$(COMPONENT_SRC$(1))
# Set source dir if not overridden, then make it absolute.
SOURCE_DIR$(1) ?= $$(COMPONENT_SRC$(1))
SOURCE_DIR$(1) := $$(COMPONENT_DIR)/$$(SOURCE_DIR$(1))
# Clean is done from COMPONENT_DIR, so we can short the filenames.
CLEAN_PATHS += $$(shell basename $$(SOURCE_DIR$(1)))
UNPACK_STAMP$(1) =    $$(SOURCE_DIR$(1))/.unpacked
make-rules/shared-macros.mk
@@ -221,7 +221,6 @@
COMPONENT_LICENSE_FILE ?= $(COMPONENT_NAME).license
COMPONENT_DIR :=    $(shell pwd)
SOURCE_DIR =    $(COMPONENT_DIR)/$(COMPONENT_SRC)
BUILD_DIR =    $(COMPONENT_DIR)/build
PROTO_DIR =    $(BUILD_DIR)/prototype/$(MACH)
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"])