2010-02-20 12:48:07 +08:00
|
|
|
#
|
2012-03-18 05:33:13 +08:00
|
|
|
# Copyright (C) 2006-2012 OpenWrt.org
|
2016-04-04 04:02:46 +08:00
|
|
|
# Copyright (C) 2016 LEDE project
|
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.
|
|
|
|
#
|
|
|
|
|
2016-01-04 23:11:43 +08:00
|
|
|
OPENWRT_GIT = http://git.openwrt.org
|
2016-04-27 07:33:14 +08:00
|
|
|
LEDE_GIT = http://git.lede-project.org
|
2016-01-04 23:11:43 +08:00
|
|
|
|
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), \
|
2016-04-09 18:25:34 +08:00
|
|
|
$(if $(filter @APACHE/% @GITHUB/% @GNOME/% @GNU/% @KERNEL/% @SF/% @SAVANNAH/% 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)
|
2014-04-10 22:43:26 +08:00
|
|
|
dl_pack/xz=$(TAR) c $(2) | xz -zc > $(1)
|
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
|
2015-11-23 03:06:33 +08:00
|
|
|
$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" "$(URL_FILE)" $(foreach url,$(URL),"$(url)")
|
2007-09-29 08:05:48 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define wrap_mirror
|
2016-02-17 16:44:37 +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) ] && \
|
2016-03-01 04:12:25 +08:00
|
|
|
git clone $(URL) $(SUBDIR) && \
|
|
|
|
(cd $(SUBDIR) && git checkout $(VERSION) && \
|
|
|
|
git submodule update --init --recursive) && \
|
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:=
|
2015-11-23 03:06:33 +08:00
|
|
|
URL_FILE:=
|
2007-09-29 08:05:48 +08:00
|
|
|
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)
|
2016-01-21 05:31:50 +08:00
|
|
|
$(call locked,$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown)),$(FILE))
|
2007-09-29 08:05:48 +08:00
|
|
|
|
|
|
|
endef
|