]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/pkg-download.mk
pkg-{download, generic}: remove source-check
[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
23 # DL_DIR may have been set already from the environment
24 ifeq ($(origin DL_DIR),undefined)
25 DL_DIR ?= $(call qstrip,$(BR2_DL_DIR))
26 ifeq ($(DL_DIR),)
27 DL_DIR := $(TOPDIR)/dl
28 endif
29 else
30 # Restore the BR2_DL_DIR that was overridden by the .config file
31 BR2_DL_DIR = $(DL_DIR)
32 endif
33
34 # ensure it exists and a absolute path
35 DL_DIR := $(shell mkdir -p $(DL_DIR) && cd $(DL_DIR) >/dev/null && pwd)
36
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
44 geturischeme = $(firstword $(subst ://, ,$(call qstrip,$(1))))
45 # stripurischeme: www.example.com/dir/file
46 stripurischeme = $(lastword $(subst ://, ,$(call qstrip,$(1))))
47 # domain: www.example.com
48 domain = $(firstword $(subst $(call domainseparator,$(2)), ,$(call stripurischeme,$(1))))
49 # notdomain: dir/file
50 notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$(call stripurischeme,$(1)))
51 #
52 # default domainseparator is /, specify alternative value as first argument
53 domainseparator = $(if $(1),$(1),/)
54
55 # github(user,package,version): returns site of GitHub repository
56 github = https://github.com/$(1)/$(2)/archive/$(3)
57
58 # Expressly do not check hashes for those files
59 # Exported variables default to immediately expanded in some versions of
60 # make, but we need it to be recursively-epxanded, so explicitly assign it.
61 export BR_NO_CHECK_HASH_FOR =
62
63 ################################################################################
64 # The DOWNLOAD_* helpers are in charge of getting a working copy
65 # of the source repository for their corresponding SCM,
66 # checking out the requested version / commit / tag, and create an
67 # archive out of it. DOWNLOAD_SCP uses scp to obtain a remote file with
68 # ssh authentication. DOWNLOAD_WGET is the normal wget-based download
69 # mechanism.
70 #
71 ################################################################################
72
73 define DOWNLOAD_GIT
74         $(EXTRA_ENV) $(DL_WRAPPER) -b git \
75                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
76                 $(if $($(PKG)_GIT_SUBMODULES),-r) \
77                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
78                 $(QUIET) \
79                 -- \
80                 $($(PKG)_SITE) \
81                 $($(PKG)_DL_VERSION) \
82                 $($(PKG)_RAW_BASE_NAME) \
83                 $($(PKG)_DL_OPTS)
84 endef
85
86 define DOWNLOAD_BZR
87         $(EXTRA_ENV) $(DL_WRAPPER) -b bzr \
88                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
89                 $(QUIET) \
90                 -- \
91                 $($(PKG)_SITE) \
92                 $($(PKG)_DL_VERSION) \
93                 $($(PKG)_RAW_BASE_NAME) \
94                 $($(PKG)_DL_OPTS)
95 endef
96
97 define DOWNLOAD_CVS
98         $(EXTRA_ENV) $(DL_WRAPPER) -b cvs \
99                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
100                 $(QUIET) \
101                 -- \
102                 $(call stripurischeme,$(call qstrip,$($(PKG)_SITE))) \
103                 $($(PKG)_DL_VERSION) \
104                 $($(PKG)_RAWNAME) \
105                 $($(PKG)_RAW_BASE_NAME) \
106                 $($(PKG)_DL_OPTS)
107 endef
108
109 define DOWNLOAD_SVN
110         $(EXTRA_ENV) $(DL_WRAPPER) -b svn \
111                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
112                 $(QUIET) \
113                 -- \
114                 $($(PKG)_SITE) \
115                 $($(PKG)_DL_VERSION) \
116                 $($(PKG)_RAW_BASE_NAME) \
117                 $($(PKG)_DL_OPTS)
118 endef
119
120 # SCP URIs should be of the form scp://[user@]host:filepath
121 # Note that filepath is relative to the user's home directory, so you may want
122 # to prepend the path with a slash: scp://[user@]host:/absolutepath
123 define DOWNLOAD_SCP
124         $(EXTRA_ENV) $(DL_WRAPPER) -b scp \
125                 -o $(DL_DIR)/$(2) \
126                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
127                 $(QUIET) \
128                 -- \
129                 '$(call stripurischeme,$(call qstrip,$(1)))' \
130                 $($(PKG)_DL_OPTS)
131 endef
132
133 define DOWNLOAD_HG
134         $(EXTRA_ENV) $(DL_WRAPPER) -b hg \
135                 -o $(DL_DIR)/$($(PKG)_SOURCE) \
136                 $(QUIET) \
137                 -- \
138                 $($(PKG)_SITE) \
139                 $($(PKG)_DL_VERSION) \
140                 $($(PKG)_RAW_BASE_NAME) \
141                 $($(PKG)_DL_OPTS)
142 endef
143
144 define DOWNLOAD_WGET
145         $(EXTRA_ENV) $(DL_WRAPPER) -b wget \
146                 -o $(DL_DIR)/$(2) \
147                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
148                 $(QUIET) \
149                 -- \
150                 '$(call qstrip,$(1))' \
151                 $($(PKG)_DL_OPTS)
152 endef
153
154 define DOWNLOAD_LOCALFILES
155         $(EXTRA_ENV) $(DL_WRAPPER) -b cp \
156                 -o $(DL_DIR)/$(2) \
157                 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
158                 $(QUIET) \
159                 -- \
160                 $(call stripurischeme,$(call qstrip,$(1))) \
161                 $($(PKG)_DL_OPTS)
162 endef
163
164 ################################################################################
165 # DOWNLOAD -- Download helper. Will try to download source from:
166 # 1) BR2_PRIMARY_SITE if enabled
167 # 2) Download site, unless BR2_PRIMARY_SITE_ONLY is set
168 # 3) BR2_BACKUP_SITE if enabled, unless BR2_PRIMARY_SITE_ONLY is set
169 #
170 # Argument 1 is the source location
171 #
172 # E.G. use like this:
173 # $(call DOWNLOAD,$(FOO_SITE))
174 #
175 # For PRIMARY and BACKUP site, any ? in the URL is replaced by %3F. A ? in
176 # the URL is used to separate query arguments, but the PRIMARY and BACKUP
177 # sites serve just plain files.
178 ################################################################################
179
180 define DOWNLOAD
181         $(call DOWNLOAD_INNER,$(1),$(notdir $(1)),DOWNLOAD)
182 endef
183
184 define DOWNLOAD_INNER
185         $(Q)$(if $(filter bzr cvs hg svn,$($(PKG)_SITE_METHOD)),export BR_NO_CHECK_HASH_FOR=$(2);) \
186         if test -n "$(call qstrip,$(BR2_PRIMARY_SITE))" ; then \
187                 case "$(call geturischeme,$(BR2_PRIMARY_SITE))" in \
188                         file) $(call $(3)_LOCALFILES,$(BR2_PRIMARY_SITE)/$(2),$(2)) && exit ;; \
189                         scp) $(call $(3)_SCP,$(BR2_PRIMARY_SITE)/$(2),$(2)) && exit ;; \
190                         *) $(call $(3)_WGET,$(BR2_PRIMARY_SITE)/$(subst ?,%3F,$(2)),$(2)) && exit ;; \
191                 esac ; \
192         fi ; \
193         if test "$(BR2_PRIMARY_SITE_ONLY)" = "y" ; then \
194                 exit 1 ; \
195         fi ; \
196         if test -n "$(1)" ; then \
197                 case "$($(PKG)_SITE_METHOD)" in \
198                         git) $($(3)_GIT) && exit ;; \
199                         svn) $($(3)_SVN) && exit ;; \
200                         cvs) $($(3)_CVS) && exit ;; \
201                         bzr) $($(3)_BZR) && exit ;; \
202                         file) $($(3)_LOCALFILES) && exit ;; \
203                         scp) $($(3)_SCP) && exit ;; \
204                         hg) $($(3)_HG) && exit ;; \
205                         *) $(call $(3)_WGET,$(1),$(2)) && exit ;; \
206                 esac ; \
207         fi ; \
208         if test -n "$(call qstrip,$(BR2_BACKUP_SITE))" ; then \
209                 $(call $(3)_WGET,$(BR2_BACKUP_SITE)/$(subst ?,%3F,$(2)),$(2)) && exit ; \
210         fi ; \
211         exit 1
212 endef