2 # Copyright (C) 2006-2010 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
/% ftp
://% http
://% 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
) cfj
$(1) $(2)
33 dl_pack
/gz
=$(TAR
) cfz
$(1) $(2)
34 dl_pack
/unknown
=echo
"ERROR: Unknown pack format for file $(1)"; false
36 $(if
$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/unknown
))
39 define DownloadMethod
/unknown
40 @echo
"ERROR: No download method available"; false
43 define DownloadMethod
/default
44 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(URL
)
48 $(if
$(MIRROR
),@
$(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "x" ||
( $(1) ),$(1))
51 define DownloadMethod
/cvs
53 echo
"Checking out files from the cvs repository..."; \
54 mkdir
-p
$(TMP_DIR
)/dl
&& \
57 [ \
! -d
$(SUBDIR
) ] && \
58 cvs
-d
$(URL
) export $(VERSION
) $(SUBDIR
) && \
59 echo
"Packing checkout..." && \
60 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
61 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
66 define DownloadMethod
/svn
68 echo
"Checking out files from the svn repository..."; \
69 mkdir
-p
$(TMP_DIR
)/dl
&& \
72 [ \
! -d
$(SUBDIR
) ] && \
73 ( svn help
export | grep
-q trust-server-cert
&& \
74 svn
export --non-interactive
--trust-server-cert
-r
$(VERSION
) $(URL
) $(SUBDIR
) || \
75 svn
export --non-interactive
-r
$(VERSION
) $(URL
) $(SUBDIR
) ) && \
76 echo
"Packing checkout..." && \
77 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
78 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
83 define DownloadMethod
/git
85 echo
"Checking out files from the git repository..."; \
86 mkdir
-p
$(TMP_DIR
)/dl
&& \
89 [ \
! -d
$(SUBDIR
) ] && \
90 git clone
$(URL
) $(SUBDIR
) && \
91 (cd
$(SUBDIR
) && git checkout
$(VERSION
)) && \
92 echo
"Packing checkout..." && \
93 rm -rf
$(SUBDIR
)/.git
&& \
94 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
95 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
100 define DownloadMethod
/bzr
101 $(call wrap_mirror
, \
102 echo
"Checking out files from the bzr repository..."; \
103 mkdir
-p
$(TMP_DIR
)/dl
&& \
104 cd
$(TMP_DIR
)/dl
&& \
105 rm -rf
$(SUBDIR
) && \
106 [ \
! -d
$(SUBDIR
) ] && \
107 bzr
export -r
$(VERSION
) $(SUBDIR
) $(URL
) && \
108 echo
"Packing checkout..." && \
109 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
110 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
115 define DownloadMethod
/hg
116 $(call wrap_mirror
, \
117 echo
"Checking out files from the hg repository..."; \
118 mkdir
-p
$(TMP_DIR
)/dl
&& \
119 cd
$(TMP_DIR
)/dl
&& \
120 rm -rf
$(SUBDIR
) && \
121 [ \
! -d
$(SUBDIR
) ] && \
122 hg clone
-r
$(VERSION
) $(URL
) $(SUBDIR
) && \
123 find
$(SUBDIR
) -name .hg | xargs
rm -rf
&& \
124 echo
"Packing checkout..." && \
125 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
126 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
131 define DownloadMethod
/darcs
132 $(call wrap_mirror
, \
133 echo
"Checking out files from the darcs repository..."; \
134 mkdir
-p
$(TMP_DIR
)/dl
&& \
135 cd
$(TMP_DIR
)/dl
&& \
136 rm -rf
$(SUBDIR
) && \
137 [ \
! -d
$(SUBDIR
) ] && \
138 darcs
get -t
$(VERSION
) $(URL
) $(SUBDIR
) && \
139 find
$(SUBDIR
) -name _darcs | xargs
rm -rf
&& \
140 echo
"Packing checkout..." && \
141 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
142 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
147 Validate
/cvs
=VERSION SUBDIR
148 Validate
/svn
=VERSION SUBDIR
149 Validate
/git
=VERSION SUBDIR
150 Validate
/bzr
=VERSION SUBDIR
151 Validate
/hg
=VERSION SUBDIR
152 Validate
/darcs
=VERSION SUBDIR
154 define Download
/Defaults
165 $(eval
$(Download
/Defaults
))
166 $(eval
$(Download
/$(1)))
167 $(foreach FIELD
,URL FILE
$(Validate
/$(call dl_method
,$(URL
),$(PROTO
))),
169 $$(error Download
/$(1) is missing the
$(FIELD
) field.
)
173 $(foreach dep
,$(DOWNLOAD_RDEP
),
174 $(dep
): $(DL_DIR
)/$(FILE
)
176 download
: $(DL_DIR
)/$(FILE
)
180 $(if
$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/unknown
))
This page took 0.048388 seconds and 5 git commands to generate.