1 ################################################################################
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.
8 ################################################################################
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
))
21 DL_WRAPPER
= support
/download
/dl-wrapper
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
))
27 DL_DIR
:= $(TOPDIR
)/dl
30 # Restore the BR2_DL_DIR that was overridden by the .config file
31 BR2_DL_DIR
= $(DL_DIR
)
34 # ensure it exists and a absolute path
35 DL_DIR
:= $(shell mkdir
-p
$(DL_DIR
) && cd
$(DL_DIR
) >/dev
/null
&& pwd
)
38 # URI scheme helper functions
40 # * http://www.example.com/dir/file
41 # * scp://www.example.com:dir/file (with domainseparator :)
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))))
50 notdomain
= $(patsubst $(call domain
,$(1),$(2))$(call domainseparator
,$(2))%,%,$(call stripurischeme
,$(1)))
52 # default domainseparator is /, specify alternative value as first argument
53 domainseparator
= $(if
$(1),$(1),/)
55 # github(user,package,version): returns site of GitHub repository
56 github
= https
://github.com
/$(1)/$(2)/archive
/$(3)
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
=
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
71 # The SOURCE_CHECK_* helpers are in charge of simply checking that the source
72 # is available for download. This can be used to make sure one will be able
73 # to get all the sources needed for one's build configuration.
74 ################################################################################
77 $(EXTRA_ENV
) $(DL_WRAPPER
) -b git \
78 -o
$(DL_DIR
)/$($(PKG
)_SOURCE
) \
79 $(if
$($(PKG
)_GIT_SUBMODULES
),-r
) \
83 $($(PKG
)_DL_VERSION
) \
84 $($(PKG
)_RAW_BASE_NAME
) \
88 # TODO: improve to check that the given PKG_DL_VERSION exists on the remote
90 define SOURCE_CHECK_GIT
91 $(GIT
) ls-remote
--heads
$($(PKG
)_SITE
) > /dev
/null
95 $(EXTRA_ENV
) $(DL_WRAPPER
) -b bzr \
96 -o
$(DL_DIR
)/$($(PKG
)_SOURCE
) \
100 $($(PKG
)_DL_VERSION
) \
101 $($(PKG
)_RAW_BASE_NAME
) \
105 define SOURCE_CHECK_BZR
106 $(BZR
) ls
--quiet
$($(PKG
)_SITE
) > /dev
/null
110 $(EXTRA_ENV
) $(DL_WRAPPER
) -b cvs \
111 -o
$(DL_DIR
)/$($(PKG
)_SOURCE
) \
114 $(call stripurischeme
,$(call qstrip
,$($(PKG
)_SITE
))) \
115 $($(PKG
)_DL_VERSION
) \
117 $($(PKG
)_RAW_BASE_NAME
) \
121 # Not all CVS servers support ls/rls, use login to see if we can connect
122 define SOURCE_CHECK_CVS
123 $(CVS
) -d
:pserver
:anonymous
:@
$(call stripurischeme
,$(call qstrip
,$($(PKG
)_SITE
))) login
127 $(EXTRA_ENV
) $(DL_WRAPPER
) -b svn \
128 -o
$(DL_DIR
)/$($(PKG
)_SOURCE
) \
132 $($(PKG
)_DL_VERSION
) \
133 $($(PKG
)_RAW_BASE_NAME
) \
137 define SOURCE_CHECK_SVN
138 $(SVN
) ls
$($(PKG
)_SITE
)@
$($(PKG
)_DL_VERSION
) > /dev
/null
141 # SCP URIs should be of the form scp://[user@]host:filepath
142 # Note that filepath is relative to the user's home directory, so you may want
143 # to prepend the path with a slash: scp://[user@]host:/absolutepath
145 $(EXTRA_ENV
) $(DL_WRAPPER
) -b scp \
147 -H
$(PKGDIR
)/$($(PKG
)_RAWNAME
).hash \
150 '$(call stripurischeme,$(call qstrip,$(1)))' \
154 define SOURCE_CHECK_SCP
155 $(SSH
) $(call domain
,$(1),:) ls
'$(call notdomain,$(1),:)' > /dev
/null
159 $(EXTRA_ENV
) $(DL_WRAPPER
) -b hg \
160 -o
$(DL_DIR
)/$($(PKG
)_SOURCE
) \
164 $($(PKG
)_DL_VERSION
) \
165 $($(PKG
)_RAW_BASE_NAME
) \
169 # TODO: improve to check that the given PKG_DL_VERSION exists on the remote
171 define SOURCE_CHECK_HG
172 $(HG
) incoming
--force -l1
$($(PKG
)_SITE
) > /dev
/null
176 $(EXTRA_ENV
) $(DL_WRAPPER
) -b wget \
178 -H
$(PKGDIR
)/$($(PKG
)_RAWNAME
).hash \
181 '$(call qstrip,$(1))' \
185 define SOURCE_CHECK_WGET
186 $(WGET
) --spider
'$(call qstrip,$(1))'
189 define DOWNLOAD_LOCALFILES
190 $(EXTRA_ENV
) $(DL_WRAPPER
) -b cp \
192 -H
$(PKGDIR
)/$($(PKG
)_RAWNAME
).hash \
195 $(call stripurischeme
,$(call qstrip
,$(1))) \
199 define SOURCE_CHECK_LOCALFILES
200 test -e
$(call stripurischeme
,$(call qstrip
,$(1)))
203 ################################################################################
204 # DOWNLOAD -- Download helper. Will try to download source from:
205 # 1) BR2_PRIMARY_SITE if enabled
206 # 2) Download site, unless BR2_PRIMARY_SITE_ONLY is set
207 # 3) BR2_BACKUP_SITE if enabled, unless BR2_PRIMARY_SITE_ONLY is set
209 # Argument 1 is the source location
211 # E.G. use like this:
212 # $(call DOWNLOAD,$(FOO_SITE))
213 ################################################################################
216 $(call DOWNLOAD_INNER
,$(1),$(notdir $(1)),DOWNLOAD
)
220 $(call DOWNLOAD_INNER
,$(1),$(notdir $(1)),SOURCE_CHECK
)
223 define DOWNLOAD_INNER
224 $(Q
)$(if
$(filter bzr cvs git hg svn
,$($(PKG
)_SITE_METHOD
)),export BR_NO_CHECK_HASH_FOR
=$(2);) \
225 if
test -n
"$(call qstrip,$(BR2_PRIMARY_SITE))" ; then \
226 case
"$(call geturischeme,$(BR2_PRIMARY_SITE))" in \
227 file
) $(call
$(3)_LOCALFILES
,$(BR2_PRIMARY_SITE
)/$(2),$(2)) && exit
;; \
228 scp
) $(call
$(3)_SCP
,$(BR2_PRIMARY_SITE
)/$(2),$(2)) && exit
;; \
229 *) $(call
$(3)_WGET
,$(BR2_PRIMARY_SITE
)/$(2),$(2)) && exit
;; \
232 if
test "$(BR2_PRIMARY_SITE_ONLY)" = "y" ; then \
235 if
test -n
"$(1)" ; then \
236 case
"$($(PKG)_SITE_METHOD)" in \
237 git
) $($(3)_GIT
) && exit
;; \
238 svn
) $($(3)_SVN
) && exit
;; \
239 cvs
) $($(3)_CVS
) && exit
;; \
240 bzr
) $($(3)_BZR
) && exit
;; \
241 file
) $($(3)_LOCALFILES
) && exit
;; \
242 scp
) $($(3)_SCP
) && exit
;; \
243 hg
) $($(3)_HG
) && exit
;; \
244 *) $(call
$(3)_WGET
,$(1),$(2)) && exit
;; \
247 if
test -n
"$(call qstrip,$(BR2_BACKUP_SITE))" ; then \
248 $(call
$(3)_WGET
,$(BR2_BACKUP_SITE
)/$(2),$(2)) && exit
; \