2 # Copyright (C) 2006-2012 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 DOWNLOAD_RDEP
=$(STAMP_PREPARED
) $(HOST_STAMP_PREPARED
)
10 # Try to guess the download method from the URL
14 $(if
$(filter @GNOME
/% @GNU
/% @KERNEL
/% @SF
/% @SAVANNAH
/% ftp
://% http
://% https
://% file
://%,$(1)),default
, \
15 $(if
$(filter git
://%,$(1)),git
, \
16 $(if
$(filter svn
://%,$(1)),svn
, \
17 $(if
$(filter cvs
://%,$(1)),cvs
, \
18 $(if
$(filter hg
://%,$(1)),hg
, \
19 $(if
$(filter sftp
://%,$(1)),bzr
, \
31 # code for creating tarballs from cvs/svn/git/bzr/hg/darcs checkouts - useful for mirror support
32 dl_pack
/bz2
=$(TAR
) cjf
$(1) $(2)
33 dl_pack
/gz
=$(TAR
) czf
$(1) $(2)
34 dl_pack
/xz
=$(TAR
) c
$(2) | xz
-zc
> $(1)
35 dl_pack
/unknown
=echo
"ERROR: Unknown pack format for file $(1)"; false
37 $(if
$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/unknown
))
40 define DownloadMethod
/unknown
41 @echo
"ERROR: No download method available"; false
44 define DownloadMethod
/default
45 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(foreach url
,$(URL
),"$(url)")
49 $(if
$(if
$(MIRROR
),$(filter-out x
,$(MIRROR_MD5SUM
))),@
$(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" ||
( $(1) ),$(1))
52 define DownloadMethod
/cvs
54 echo
"Checking out files from the cvs repository..."; \
55 mkdir
-p
$(TMP_DIR
)/dl
&& \
58 [ \
! -d
$(SUBDIR
) ] && \
59 cvs
-d
$(URL
) export $(VERSION
) $(SUBDIR
) && \
60 echo
"Packing checkout..." && \
61 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
62 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
67 define DownloadMethod
/svn
69 echo
"Checking out files from the svn repository..."; \
70 mkdir
-p
$(TMP_DIR
)/dl
&& \
73 [ \
! -d
$(SUBDIR
) ] && \
74 ( svn help
export | grep
-q trust-server-cert
&& \
75 svn
export --non-interactive
--trust-server-cert
-r
$(VERSION
) $(URL
) $(SUBDIR
) || \
76 svn
export --non-interactive
-r
$(VERSION
) $(URL
) $(SUBDIR
) ) && \
77 echo
"Packing checkout..." && \
78 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
79 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
84 define DownloadMethod
/git
86 echo
"Checking out files from the git repository..."; \
87 mkdir
-p
$(TMP_DIR
)/dl
&& \
90 [ \
! -d
$(SUBDIR
) ] && \
91 git clone
$(URL
) $(SUBDIR
) --recursive
&& \
92 (cd
$(SUBDIR
) && git checkout
$(VERSION
) && git submodule update
) && \
93 echo
"Packing checkout..." && \
94 rm -rf
$(SUBDIR
)/.git
&& \
95 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
96 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
101 define DownloadMethod
/bzr
102 $(call wrap_mirror
, \
103 echo
"Checking out files from the bzr repository..."; \
104 mkdir
-p
$(TMP_DIR
)/dl
&& \
105 cd
$(TMP_DIR
)/dl
&& \
106 rm -rf
$(SUBDIR
) && \
107 [ \
! -d
$(SUBDIR
) ] && \
108 bzr
export -r
$(VERSION
) $(SUBDIR
) $(URL
) && \
109 echo
"Packing checkout..." && \
110 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
111 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
116 define DownloadMethod
/hg
117 $(call wrap_mirror
, \
118 echo
"Checking out files from the hg repository..."; \
119 mkdir
-p
$(TMP_DIR
)/dl
&& \
120 cd
$(TMP_DIR
)/dl
&& \
121 rm -rf
$(SUBDIR
) && \
122 [ \
! -d
$(SUBDIR
) ] && \
123 hg clone
-r
$(VERSION
) $(URL
) $(SUBDIR
) && \
124 find
$(SUBDIR
) -name .hg | xargs
rm -rf
&& \
125 echo
"Packing checkout..." && \
126 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
127 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
132 define DownloadMethod
/darcs
133 $(call wrap_mirror
, \
134 echo
"Checking out files from the darcs repository..."; \
135 mkdir
-p
$(TMP_DIR
)/dl
&& \
136 cd
$(TMP_DIR
)/dl
&& \
137 rm -rf
$(SUBDIR
) && \
138 [ \
! -d
$(SUBDIR
) ] && \
139 darcs
get -t
$(VERSION
) $(URL
) $(SUBDIR
) && \
140 find
$(SUBDIR
) -name _darcs | xargs
rm -rf
&& \
141 echo
"Packing checkout..." && \
142 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
143 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
148 Validate
/cvs
=VERSION SUBDIR
149 Validate
/svn
=VERSION SUBDIR
150 Validate
/git
=VERSION SUBDIR
151 Validate
/bzr
=VERSION SUBDIR
152 Validate
/hg
=VERSION SUBDIR
153 Validate
/darcs
=VERSION SUBDIR
155 define Download
/Defaults
167 $(eval
$(Download
/Defaults
))
168 $(eval
$(Download
/$(1)))
169 $(foreach FIELD
,URL FILE
$(Validate
/$(call dl_method
,$(URL
),$(PROTO
))),
171 $$(error Download
/$(1) is missing the
$(FIELD
) field.
)
175 $(foreach dep
,$(DOWNLOAD_RDEP
),
176 $(dep
): $(DL_DIR
)/$(FILE
)
178 download
: $(DL_DIR
)/$(FILE
)
182 $(if
$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/unknown
))