2 # Copyright (C) 2007 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
)
10 # Try to guess the download method from the URL
14 $(if
$(filter @GNU
/% @KERNEL
/% @SF
/% ftp
://% http
://%,$(1)),default
, \
15 $(if
$(filter git
://%,$(1)),git
, \
16 $(if
$(filter svn
://%,$(1)),svn
, \
17 $(if
$(filter cvs
://%,$(1)),cvs
, \
27 # code for creating tarballs from cvs/svn/git checkouts - useful for mirror support
28 dl_pack
/bz2
=$(TAR
) cfj
$(1) $(2)
29 dl_pack
/gz
=$(TAR
) cfz
$(1) $(2)
30 dl_pack
/unknown
=echo
"ERROR: Unknown pack format for file $(1)"; false
32 $(if
$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/unknown
))
35 define DownloadMethod
/unknown
36 @echo
"ERROR: No download method available"; false
39 define DownloadMethod
/default
40 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(URL
)
44 @
$(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "x" ||
( $(1) )
47 define DownloadMethod
/cvs
49 echo
"Checking out files from the cvs repository..."; \
50 mkdir
-p
$(TMP_DIR
)/dl
&& \
53 [ \
! -d
$(SUBDIR
) ] && \
54 cvs
co -r
$(VERSION
) $(URL
) $(SUBDIR
) && \
55 find
$(SUBDIR
) -name CVS | xargs
rm -rf
&& \
56 echo
"Packing checkout..." && \
57 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
58 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/; \
63 define DownloadMethod
/svn
65 echo
"Checking out files from the svn repository..."; \
66 mkdir
-p
$(TMP_DIR
)/dl
&& \
69 [ \
! -d
$(SUBDIR
) ] && \
70 svn
co --non-interactive
-r
$(VERSION
) $(URL
) $(SUBDIR
) && \
71 find
$(SUBDIR
) -name .svn | xargs
rm -rf
&& \
72 echo
"Packing checkout..." && \
73 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
74 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/; \
78 define DownloadMethod
/git
80 echo
"Checking out files from the git repository..."; \
81 mkdir
-p
$(TMP_DIR
)/dl
&& \
84 [ \
! -d
$(SUBDIR
) ] && \
85 git-clone
$(URL
) $(SUBDIR
) && \
86 (cd
$(SUBDIR
) && git-checkout
$(VERSION
)) && \
87 echo
"Packing checkout..." && \
88 rm -rf
$(SUBDIR
)/.git
&& \
89 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
90 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/; \
94 Validate
/cvs
=VERSION SUBDIR
95 Validate
/svn
=VERSION SUBDIR
96 Validate
/git
=VERSION SUBDIR
98 define Download
/Defaults
108 $(eval
$(Download
/Defaults
))
109 $(eval
$(Download
/$(1)))
110 $(foreach FIELD
,URL FILE
$(Validate
/$(call dl_method
,$(URL
),$(PROTO
))),
112 $$(error Download
/$(1) is missing the
$(FIELD
) field.
)
116 $(if
$(DOWNLOAD_RDEP
),$(DOWNLOAD_RDEP
): $(DL_DIR
)/$(FILE
))
117 download
: $(DL_DIR
)/$(FILE
)
121 $(if
$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/unknown
))
This page took 0.058124 seconds and 5 git commands to generate.