2 # Copyright (C) 2006-2012 OpenWrt.org
3 # Copyright (C) 2016 LEDE project
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 OPENWRT_GIT
= http
://git.openwrt.org
11 DOWNLOAD_RDEP
=$(STAMP_PREPARED
) $(HOST_STAMP_PREPARED
)
13 # Try to guess the download method from the URL
17 $(if
$(filter @APACHE
/% @GITHUB
/% @GNOME
/% @GNU
/% @KERNEL
/% @SF
/% @SAVANNAH
/% ftp
://% http
://% https
://% file
://%,$(1)),default
, \
18 $(if
$(filter git
://%,$(1)),git
, \
19 $(if
$(filter svn
://%,$(1)),svn
, \
20 $(if
$(filter cvs
://%,$(1)),cvs
, \
21 $(if
$(filter hg
://%,$(1)),hg
, \
22 $(if
$(filter sftp
://%,$(1)),bzr
, \
34 # code for creating tarballs from cvs/svn/git/bzr/hg/darcs checkouts - useful for mirror support
35 dl_pack
/bz2
=$(TAR
) cjf
$(1) $(2)
36 dl_pack
/gz
=$(TAR
) czf
$(1) $(2)
37 dl_pack
/xz
=$(TAR
) c
$(2) | xz
-zc
> $(1)
38 dl_pack
/unknown
=echo
"ERROR: Unknown pack format for file $(1)"; false
40 $(if
$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/unknown
))
43 define DownloadMethod
/unknown
44 @echo
"ERROR: No download method available"; false
47 define DownloadMethod
/default
48 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "$(MD5SUM)" "$(URL_FILE)" $(foreach url
,$(URL
),"$(url)")
52 $(if
$(if
$(MIRROR
),$(filter-out x
,$(MIRROR_MD5SUM
))),$(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" "" ||
( $(1) ),$(1))
55 define DownloadMethod
/cvs
57 echo
"Checking out files from the cvs repository..."; \
58 mkdir
-p
$(TMP_DIR
)/dl
&& \
61 [ \
! -d
$(SUBDIR
) ] && \
62 cvs
-d
$(URL
) export $(VERSION
) $(SUBDIR
) && \
63 echo
"Packing checkout..." && \
64 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
65 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
70 define DownloadMethod
/svn
72 echo
"Checking out files from the svn repository..."; \
73 mkdir
-p
$(TMP_DIR
)/dl
&& \
76 [ \
! -d
$(SUBDIR
) ] && \
77 ( svn help
export | grep
-q trust-server-cert
&& \
78 svn
export --non-interactive
--trust-server-cert
-r
$(VERSION
) $(URL
) $(SUBDIR
) || \
79 svn
export --non-interactive
-r
$(VERSION
) $(URL
) $(SUBDIR
) ) && \
80 echo
"Packing checkout..." && \
81 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
82 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
87 define DownloadMethod
/git
89 echo
"Checking out files from the git repository..."; \
90 mkdir
-p
$(TMP_DIR
)/dl
&& \
93 [ \
! -d
$(SUBDIR
) ] && \
94 git clone
$(URL
) $(SUBDIR
) && \
95 (cd
$(SUBDIR
) && git checkout
$(VERSION
) && \
96 git submodule update
--init
--recursive
) && \
97 echo
"Packing checkout..." && \
98 rm -rf
$(SUBDIR
)/.git
&& \
99 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
100 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
105 define DownloadMethod
/bzr
106 $(call wrap_mirror
, \
107 echo
"Checking out files from the bzr repository..."; \
108 mkdir
-p
$(TMP_DIR
)/dl
&& \
109 cd
$(TMP_DIR
)/dl
&& \
110 rm -rf
$(SUBDIR
) && \
111 [ \
! -d
$(SUBDIR
) ] && \
112 bzr
export -r
$(VERSION
) $(SUBDIR
) $(URL
) && \
113 echo
"Packing checkout..." && \
114 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
115 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
120 define DownloadMethod
/hg
121 $(call wrap_mirror
, \
122 echo
"Checking out files from the hg repository..."; \
123 mkdir
-p
$(TMP_DIR
)/dl
&& \
124 cd
$(TMP_DIR
)/dl
&& \
125 rm -rf
$(SUBDIR
) && \
126 [ \
! -d
$(SUBDIR
) ] && \
127 hg clone
-r
$(VERSION
) $(URL
) $(SUBDIR
) && \
128 find
$(SUBDIR
) -name .hg | xargs
rm -rf
&& \
129 echo
"Packing checkout..." && \
130 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
131 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
136 define DownloadMethod
/darcs
137 $(call wrap_mirror
, \
138 echo
"Checking out files from the darcs repository..."; \
139 mkdir
-p
$(TMP_DIR
)/dl
&& \
140 cd
$(TMP_DIR
)/dl
&& \
141 rm -rf
$(SUBDIR
) && \
142 [ \
! -d
$(SUBDIR
) ] && \
143 darcs
get -t
$(VERSION
) $(URL
) $(SUBDIR
) && \
144 find
$(SUBDIR
) -name _darcs | xargs
rm -rf
&& \
145 echo
"Packing checkout..." && \
146 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
147 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
152 Validate
/cvs
=VERSION SUBDIR
153 Validate
/svn
=VERSION SUBDIR
154 Validate
/git
=VERSION SUBDIR
155 Validate
/bzr
=VERSION SUBDIR
156 Validate
/hg
=VERSION SUBDIR
157 Validate
/darcs
=VERSION SUBDIR
159 define Download
/Defaults
172 $(eval
$(Download
/Defaults
))
173 $(eval
$(Download
/$(1)))
174 $(foreach FIELD
,URL FILE
$(Validate
/$(call dl_method
,$(URL
),$(PROTO
))),
176 $$(error Download
/$(1) is missing the
$(FIELD
) field.
)
180 $(foreach dep
,$(DOWNLOAD_RDEP
),
181 $(dep
): $(DL_DIR
)/$(FILE
)
183 download
: $(DL_DIR
)/$(FILE
)
187 $(call locked
,$(if
$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/unknown
)),$(FILE
))