2010-02-20 06:48:07 +02:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006-2010 OpenWrt.org
|
2007-09-29 03:05:48 +03:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2009-03-17 04:37:10 +02:00
|
|
|
DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED)
|
2007-09-29 03:05:48 +03:00
|
|
|
|
|
|
|
# Try to guess the download method from the URL
|
2010-02-20 06:48:07 +02:00
|
|
|
define dl_method
|
2007-09-29 03:05:48 +03:00
|
|
|
$(strip \
|
|
|
|
$(if $(2),$(2), \
|
2010-01-13 21:38:53 +02:00
|
|
|
$(if $(filter @GNOME/% @GNU/% @KERNEL/% @SF/% ftp://% http://% file://%,$(1)),default, \
|
2007-09-29 03:05:48 +03:00
|
|
|
$(if $(filter git://%,$(1)),git, \
|
|
|
|
$(if $(filter svn://%,$(1)),svn, \
|
2008-01-02 17:14:31 +02:00
|
|
|
$(if $(filter cvs://%,$(1)),cvs, \
|
2008-08-29 16:02:05 +03:00
|
|
|
$(if $(filter hg://%,$(1)),hg, \
|
2010-03-14 23:55:11 +02:00
|
|
|
$(if $(filter sftp://%,$(1)),bzr, \
|
|
|
|
unknown \
|
|
|
|
) \
|
2010-02-20 06:48:07 +02:00
|
|
|
) \
|
|
|
|
) \
|
2007-09-29 03:05:48 +03:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-02-20 06:48:07 +02:00
|
|
|
# code for creating tarballs from cvs/svn/git/bzr/hg checkouts - useful for mirror support
|
2007-09-29 03:16:33 +03:00
|
|
|
dl_pack/bz2=$(TAR) cfj $(1) $(2)
|
|
|
|
dl_pack/gz=$(TAR) cfz $(1) $(2)
|
2007-09-29 03:05:48 +03: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
|
|
|
|
$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(URL)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define wrap_mirror
|
2008-07-31 05:43:33 +03:00
|
|
|
$(if $(MIRROR),@$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "x" || ( $(1) ),$(1))
|
2007-09-29 03:05:48 +03:00
|
|
|
endef
|
|
|
|
|
2008-01-02 17:14:31 +02:00
|
|
|
define DownloadMethod/cvs
|
|
|
|
$(call wrap_mirror, \
|
|
|
|
echo "Checking out files from the cvs repository..."; \
|
2010-02-20 06:48:07 +02:00
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2010-03-14 23:55:11 +02:00
|
|
|
cvs -d $(URL) export $(VERSION) $(SUBDIR) && \
|
2010-02-20 06:48:07 +02:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 23:55:11 +02:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2010-02-20 06:48:07 +02:00
|
|
|
)
|
2008-01-02 17:14:31 +02:00
|
|
|
endef
|
|
|
|
|
2007-09-29 03:05:48 +03:00
|
|
|
define DownloadMethod/svn
|
|
|
|
$(call wrap_mirror, \
|
2007-11-16 05:10:40 +02:00
|
|
|
echo "Checking out files from the svn repository..."; \
|
2007-09-29 03:05:48 +03:00
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2010-03-19 15:44:47 +02:00
|
|
|
svn export --non-interactive --trust-server-cert -r$(VERSION) $(URL) $(SUBDIR) && \
|
2007-09-29 03:05:48 +03:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 23:55:11 +02:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2007-09-29 03:05:48 +03:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2007-11-16 05:10:40 +02: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) ] && \
|
2008-08-24 16:40:21 +03:00
|
|
|
git clone $(URL) $(SUBDIR) && \
|
|
|
|
(cd $(SUBDIR) && git checkout $(VERSION)) && \
|
2007-11-16 05:10:40 +02:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
rm -rf $(SUBDIR)/.git && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 23:55:11 +02:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2007-11-16 05:10:40 +02:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2010-02-20 06:48:07 +02: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-14 23:55:11 +02:00
|
|
|
bzr export -r$(VERSION) $(URL) $(SUBDIR) && \
|
2010-02-20 06:48:07 +02:00
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
2010-03-14 23:55:11 +02:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ &&
|
|
|
|
rm -rf $(SUBDIR); \
|
2010-02-20 06:48:07 +02:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2008-08-29 16:02:05 +03: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-14 23:55:11 +02:00
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
|
|
|
|
rm -rf $(SUBDIR); \
|
2008-08-29 16:02:05 +03:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2008-01-02 17:14:31 +02:00
|
|
|
Validate/cvs=VERSION SUBDIR
|
2007-09-29 03:05:48 +03:00
|
|
|
Validate/svn=VERSION SUBDIR
|
2007-11-16 05:10:40 +02:00
|
|
|
Validate/git=VERSION SUBDIR
|
2010-02-20 06:48:07 +02:00
|
|
|
Validate/bzr=VERSION SUBDIR
|
2008-08-29 16:02:05 +03:00
|
|
|
Validate/hg=VERSION SUBDIR
|
2007-09-29 03:05:48 +03:00
|
|
|
|
|
|
|
define Download/Defaults
|
|
|
|
URL:=
|
|
|
|
FILE:=
|
|
|
|
PROTO:=
|
|
|
|
MD5SUM:=
|
|
|
|
SUBDIR:=
|
2008-07-31 05:43:33 +03:00
|
|
|
MIRROR:=1
|
2007-09-29 03:05:48 +03: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 04:37:10 +02:00
|
|
|
$(foreach dep,$(DOWNLOAD_RDEP),
|
|
|
|
$(dep): $(DL_DIR)/$(FILE)
|
|
|
|
)
|
2007-09-29 03:05:48 +03: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
|