2007-09-29 03:05:48 +03:00
|
|
|
#
|
|
|
|
# Copyright (C) 2007 OpenWrt.org
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
|
|
|
DOWNLOAD_RDEP:=$(STAMP_PREPARED)
|
|
|
|
|
|
|
|
# Try to guess the download method from the URL
|
|
|
|
define dl_method
|
|
|
|
$(strip \
|
|
|
|
$(if $(2),$(2), \
|
2008-09-02 00:46:17 +03:00
|
|
|
$(if $(filter @GNOME/% @GNU/% @KERNEL/% @SF/% ftp://% http://%,$(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, \
|
|
|
|
unknown \
|
|
|
|
) \
|
2008-01-02 17:18:24 +02:00
|
|
|
) \
|
2007-09-29 03:05:48 +03:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2008-08-29 16:02:05 +03:00
|
|
|
# code for creating tarballs from cvs/svn/git/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..."; \
|
|
|
|
mkdir -p $(TMP_DIR)/dl && \
|
|
|
|
cd $(TMP_DIR)/dl && \
|
|
|
|
rm -rf $(SUBDIR) && \
|
|
|
|
[ \! -d $(SUBDIR) ] && \
|
2008-08-27 18:24:25 +03:00
|
|
|
cvs -d $(URL) co -r $(VERSION) $(SUBDIR) && \
|
2008-01-02 17:14:31 +02:00
|
|
|
find $(SUBDIR) -name CVS | xargs rm -rf && \
|
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
|
|
|
|
)
|
|
|
|
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) ] && \
|
2008-07-12 15:18:36 +03:00
|
|
|
svn co --non-interactive -r$(VERSION) $(URL) $(SUBDIR) && \
|
2007-09-29 03:05:48 +03:00
|
|
|
find $(SUBDIR) -name .svn | xargs rm -rf && \
|
|
|
|
echo "Packing checkout..." && \
|
|
|
|
$(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
|
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
|
|
|
|
)
|
|
|
|
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)) && \
|
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
|
|
|
|
)
|
|
|
|
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)) && \
|
|
|
|
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
|
|
|
|
)
|
|
|
|
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
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
$(if $(DOWNLOAD_RDEP),$(DOWNLOAD_RDEP): $(DL_DIR)/$(FILE))
|
|
|
|
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
|