--- /dev/null
+#
+# 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), \
+ $(if $(filter @GNU/% @KERNEL/% @SF/% ftp://% http://%,$(1)),default, \
+ $(if $(filter git://%,$(1)),git, \
+ $(if $(filter svn://%,$(1)),svn, \
+ unknown \
+ ) \
+ ) \
+ ) \
+ ) \
+)
+endef
+
+# code for creating tarballs from svn/git checkouts - useful for mirror support
+dl_pack/bz2=tar cfj $(1) $(2)
+dl_pack/gz=tar cfz $(1) $(2)
+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
+ @$(if $(CONFIG_LOCALMIRROR),$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "x" || ) \
+ ( $(1) ) \
+ $(if $(CONFIG_LOCALMIRROR),, || $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "x")
+endef
+
+define DownloadMethod/svn
+ $(call wrap_mirror, \
+ echo "Checking out files from svn repository..."; \
+ mkdir -p $(TMP_DIR)/dl && \
+ cd $(TMP_DIR)/dl && \
+ rm -rf $(SUBDIR) && \
+ [ \! -d $(SUBDIR) ] && \
+ svn co -r$(VERSION) $(URL) $(SUBDIR) && \
+ 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
+
+Validate/svn=VERSION SUBDIR
+#Validate/git=VERSION SUBDIR
+
+define Download/Defaults
+ URL:=
+ FILE:=
+ PROTO:=
+ MD5SUM:=
+ SUBDIR:=
+ 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
override MAKEFLAGS=
+include $(INCLUDE_DIR)/download.mk
include $(INCLUDE_DIR)/quilt.mk
Build/Patch:=$(Build/Patch/Default)
$(call Build/Compile/Default)
endef
-
-ifneq ($(strip $(PKG_SOURCE)),)
- download: $(DL_DIR)/$(PKG_SOURCE)
-
- $(DL_DIR)/$(PKG_SOURCE):
- mkdir -p $(DL_DIR)
- $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
-
- $(STAMP_PREPARED): $(DL_DIR)/$(PKG_SOURCE)
-endif
-
ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
define HostBuild/Autoclean
$(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
endef
endif
+define Download/default
+ FILE:=$(PKG_SOURCE)
+ URL:=$(PKG_SOURCE_URL)
+ PROTO:=$(PKG_SOURCE_PROTO)
+ VERSION:=$(PKG_SOURCE_VERSION)
+ MD5SUM:=$(PKG_MD5SUM)
+endef
+
define HostBuild
- ifeq ($(DUMP),)
- $(call HostBuild/Autoclean)
- endif
+ $(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))
+ $(if $(DUMP),,$(call HostBuild/Autoclean))
$(STAMP_PREPARED):
@-rm -rf $(PKG_BUILD_DIR)
STAMP_PREPARED:=$(LINUX_DIR)/.prepared
STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
+include $(INCLUDE_DIR)/download.mk
include $(INCLUDE_DIR)/quilt.mk
include $(INCLUDE_DIR)/kernel-defaults.mk
$(call Kernel/Clean/Default)
endef
+define Download/kernel
+ URL:=$(LINUX_SITE)
+ FILE:=$(LINUX_SOURCE)
+ MD5SUM:=$(LINUX_KERNEL_MD5SUM)
+endef
+
define BuildKernel
- ifneq ($(LINUX_SITE),)
- $(DL_DIR)/$(LINUX_SOURCE):
- -mkdir -p $(DL_DIR)
- $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
- endif
+ $(if $(LINUX_SITE),$(call Download,kernel))
$(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
-rm -rf $(KERNEL_BUILD_DIR)
STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
+include $(INCLUDE_DIR)/download.mk
include $(INCLUDE_DIR)/quilt.mk
include $(INCLUDE_DIR)/package-defaults.mk
include $(INCLUDE_DIR)/package-dumpinfo.mk
endif
endif
+define Download/default
+ FILE:=$(PKG_SOURCE)
+ URL:=$(PKG_SOURCE_URL)
+ PROTO:=$(PKG_SOURCE_PROTO)
+ VERSION:=$(PKG_SOURCE_VERSION)
+ MD5SUM:=$(PKG_MD5SUM)
+endef
define Build/DefaultTargets
- ifneq ($(strip $(PKG_SOURCE_URL)),)
- download: $(DL_DIR)/$(PKG_SOURCE)
-
- $(DL_DIR)/$(PKG_SOURCE):
- mkdir -p $(DL_DIR)
- $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
-
- $(STAMP_PREPARED): $(DL_DIR)/$(PKG_SOURCE)
- endif
-
+ $(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))
$(call Build/Autoclean)
$(STAMP_PREPARED):
-ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))
+#
+# Copyright (C) 2006-2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
# unpacking files with +s may break on some platforms. this typically emits error code 2
ifneq ($(HOST_OS),Linux)
#
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
export $(call shvar,$(1))
endef
+# file extension
+ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))
+
all:
FORCE: ;
.PHONY: FORCE
use warnings;
use File::Basename;
+@ARGV > 2 or die "Syntax: $0 <target dir> <filename> <md5sum> [<mirror> ...]\n";
+
my $target = shift @ARGV;
my $filename = shift @ARGV;
my $md5sum = shift @ARGV;
my $scriptdir = dirname($0);
my @mirrors;
-
my $ok;
-@ARGV > 0 or die "Syntax: $0 <target dir> <filename> <md5sum> <mirror> [<mirror> ...]\n";
-
sub localmirrors {
my @mlist;
open LM, "$scriptdir/localmirrors" and do {