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 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 SVN_VERSION
=$(shell svn
--version | head
-1 | awk
'{ print $3 }' | cut
-d.
-f2
)
67 ifeq ($(SVN_VERSION
),5)
69 SVN_OPTS
:=--trust-server-cert
72 define DownloadMethod
/svn
74 echo
"Checking out files from the svn repository..."; \
75 mkdir
-p
$(TMP_DIR
)/dl
&& \
78 [ \
! -d
$(SUBDIR
) ] && \
79 svn
export --non-interactive
$(SVN_OPTS
) -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 echo
"Packing checkout..." && \
97 rm -rf
$(SUBDIR
)/.git
&& \
98 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
99 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
104 define DownloadMethod
/bzr
105 $(call wrap_mirror
, \
106 echo
"Checking out files from the bzr repository..."; \
107 mkdir
-p
$(TMP_DIR
)/dl
&& \
108 cd
$(TMP_DIR
)/dl
&& \
109 rm -rf
$(SUBDIR
) && \
110 [ \
! -d
$(SUBDIR
) ] && \
111 bzr
export -r
$(VERSION
) $(URL
) $(SUBDIR
) && \
112 echo
"Packing checkout..." && \
113 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
114 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ &&
119 define DownloadMethod
/hg
120 $(call wrap_mirror
, \
121 echo
"Checking out files from the hg repository..."; \
122 mkdir
-p
$(TMP_DIR
)/dl
&& \
123 cd
$(TMP_DIR
)/dl
&& \
124 rm -rf
$(SUBDIR
) && \
125 [ \
! -d
$(SUBDIR
) ] && \
126 hg clone
-r
$(VERSION
) $(URL
) $(SUBDIR
) && \
127 find
$(SUBDIR
) -name .hg | xargs
rm -rf
&& \
128 echo
"Packing checkout..." && \
129 $(call dl_pack
,$(TMP_DIR
)/dl
/$(FILE
),$(SUBDIR
)) && \
130 mv
$(TMP_DIR
)/dl
/$(FILE
) $(DL_DIR
)/ && \
135 Validate
/cvs
=VERSION SUBDIR
136 Validate
/svn
=VERSION SUBDIR
137 Validate
/git
=VERSION SUBDIR
138 Validate
/bzr
=VERSION SUBDIR
139 Validate
/hg
=VERSION SUBDIR
141 define Download
/Defaults
152 $(eval
$(Download
/Defaults
))
153 $(eval
$(Download
/$(1)))
154 $(foreach FIELD
,URL FILE
$(Validate
/$(call dl_method
,$(URL
),$(PROTO
))),
156 $$(error Download
/$(1) is missing the
$(FIELD
) field.
)
160 $(foreach dep
,$(DOWNLOAD_RDEP
),
161 $(dep
): $(DL_DIR
)/$(FILE
)
163 download
: $(DL_DIR
)/$(FILE
)
167 $(if
$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/$(call dl_method
,$(URL
),$(PROTO
))),$(DownloadMethod
/unknown
))
This page took 0.049564 seconds and 5 git commands to generate.