2010-02-20 12:48:07 +08:00
|
|
|
#
|
2012-03-18 05:33:13 +08:00
|
|
|
# Copyright (C) 2006-2012 OpenWrt.org
|
2007-09-29 08:05:48 +08:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2009-03-17 10:37:10 +08:00
|
|
|
DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED)
|
2007-09-29 08:05:48 +08:00
|
|
|
|
|
|
|
# Try to guess the download method from the URL
|
2010-02-20 12:48:07 +08:00
|
|
|
define dl_method
|
2007-09-29 08:05:48 +08:00
|
|
|
$(strip \
|
|
|
|
$(if $(2),$(2), \
|
2010-12-19 05:43:10 +08:00
|
|
|
$(if $(filter @GNOME/% @GNU/% @KERNEL/% @SF/% ftp://% http://% https://% file://%,$(1)),default, \
|
2007-09-29 08:05:48 +08:00
|
|
|
$(if $(filter git://%,$(1)),git, \
|
|
|
|
$(if $(filter svn://%,$(1)),svn, \
|
2008-01-02 23:14:31 +08:00
|
|
|
$(if $(filter cvs://%,$(1)),cvs, \
|
2008-08-29 21:02:05 +08:00
|
|
|
$(if $(filter hg://%,$(1)),hg, \
|
2010-03-15 05:55:11 +08:00
|
|
|
$(if $(filter sftp://%,$(1)),bzr, \
|
|
|
|
unknown \
|
|
|
|
) \
|
2010-02-20 12:48:07 +08:00
|
|
|
) \
|
|
|
|
) \
|
2007-09-29 08:05:48 +08:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-10-24 20:36:44 +08:00
|
|
|
# code for creating tarballs from cvs/svn/git/bzr/hg/darcs checkouts - useful for mirror support
|
2012-12-03 02:35:47 +08:00
|
|
|
dl_pack/bz2=$(TAR) cjf $(1) $(2)
|
|
|
|
dl_pack/gz=$(TAR) czf $(1) $(2)
|
2007-09-29 08:05:48 +08:00
|
|
|
dl_pack/unknown=echo "ERROR: Unknown pack format for file $(1)"; false
|
|
|
|
define dl_pack
|
|
|
|
$(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define DownloadMethod/unknown
|
|
|
|
@echo "ERROR: No download method available"; false
|
|
|
|
endef
|
|
|
|
|
|
|
|
define DownloadMethod/default
|
2011-03-14 02:38:43 +08:00
|
|
|
$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(foreach url,$(URL),"$(url)")
|
2007-09-29 08:05:48 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define wrap_mirror
|
2012-06-06 21:45:53 +08:00
|
|
|
$(if $(if $(MIRROR),$(filter-out x,$(MIRROR_MD5SUM))),@$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" || ( $(1) ),$(1))
|
2007-09-29 08:05:48 +08:00
|
|
|
endef
|
|
|
|
|
2008-01-02 23:14:31 +08:00
|
|
|
define DownloadMethod/cvs
|
|
|
|
$(call wrap_mirror, \
|
|
|
|
echo "Checking out files from the cvs repository..."; \
|
2010-02-20 12:48:07 +08:00
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2010-03-15 05:55:11 +08:00
|
|
|
cvs -d $(URL) export $(VERSION) $(SUBDIR) && \
|
2010-02-20 12:48:07 +08:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-15 05:55:11 +08:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2010-02-20 12:48:07 +08:00
|
|
|
)
|
2008-01-02 23:14:31 +08:00
|
|
|
endef
|
|
|
|
|
2007-09-29 08:05:48 +08:00
|
|
|
define DownloadMethod/svn
|
|
|
|
$(call wrap_mirror, \
|
2007-11-16 11:10:40 +08:00
|
|
|
echo "Checking out files from the svn repository..."; \
|
2007-09-29 08:05:48 +08:00
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2010-03-23 09:21:50 +08:00
|
|
|
( svn help export | grep -q trust-server-cert && \
|
|
|
|
svn export --non-interactive --trust-server-cert -r$(VERSION) $(URL) $(SUBDIR) || \
|
|
|
|
svn export --non-interactive -r$(VERSION) $(URL) $(SUBDIR) ) && \
|
2007-09-29 08:05:48 +08:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-15 05:55:11 +08:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2007-09-29 08:05:48 +08:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2007-11-16 11:10:40 +08:00
|
|
|
define DownloadMethod/git
|
|
|
|
$(call wrap_mirror, \
|
|
|
|
echo "Checking out files from the git repository..."; \
|
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2012-03-18 05:33:13 +08:00
|
|
|
git clone $(URL) $(SUBDIR) --recursive && \
|
2008-08-24 21:40:21 +08:00
|
|
|
(cd $(SUBDIR) && git checkout $(VERSION)) && \
|
2007-11-16 11:10:40 +08:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
rm -rf $(SUBDIR)/.git && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-15 05:55:11 +08:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2007-11-16 11:10:40 +08:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-02-20 12:48:07 +08:00
|
|
|
define DownloadMethod/bzr
|
|
|
|
$(call wrap_mirror, \
|
|
|
|
echo "Checking out files from the bzr repository..."; \
|
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2010-03-29 21:06:19 +08:00
|
|
|
bzr export -r$(VERSION) $(SUBDIR) $(URL) && \
|
2010-02-20 12:48:07 +08:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-29 21:06:19 +08:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
2010-03-15 05:55:11 +08:00
|
|
|
rm -rf $(SUBDIR); \
|
2010-02-20 12:48:07 +08:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2008-08-29 21:02:05 +08:00
|
|
|
define DownloadMethod/hg
|
|
|
|
$(call wrap_mirror, \
|
|
|
|
echo "Checking out files from the hg repository..."; \
|
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
|
|
|
hg clone -r $(VERSION) $(URL) $(SUBDIR) && \
|
|
|
|
find $(SUBDIR) -name .hg | xargs rm -rf && \
|
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-15 05:55:11 +08:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2008-08-29 21:02:05 +08:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-10-24 20:36:44 +08:00
|
|
|
define DownloadMethod/darcs
|
|
|
|
$(call wrap_mirror, \
|
|
|
|
echo "Checking out files from the darcs repository..."; \
|
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
|
|
|
darcs get -t $(VERSION) $(URL) $(SUBDIR) && \
|
|
|
|
find $(SUBDIR) -name _darcs | xargs rm -rf && \
|
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2008-01-02 23:14:31 +08:00
|
|
|
Validate/cvs=VERSION SUBDIR
|
2007-09-29 08:05:48 +08:00
|
|
|
Validate/svn=VERSION SUBDIR
|
2007-11-16 11:10:40 +08:00
|
|
|
Validate/git=VERSION SUBDIR
|
2010-02-20 12:48:07 +08:00
|
|
|
Validate/bzr=VERSION SUBDIR
|
2008-08-29 21:02:05 +08:00
|
|
|
Validate/hg=VERSION SUBDIR
|
2010-10-24 20:36:44 +08:00
|
|
|
Validate/darcs=VERSION SUBDIR
|
2007-09-29 08:05:48 +08:00
|
|
|
|
|
|
|
define Download/Defaults
|
|
|
|
URL:=
|
|
|
|
FILE:=
|
|
|
|
PROTO:=
|
|
|
|
MD5SUM:=
|
|
|
|
SUBDIR:=
|
2008-07-31 10:43:33 +08:00
|
|
|
MIRROR:=1
|
2011-03-22 07:02:06 +08:00
|
|
|
MIRROR_MD5SUM:=x
|
2007-09-29 08:05:48 +08:00
|
|
|
VERSION:=
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Download
|
|
|
|
$(eval $(Download/Defaults))
|
|
|
|
$(eval $(Download/$(1)))
|
|
|
|
$(foreach FIELD,URL FILE $(Validate/$(call dl_method,$(URL),$(PROTO))),
|
|
|
|
ifeq ($($(FIELD)),)
|
|
|
|
$$(error Download/$(1) is missing the $(FIELD) field.)
|
|
|
|
endif
|
|
|
|
)
|
|
|
|
|
2009-03-17 10:37:10 +08:00
|
|
|
$(foreach dep,$(DOWNLOAD_RDEP),
|
|
|
|
$(dep): $(DL_DIR)/$(FILE)
|
|
|
|
)
|
2007-09-29 08:05:48 +08:00
|
|
|
download: $(DL_DIR)/$(FILE)
|
|
|
|
|
|
|
|
$(DL_DIR)/$(FILE):
|
|
|
|
mkdir -p $(DL_DIR)
|
|
|
|
$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown))
|
|
|
|
|
|
|
|
endef
|