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 @GNOME
/% @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
, \
18 $(if
$(filter hg
://%,$(1)),hg
, \
29 # code for creating tarballs from cvs/svn/git/hg checkouts - useful for mirror support
30 dl_pack
/bz2
=$(TAR
) cfj
$(1) $(2)
31 dl_pack
/gz
=$(TAR
) cfz
$(1) $(2)
32 dl_pack
/unknown
=echo
"ERROR: Unknown pack format for file $(1)"; false
34 $(if
$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/$(call ext
,$(1))),$(dl_pack
/unknown
))
37 define DownloadMethod
/unknown
38 @echo
"ERROR: No download method available"; false
41 define DownloadMethod
/default
42 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(URL
)
46 $(if
$(MIRROR
),@
$(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(FILE)" "x" ||
( $(1) ),$(1))
49 define DownloadMethod
/cvs
51 echo
"Checking out files from the cvs repository..."; \
52 mkdir
-p
$(TMP_DIR
)/dl
&& \
55 [ \
! -d
$(SUBDIR
) ] && \
56 cvs
-d
$(URL
) co -r
$(VERSION
) $(SUBDIR
) && \
57 find
$(SUBDIR
) -name CVS | xargs
rm -rf
&& \
58 echo
"Packing checkout..." && \
59 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
60 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/; \
65 define DownloadMethod
/svn
67 echo
"Checking out files from the svn repository..."; \
68 mkdir
-p
$(TMP_DIR
)/dl
&& \
71 [ \
! -d
$(SUBDIR
) ] && \
72 svn
co --non-interactive
-r
$(VERSION
) $(URL
) $(SUBDIR
) && \
73 find
$(SUBDIR
) -name .svn | xargs
rm -rf
&& \
74 echo
"Packing checkout..." && \
75 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
76 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/; \
80 define DownloadMethod
/git
82 echo
"Checking out files from the git repository..."; \
83 mkdir
-p
$(TMP_DIR
)/dl
&& \
86 [ \
! -d
$(SUBDIR
) ] && \
87 git clone
$(URL
) $(SUBDIR
) && \
88 (cd
$(SUBDIR
) && git checkout
$(VERSION
)) && \
89 echo
"Packing checkout..." && \
90 rm -rf
$(SUBDIR
)/.git
&& \
91 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
92 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/; \
96 define DownloadMethod
/hg
98 echo
"Checking out files from the hg repository..."; \
99 mkdir
-p
$(TMP_DIR
)/dl
&& \
100 cd
$(TMP_DIR
)/dl
&& \
101 rm -rf
$(SUBDIR
) && \
102 [ \
! -d
$(SUBDIR
) ] && \
103 hg clone
-r
$(VERSION
) $(URL
) $(SUBDIR
) && \
104 find
$(SUBDIR
) -name .hg | xargs
rm -rf
&& \
105 echo
"Packing checkout..." && \
106 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
107 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/; \
111 Validate
/cvs
=VERSION SUBDIR
112 Validate
/svn
=VERSION SUBDIR
113 Validate
/git
=VERSION SUBDIR
114 Validate
/hg
=VERSION SUBDIR
116 define Download
/Defaults
127 $(eval
$(Download
/Defaults
))
128 $(eval
$(Download
/$(1)))
129 $(foreach FIELD
,URL FILE
$(Validate
/$(call dl_method
,$(URL
),$(PROTO
))),
131 $$(error Download
/$(1) is missing the
$(FIELD
) field.
)
135 $(if
$(DOWNLOAD_RDEP
),$(DOWNLOAD_RDEP
): $(DL_DIR
)/$(FILE
))
136 download
: $(DL_DIR
)/$(FILE
)
140 $(if
$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/unknown
))