update ar7 sangam tarball
[openwrt.git] / include / unpack.mk
1 #
2 # Copyright (C) 2006-2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 # unpacking files with +s may break on some platforms. this typically emits error code 2
9 ifneq ($(HOST_OS),Linux)
10 HOST_TAR:=trapret 2 $(TAR)
11 else
12 HOST_TAR:=$(TAR)
13 endif
14 TAR_CMD:=$(HOST_TAR) -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS)
15 UNZIP_CMD:=unzip -d $(PKG_BUILD_DIR)/.. $(DL_DIR)/$(PKG_SOURCE)
16
17 ifeq ($(PKG_SOURCE),)
18 PKG_UNPACK ?= true
19 endif
20 ifeq ($(strip $(PKG_UNPACK)),)
21 ifeq ($(strip $(PKG_CAT)),)
22 # try to autodetect file type
23 EXT:=$(call ext,$(PKG_SOURCE))
24 EXT1:=$(EXT)
25
26 ifeq ($(filter gz tgz,$(EXT)),$(EXT))
27 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
28 UNPACK:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) |
29 endif
30 ifeq ($(filter bzip2 bz2 bz tbz2 tbz,$(EXT)),$(EXT))
31 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
32 UNPACK:=bzcat $(DL_DIR)/$(PKG_SOURCE) |
33 endif
34 ifeq ($(filter tgz tbz tbz2,$(EXT1)),$(EXT1))
35 EXT:=tar
36 endif
37 UNPACK ?= cat $(DL_DIR)/$(PKG_SOURCE) |
38 ifeq ($(EXT),tar)
39 PKG_UNPACK:=$(UNPACK) $(TAR_CMD)
40 endif
41 ifeq ($(EXT),cpio)
42 PKG_UNPACK:=$(UNPACK) (cd $(PKG_BUILD_DIR)/..; cpio -i -d)
43 endif
44 ifeq ($(EXT),zip)
45 PKG_UNPACK:=$(UNZIP_CMD)
46 endif
47 endif
48
49 # compatibility code for packages that set PKG_CAT
50 ifeq ($(strip $(PKG_UNPACK)),)
51 # use existing PKG_CAT
52 PKG_UNPACK:=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
53 ifeq ($(PKG_CAT),unzip)
54 PKG_UNPACK:=$(UNZIP_CMD)
55 endif
56 # replace zcat with $(ZCAT), because some system don't support it properly
57 ifeq ($(PKG_CAT),zcat)
58 PKG_UNPACK:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
59 endif
60 endif
61 ifneq ($(strip $(CRLF_WORKAROUND)),)
62 PKG_UNPACK += && find $(PKG_BUILD_DIR) -type f -print0 | xargs -0 perl -pi -e 's!\r$$$$!!g'
63 endif
64 endif
This page took 0.053856 seconds and 5 git commands to generate.