]>
Commit | Line | Data |
---|---|---|
8dfd59d1 | 1 | ################################################################################ |
c0e6b524 TP |
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 | # | |
8dfd59d1 | 8 | ################################################################################ |
c0e6b524 | 9 | |
6e6b99a5 | 10 | # Download method commands |
4dc54da0 | 11 | export WGET := $(call qstrip,$(BR2_WGET)) |
daf034f8 | 12 | export SVN := $(call qstrip,$(BR2_SVN)) |
f4526c05 | 13 | export CVS := $(call qstrip,$(BR2_CVS)) |
45261f1f | 14 | export BZR := $(call qstrip,$(BR2_BZR)) |
95a57228 | 15 | export GIT := $(call qstrip,$(BR2_GIT)) |
4dc54da0 YM |
16 | export HG := $(call qstrip,$(BR2_HG)) |
17 | export SCP := $(call qstrip,$(BR2_SCP)) | |
18 | SSH := $(call qstrip,$(BR2_SSH)) | |
283b8b7f | 19 | export LOCALFILES := $(call qstrip,$(BR2_LOCALFILES)) |
6e6b99a5 | 20 | |
78b92e50 YM |
21 | DL_WRAPPER = support/download/dl-wrapper |
22 | ||
6768021c | 23 | # DL_DIR may have been set already from the environment |
af97c94b | 24 | ifeq ($(origin DL_DIR),undefined) |
6768021c | 25 | DL_DIR ?= $(call qstrip,$(BR2_DL_DIR)) |
6e6b99a5 | 26 | ifeq ($(DL_DIR),) |
e0d9d33c | 27 | DL_DIR := $(TOPDIR)/dl |
6e6b99a5 | 28 | endif |
af97c94b AV |
29 | else |
30 | # Restore the BR2_DL_DIR that was overridden by the .config file | |
31 | BR2_DL_DIR = $(DL_DIR) | |
32 | endif | |
6e6b99a5 | 33 | |
a77ee7fd | 34 | # ensure it exists and a absolute path |
e0d9d33c | 35 | DL_DIR := $(shell mkdir -p $(DL_DIR) && cd $(DL_DIR) >/dev/null && pwd) |
a77ee7fd | 36 | |
6e6b99a5 TP |
37 | # |
38 | # URI scheme helper functions | |
39 | # Example URIs: | |
40 | # * http://www.example.com/dir/file | |
41 | # * scp://www.example.com:dir/file (with domainseparator :) | |
42 | # | |
43 | # geturischeme: http | |
f268f713 | 44 | geturischeme = $(firstword $(subst ://, ,$(call qstrip,$(1)))) |
c8ef0c03 MH |
45 | # getschemeplusuri: git|parameter+http://example.com |
46 | getschemeplusuri = $(call geturischeme,$(1))$(if $(2),\|$(2))+$(1) | |
6e6b99a5 | 47 | # stripurischeme: www.example.com/dir/file |
f268f713 | 48 | stripurischeme = $(lastword $(subst ://, ,$(call qstrip,$(1)))) |
6e6b99a5 | 49 | # domain: www.example.com |
f268f713 | 50 | domain = $(firstword $(subst $(call domainseparator,$(2)), ,$(call stripurischeme,$(1)))) |
6e6b99a5 | 51 | # notdomain: dir/file |
f268f713 | 52 | notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$(call stripurischeme,$(1))) |
6e6b99a5 TP |
53 | # |
54 | # default domainseparator is /, specify alternative value as first argument | |
f268f713 | 55 | domainseparator = $(if $(1),$(1),/) |
6e6b99a5 | 56 | |
2114c29e YM |
57 | # github(user,package,version): returns site of GitHub repository |
58 | github = https://github.com/$(1)/$(2)/archive/$(3) | |
bb083e95 | 59 | |
8d2f4e62 | 60 | # Expressly do not check hashes for those files |
9fa6209f YM |
61 | # Exported variables default to immediately expanded in some versions of |
62 | # make, but we need it to be recursively-epxanded, so explicitly assign it. | |
63 | export BR_NO_CHECK_HASH_FOR = | |
8d2f4e62 | 64 | |
6e6b99a5 | 65 | ################################################################################ |
c8ef0c03 MH |
66 | # DOWNLOAD -- Download helper. Will call DL_WRAPPER which will try to download |
67 | # source from: | |
68 | # 1) BR2_PRIMARY_SITE if enabled | |
69 | # 2) Download site, unless BR2_PRIMARY_SITE_ONLY is set | |
70 | # 3) BR2_BACKUP_SITE if enabled, unless BR2_PRIMARY_SITE_ONLY is set | |
71 | # | |
72 | # Argument 1 is the source location | |
6e6b99a5 | 73 | # |
6e6b99a5 TP |
74 | ################################################################################ |
75 | ||
c8ef0c03 MH |
76 | ifneq ($(call qstrip,$(BR2_PRIMARY_SITE)),) |
77 | DOWNLOAD_URIS += \ | |
78 | -u $(call getschemeplusuri,$(BR2_PRIMARY_SITE),urlencode) | |
79 | endif | |
6e6b99a5 | 80 | |
c8ef0c03 MH |
81 | ifeq ($(BR2_PRIMARY_SITE_ONLY),) |
82 | DOWNLOAD_URIS += \ | |
83 | -u $($(PKG)_SITE_METHOD)+$(dir $(1)) | |
84 | ifneq ($(call qstrip,$(BR2_BACKUP_SITE)),) | |
85 | DOWNLOAD_URIS += \ | |
86 | -u $(call getschemeplusuri,$(BR2_BACKUP_SITE),urlencode) | |
87 | endif | |
88 | endif | |
15eb1faf | 89 | |
c8ef0c03 MH |
90 | define DOWNLOAD |
91 | $(Q)$(if $(filter bzr cvs hg svn,$($(PKG)_SITE_METHOD)),BR_NO_CHECK_HASH_FOR=$(notdir $(1))) \ | |
92 | $(EXTRA_ENV) $(DL_WRAPPER) \ | |
91e776b5 | 93 | -c $($(PKG)_DL_VERSION) \ |
c8ef0c03 | 94 | -f $(notdir $(1)) \ |
9b88c604 | 95 | -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \ |
91e776b5 | 96 | -n $($(PKG)_BASENAME_RAW) \ |
c8ef0c03 MH |
97 | -N $($(PKG)_RAWNAME) \ |
98 | -o $(DL_DIR)/$(notdir $(1)) \ | |
99 | $(if $($(PKG)_GIT_SUBMODULES),-r) \ | |
100 | $(DOWNLOAD_URIS) \ | |
0b600227 | 101 | $(QUIET) \ |
78b92e50 | 102 | -- \ |
91b34e0a | 103 | $($(PKG)_DL_OPTS) |
6e6b99a5 | 104 | endef |