2010-02-20 04:48:07 +00:00
|
|
|
#
|
2012-03-17 21:33:13 +00:00
|
|
|
# Copyright (C) 2006-2012 OpenWrt.org
|
2016-04-03 20:02:46 +00:00
|
|
|
# Copyright (C) 2016 LEDE project
|
2007-09-29 00:05:48 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2016-01-04 15:11:43 +00:00
|
|
|
OPENWRT_GIT = http://git.openwrt.org
|
2016-05-29 13:40:51 +00:00
|
|
|
LEDE_GIT = https://git.lede-project.org
|
2016-01-04 15:11:43 +00:00
|
|
|
|
2009-03-17 02:37:10 +00:00
|
|
|
DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED)
|
2007-09-29 00:05:48 +00:00
|
|
|
|
|
|
|
# Try to guess the download method from the URL
|
2010-02-20 04:48:07 +00:00
|
|
|
define dl_method
|
2007-09-29 00:05:48 +00:00
|
|
|
$(strip \
|
|
|
|
$(if $(2),$(2), \
|
2016-04-09 10:25:34 +00:00
|
|
|
$(if $(filter @APACHE/% @GITHUB/% @GNOME/% @GNU/% @KERNEL/% @SF/% @SAVANNAH/% ftp://% http://% https://% file://%,$(1)),default, \
|
2007-09-29 00:05:48 +00:00
|
|
|
$(if $(filter git://%,$(1)),git, \
|
|
|
|
$(if $(filter svn://%,$(1)),svn, \
|
2008-01-02 15:14:31 +00:00
|
|
|
$(if $(filter cvs://%,$(1)),cvs, \
|
2008-08-29 13:02:05 +00:00
|
|
|
$(if $(filter hg://%,$(1)),hg, \
|
2010-03-14 21:55:11 +00:00
|
|
|
$(if $(filter sftp://%,$(1)),bzr, \
|
|
|
|
unknown \
|
|
|
|
) \
|
2010-02-20 04:48:07 +00:00
|
|
|
) \
|
|
|
|
) \
|
2007-09-29 00:05:48 +00:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-10-24 12:36:44 +00:00
|
|
|
# code for creating tarballs from cvs/svn/git/bzr/hg/darcs checkouts - useful for mirror support
|
2016-12-12 10:42:14 +00:00
|
|
|
dl_pack/bz2=bzip2 -c > $(1)
|
|
|
|
dl_pack/gz=gzip -nc > $(1)
|
|
|
|
dl_pack/xz=xz -zc -7e > $(1)
|
2016-12-12 10:37:23 +00:00
|
|
|
dl_pack/unknown=$(error ERROR: Unknown pack format for file $(1))
|
2007-09-29 00:05:48 +00:00
|
|
|
define dl_pack
|
|
|
|
$(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown))
|
|
|
|
endef
|
2016-12-12 10:42:14 +00:00
|
|
|
define dl_tar_pack
|
2016-12-12 12:12:43 +00:00
|
|
|
$(TAR) --numeric-owner --owner=0 --group=0 --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | $(call dl_pack,$(1))
|
2016-12-12 10:42:14 +00:00
|
|
|
endef
|
2007-09-29 00:05:48 +00:00
|
|
|
|
|
|
|
define DownloadMethod/unknown
|
|
|
|
@echo "ERROR: No download method available"; false
|
|
|
|
endef
|
|
|
|
|
|
|
|
define DownloadMethod/default
|
2015-11-22 19:06:33 +00:00
|
|
|
$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" "$(URL_FILE)" $(foreach url,$(URL),"$(url)")
|
2007-09-29 00:05:48 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define wrap_mirror
|
2016-02-17 08:44:37 +00:00
|
|
|
$(if $(if $(MIRROR),$(filter-out x,$(MIRROR_MD5SUM))),$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" "" || ( $(1) ),$(1))
|
2007-09-29 00:05:48 +00:00
|
|
|
endef
|
|
|
|
|
2008-01-02 15:14:31 +00:00
|
|
|
define DownloadMethod/cvs
|
|
|
|
$(call wrap_mirror, \
|
|
|
|
echo "Checking out files from the cvs repository..."; \
|
2010-02-20 04:48:07 +00:00
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2010-03-14 21:55:11 +00:00
|
|
|
cvs -d $(URL) export $(VERSION) $(SUBDIR) && \
|
2010-02-20 04:48:07 +00:00
|
|
|
echo "Packing checkout..." && \
|
2016-12-12 10:42:14 +00:00
|
|
|
$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 21:55:11 +00:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2010-02-20 04:48:07 +00:00
|
|
|
)
|
2008-01-02 15:14:31 +00:00
|
|
|
endef
|
|
|
|
|
2007-09-29 00:05:48 +00:00
|
|
|
define DownloadMethod/svn
|
|
|
|
$(call wrap_mirror, \
|
2007-11-16 03:10:40 +00:00
|
|
|
echo "Checking out files from the svn repository..."; \
|
2007-09-29 00:05:48 +00:00
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2010-03-23 01:21:50 +00: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 00:05:48 +00:00
|
|
|
echo "Packing checkout..." && \
|
2016-10-04 16:33:55 +00:00
|
|
|
export TAR_TIMESTAMP="" && \
|
2016-12-12 10:42:14 +00:00
|
|
|
$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 21:55:11 +00:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2007-09-29 00:05:48 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2007-11-16 03:10:40 +00: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-11-09 17:34:17 +00:00
|
|
|
git clone $(OPTS) $(URL) $(SUBDIR) && \
|
2016-02-29 20:12:25 +00:00
|
|
|
(cd $(SUBDIR) && git checkout $(VERSION) && \
|
|
|
|
git submodule update --init --recursive) && \
|
2007-11-16 03:10:40 +00:00
|
|
|
echo "Packing checkout..." && \
|
2016-10-04 16:33:55 +00:00
|
|
|
export TAR_TIMESTAMP=`cd $(SUBDIR) && git log -1 --format='@%ct'` && \
|
2007-11-16 03:10:40 +00:00
|
|
|
rm -rf $(SUBDIR)/.git && \
|
2016-12-12 10:42:14 +00:00
|
|
|
$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 21:55:11 +00:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2007-11-16 03:10:40 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-02-20 04:48:07 +00: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) ] && \
|
2016-10-04 16:33:55 +00:00
|
|
|
bzr export --per-file-timestamps -r$(VERSION) $(SUBDIR) $(URL) && \
|
2010-02-20 04:48:07 +00:00
|
|
|
echo "Packing checkout..." && \
|
2016-10-04 16:33:55 +00:00
|
|
|
export TAR_TIMESTAMP="" && \
|
2016-12-12 10:42:14 +00:00
|
|
|
$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-29 13:06:19 +00:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
2010-03-14 21:55:11 +00:00
|
|
|
rm -rf $(SUBDIR); \
|
2010-02-20 04:48:07 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2008-08-29 13:02:05 +00: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) && \
|
2016-10-04 16:33:55 +00:00
|
|
|
export TAR_TIMESTAMP=`cd $(SUBDIR) && hg log --template '@{date}' -l 1` && \
|
2008-08-29 13:02:05 +00:00
|
|
|
find $(SUBDIR) -name .hg | xargs rm -rf && \
|
|
|
|
echo "Packing checkout..." && \
|
2016-12-12 10:42:14 +00:00
|
|
|
$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 21:55:11 +00:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2008-08-29 13:02:05 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-10-24 12:36:44 +00: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) && \
|
2016-10-04 16:33:55 +00:00
|
|
|
export TAR_TIMESTAMP=`cd $(SUBDIR) && LC_ALL=C darcs log --last 1 | sed -ne 's!^Date: \+!!p'` && \
|
2010-10-24 12:36:44 +00:00
|
|
|
find $(SUBDIR) -name _darcs | xargs rm -rf && \
|
|
|
|
echo "Packing checkout..." && \
|
2016-12-12 10:42:14 +00:00
|
|
|
$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-10-24 12:36:44 +00:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2008-01-02 15:14:31 +00:00
|
|
|
Validate/cvs=VERSION SUBDIR
|
2007-09-29 00:05:48 +00:00
|
|
|
Validate/svn=VERSION SUBDIR
|
2007-11-16 03:10:40 +00:00
|
|
|
Validate/git=VERSION SUBDIR
|
2010-02-20 04:48:07 +00:00
|
|
|
Validate/bzr=VERSION SUBDIR
|
2008-08-29 13:02:05 +00:00
|
|
|
Validate/hg=VERSION SUBDIR
|
2010-10-24 12:36:44 +00:00
|
|
|
Validate/darcs=VERSION SUBDIR
|
2007-09-29 00:05:48 +00:00
|
|
|
|
|
|
|
define Download/Defaults
|
|
|
|
URL:=
|
|
|
|
FILE:=
|
2015-11-22 19:06:33 +00:00
|
|
|
URL_FILE:=
|
2007-09-29 00:05:48 +00:00
|
|
|
PROTO:=
|
|
|
|
MD5SUM:=
|
|
|
|
SUBDIR:=
|
2008-07-31 02:43:33 +00:00
|
|
|
MIRROR:=1
|
2011-03-21 23:02:06 +00:00
|
|
|
MIRROR_MD5SUM:=x
|
2007-09-29 00:05:48 +00:00
|
|
|
VERSION:=
|
2016-11-09 17:34:17 +00:00
|
|
|
OPTS:=
|
2007-09-29 00:05:48 +00:00
|
|
|
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 02:37:10 +00:00
|
|
|
$(foreach dep,$(DOWNLOAD_RDEP),
|
|
|
|
$(dep): $(DL_DIR)/$(FILE)
|
|
|
|
)
|
2007-09-29 00:05:48 +00:00
|
|
|
download: $(DL_DIR)/$(FILE)
|
|
|
|
|
|
|
|
$(DL_DIR)/$(FILE):
|
|
|
|
mkdir -p $(DL_DIR)
|
2016-01-20 21:31:50 +00:00
|
|
|
$(call locked,$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown)),$(FILE))
|
2007-09-29 00:05:48 +00:00
|
|
|
|
|
|
|
endef
|