]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/pkg-download.mk
package/xen: force location of init scripts
[coffee/buildroot.git] / package / pkg-download.mk
1 ################################################################################
2 #
3 # This file contains the download helpers for the various package
4 # infrastructures. It is used to handle downloads from HTTP servers,
5 # FTP servers, Git repositories, Subversion repositories, Mercurial
6 # repositories, Bazaar repositories, and SCP servers.
7 #
8 ################################################################################
9
10 # Download method commands
11 export WGET := $(call qstrip,$(BR2_WGET))
12 export SVN := $(call qstrip,$(BR2_SVN))
13 export CVS := $(call qstrip,$(BR2_CVS))
14 export BZR := $(call qstrip,$(BR2_BZR))
15 export GIT := $(call qstrip,$(BR2_GIT))
16 export HG := $(call qstrip,$(BR2_HG))
17 export SCP := $(call qstrip,$(BR2_SCP))
18 SSH := $(call qstrip,$(BR2_SSH))
19 export LOCALFILES := $(call qstrip,$(BR2_LOCALFILES))
20
21 DL_WRAPPER = support/download/dl-wrapper
22 FLOCK = flock $($(PKG)_DL_DIR)/
23
24 # DL_DIR may have been set already from the environment
25 ifeq ($(origin DL_DIR),undefined)
26 DL_DIR ?= $(call qstrip,$(BR2_DL_DIR))
27 ifeq ($(DL_DIR),)
28 DL_DIR := $(TOPDIR)/dl
29 endif
30 else
31 # Restore the BR2_DL_DIR that was overridden by the .config file
32 BR2_DL_DIR = $(DL_DIR)
33 endif
34
35 # ensure it exists and a absolute path
36 DL_DIR := $(shell mkdir -p $(DL_DIR) && cd $(DL_DIR) >/dev/null && pwd)
37
38 #
39 # URI scheme helper functions
40 # Example URIs:
41 # * http://www.example.com/dir/file
42 # * scp://www.example.com:dir/file (with domainseparator :)
43 #
44 # geturischeme: http
45 geturischeme = $(firstword $(subst ://, ,$(call qstrip,$(1))))
46 # getschemeplusuri: git|parameter+http://example.com
47 getschemeplusuri = $(call geturischeme,$(1))$(if $(2),\|$(2))+$(1)
48 # stripurischeme: www.example.com/dir/file
49 stripurischeme = $(lastword $(subst ://, ,$(call qstrip,$(1))))
50 # domain: www.example.com
51 domain = $(firstword $(subst $(call domainseparator,$(2)), ,$(call stripurischeme,$(1))))
52 # notdomain: dir/file
53 notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$(call stripurischeme,$(1)))
54 #
55 # default domainseparator is /, specify alternative value as first argument
56 domainseparator = $(if $(1),$(1),/)
57
58 # github(user,package,version): returns site of GitHub repository
59 github = https://github.com/$(1)/$(2)/archive/$(3)
60
61 # Expressly do not check hashes for those files
62 # Exported variables default to immediately expanded in some versions of
63 # make, but we need it to be recursively-epxanded, so explicitly assign it.
64 export BR_NO_CHECK_HASH_FOR =
65
66 ################################################################################
67 # DOWNLOAD -- Download helper. Will call DL_WRAPPER which will try to download
68 # source from:
69 # 1) BR2_PRIMARY_SITE if enabled
70 # 2) Download site, unless BR2_PRIMARY_SITE_ONLY is set
71 # 3) BR2_BACKUP_SITE if enabled, unless BR2_PRIMARY_SITE_ONLY is set
72 #
73 # Argument 1 is the source location
74 #
75 ################################################################################
76
77 ifneq ($(call qstrip,$(BR2_PRIMARY_SITE)),)
78 DOWNLOAD_URIS += \
79         -u $(call getschemeplusuri,$(call qstrip,$(BR2_PRIMARY_SITE)/$($(PKG)_DL_SUBDIR)),urlencode) \
80         -u $(call getschemeplusuri,$(call qstrip,$(BR2_PRIMARY_SITE)),urlencode)
81 endif
82
83 ifeq ($(BR2_PRIMARY_SITE_ONLY),)
84 DOWNLOAD_URIS += \
85         -u $(patsubst %/,%,$(dir $(call qstrip,$(1))))
86 ifneq ($(call qstrip,$(BR2_BACKUP_SITE)),)
87 DOWNLOAD_URIS += \
88         -u $(call getschemeplusuri,$(call qstrip,$(BR2_BACKUP_SITE)/$($(PKG)_DL_SUBDIR)),urlencode) \
89         -u $(call getschemeplusuri,$(call qstrip,$(BR2_BACKUP_SITE)),urlencode)
90 endif
91 endif
92
93 define DOWNLOAD
94         $(Q)mkdir -p $($(PKG)_DL_DIR)
95         $(EXTRA_ENV) $(FLOCK) $(DL_WRAPPER) \
96                 -c '$($(PKG)_DL_VERSION)' \
97                 -d '$($(PKG)_DL_DIR)' \
98                 -D '$(DL_DIR)' \
99                 -f '$(notdir $(1))' \
100                 -H '$(PKGDIR)/$($(PKG)_RAWNAME).hash' \
101                 -n '$($(PKG)_BASENAME_RAW)' \
102                 -N '$($(PKG)_RAWNAME)' \
103                 -o '$($(PKG)_DL_DIR)/$(notdir $(1))' \
104                 $(if $($(PKG)_GIT_SUBMODULES),-r) \
105                 $(DOWNLOAD_URIS) \
106                 $(QUIET) \
107                 -- \
108                 $($(PKG)_DL_OPTS)
109 endef