1 ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))
3 # unpacking files with +s may break on some platforms. this typically emits error code 2
4 ifneq ($(HOST_OS),Linux)
5 HOST_TAR:=trapret 2 $(TAR)
9 TAR_CMD:=$(HOST_TAR) -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS)
10 UNZIP_CMD:=unzip -d $(PKG_BUILD_DIR)/.. $(DL_DIR)/$(PKG_SOURCE)
15 ifeq ($(strip $(PKG_UNPACK)),)
16 ifeq ($(strip $(PKG_CAT)),)
17 # try to autodetect file type
18 EXT:=$(call ext,$(PKG_SOURCE))
21 ifeq ($(filter gz tgz,$(EXT)),$(EXT))
22 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
23 UNPACK:=$(ZCAT) $(DL_DIR)/$(PKG_SOURCE) |
25 ifeq ($(filter bzip2 bz2 bz tbz2 tbz,$(EXT)),$(EXT))
26 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
27 UNPACK:=bzcat $(DL_DIR)/$(PKG_SOURCE) |
29 ifeq ($(filter tgz tbz tbz2,$(EXT1)),$(EXT1))
30 $(error FOO: $(filter tgz tbz tbz2,$(EXT1)),$(EXT1))
33 UNPACK ?= cat $(DL_DIR)/$(PKG_SOURCE) |
35 PKG_UNPACK:=$(UNPACK) $(TAR_CMD)
38 PKG_UNPACK:=$(UNPACK) (cd $(PKG_BUILD_DIR)/..; cpio -i -d)
41 PKG_UNPACK:=$(UNZIP_CMD)
45 # compatibility code for packages that set PKG_CAT
46 ifeq ($(strip $(PKG_CAT)$(PKG_UNPACK)),)
47 # use existing PKG_CAT
48 PKG_UNPACK:=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
49 ifeq ($(PKG_CAT),unzip)
50 PKG_UNPACK:=$(UNZIP_CMD)
52 # replace zcat with $(ZCAT), because some system have it as gzcat
53 ifeq ($(PKG_CAT),zcat)
54 PKG_UNPACK:=$(ZCAT) $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
57 ifneq ($(strip $(CRLF_WORKAROUND)),)
58 PKG_UNPACK += && find $(PKG_BUILD_DIR) -type f -print0 | xargs -0 perl -pi -e 's!\r$$$$!!g'