feeds.conf.default: remove freifunk feed
[openwrt/openwrt.git] / include / unpack.mk
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2006-2020 OpenWrt.org
4
5 HOST_TAR:=$(TAR)
6 TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS)
7 UNZIP_CMD=unzip -q -d $(1)/.. $(DL_DIR)/$(PKG_SOURCE)
8
9 ifeq ($(PKG_SOURCE),)
10 PKG_UNPACK ?= true
11 else
12
13 ifeq ($(strip $(UNPACK_CMD)),)
14 ifeq ($(strip $(PKG_CAT)),)
15 # try to autodetect file type
16 EXT:=$(call ext,$(PKG_SOURCE))
17 EXT1:=$(EXT)
18
19 ifeq ($(filter gz tgz,$(EXT)),$(EXT))
20 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
21 DECOMPRESS_CMD:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) |
22 endif
23 ifeq ($(filter bzip2 bz2 bz tbz2 tbz,$(EXT)),$(EXT))
24 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
25 DECOMPRESS_CMD:=bzcat $(DL_DIR)/$(PKG_SOURCE) |
26 endif
27 ifeq ($(filter xz txz,$(EXT)),$(EXT))
28 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
29 DECOMPRESS_CMD:=xzcat $(DL_DIR)/$(PKG_SOURCE) |
30 endif
31 ifeq (zst,$(EXT))
32 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
33 DECOMPRESS_CMD:=zstdcat $(DL_DIR)/$(PKG_SOURCE) |
34 endif
35 ifeq ($(filter tgz tbz tbz2 txz,$(EXT1)),$(EXT1))
36 EXT:=tar
37 endif
38 DECOMPRESS_CMD ?= cat $(DL_DIR)/$(PKG_SOURCE) |
39 ifeq ($(EXT),tar)
40 UNPACK_CMD=$(DECOMPRESS_CMD) $(TAR_CMD)
41 endif
42 ifeq ($(EXT),cpio)
43 UNPACK_CMD=$(DECOMPRESS_CMD) (cd $(1)/..; $(STAGING_DIR_HOST)/bin/cpio -i -d)
44 endif
45 ifeq ($(EXT),zip)
46 UNPACK_CMD=$(UNZIP_CMD)
47 endif
48 endif
49
50 # compatibility code for packages that set PKG_CAT
51 ifeq ($(strip $(UNPACK_CMD)),)
52 # use existing PKG_CAT
53 UNPACK_CMD=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
54 ifeq ($(PKG_CAT),unzip)
55 UNPACK_CMD=$(UNZIP_CMD)
56 endif
57 # replace zcat with $(ZCAT), because some system don't support it properly
58 ifeq ($(PKG_CAT),zcat)
59 UNPACK_CMD=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
60 endif
61 endif
62 endif
63
64 ifdef PKG_BUILD_DIR
65 PKG_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(PKG_BUILD_DIR))
66 endif
67 ifdef HOST_BUILD_DIR
68 HOST_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(HOST_BUILD_DIR))
69 endif
70
71 endif # PKG_SOURCE
72