]> Git Repo - buildroot-mgba.git/blame - package/pkg-download.mk
download: put most of the infra in dl-wrapper
[buildroot-mgba.git] / package / pkg-download.mk
CommitLineData
8dfd59d1 1################################################################################
c0e6b524
TP
2#
3# This file contains the download helpers for the various package
4# infrastructures. It is used to handle downloads from HTTP servers,
5# FTP servers, Git repositories, Subversion repositories, Mercurial
6# repositories, Bazaar repositories, and SCP servers.
7#
8dfd59d1 8################################################################################
c0e6b524 9
6e6b99a5 10# Download method commands
4dc54da0 11export WGET := $(call qstrip,$(BR2_WGET))
daf034f8 12export SVN := $(call qstrip,$(BR2_SVN))
f4526c05 13export CVS := $(call qstrip,$(BR2_CVS))
45261f1f 14export BZR := $(call qstrip,$(BR2_BZR))
95a57228 15export GIT := $(call qstrip,$(BR2_GIT))
4dc54da0
YM
16export HG := $(call qstrip,$(BR2_HG))
17export SCP := $(call qstrip,$(BR2_SCP))
18SSH := $(call qstrip,$(BR2_SSH))
283b8b7f 19export LOCALFILES := $(call qstrip,$(BR2_LOCALFILES))
6e6b99a5 20
78b92e50
YM
21DL_WRAPPER = support/download/dl-wrapper
22
6768021c 23# DL_DIR may have been set already from the environment
af97c94b 24ifeq ($(origin DL_DIR),undefined)
6768021c 25DL_DIR ?= $(call qstrip,$(BR2_DL_DIR))
6e6b99a5 26ifeq ($(DL_DIR),)
e0d9d33c 27DL_DIR := $(TOPDIR)/dl
6e6b99a5 28endif
af97c94b
AV
29else
30# Restore the BR2_DL_DIR that was overridden by the .config file
31BR2_DL_DIR = $(DL_DIR)
32endif
6e6b99a5 33
a77ee7fd 34# ensure it exists and a absolute path
e0d9d33c 35DL_DIR := $(shell mkdir -p $(DL_DIR) && cd $(DL_DIR) >/dev/null && pwd)
a77ee7fd 36
6e6b99a5
TP
37#
38# URI scheme helper functions
39# Example URIs:
40# * http://www.example.com/dir/file
41# * scp://www.example.com:dir/file (with domainseparator :)
42#
43# geturischeme: http
f268f713 44geturischeme = $(firstword $(subst ://, ,$(call qstrip,$(1))))
c8ef0c03
MH
45# getschemeplusuri: git|parameter+http://example.com
46getschemeplusuri = $(call geturischeme,$(1))$(if $(2),\|$(2))+$(1)
6e6b99a5 47# stripurischeme: www.example.com/dir/file
f268f713 48stripurischeme = $(lastword $(subst ://, ,$(call qstrip,$(1))))
6e6b99a5 49# domain: www.example.com
f268f713 50domain = $(firstword $(subst $(call domainseparator,$(2)), ,$(call stripurischeme,$(1))))
6e6b99a5 51# notdomain: dir/file
f268f713 52notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$(call stripurischeme,$(1)))
6e6b99a5
TP
53#
54# default domainseparator is /, specify alternative value as first argument
f268f713 55domainseparator = $(if $(1),$(1),/)
6e6b99a5 56
2114c29e
YM
57# github(user,package,version): returns site of GitHub repository
58github = https://github.com/$(1)/$(2)/archive/$(3)
bb083e95 59
8d2f4e62 60# Expressly do not check hashes for those files
9fa6209f
YM
61# Exported variables default to immediately expanded in some versions of
62# make, but we need it to be recursively-epxanded, so explicitly assign it.
63export BR_NO_CHECK_HASH_FOR =
8d2f4e62 64
6e6b99a5 65################################################################################
c8ef0c03
MH
66# DOWNLOAD -- Download helper. Will call DL_WRAPPER which will try to download
67# source from:
68# 1) BR2_PRIMARY_SITE if enabled
69# 2) Download site, unless BR2_PRIMARY_SITE_ONLY is set
70# 3) BR2_BACKUP_SITE if enabled, unless BR2_PRIMARY_SITE_ONLY is set
71#
72# Argument 1 is the source location
6e6b99a5 73#
6e6b99a5
TP
74################################################################################
75
c8ef0c03
MH
76ifneq ($(call qstrip,$(BR2_PRIMARY_SITE)),)
77DOWNLOAD_URIS += \
78 -u $(call getschemeplusuri,$(BR2_PRIMARY_SITE),urlencode)
79endif
6e6b99a5 80
c8ef0c03
MH
81ifeq ($(BR2_PRIMARY_SITE_ONLY),)
82DOWNLOAD_URIS += \
83 -u $($(PKG)_SITE_METHOD)+$(dir $(1))
84ifneq ($(call qstrip,$(BR2_BACKUP_SITE)),)
85DOWNLOAD_URIS += \
86 -u $(call getschemeplusuri,$(BR2_BACKUP_SITE),urlencode)
87endif
88endif
15eb1faf 89
c8ef0c03
MH
90define DOWNLOAD
91 $(Q)$(if $(filter bzr cvs hg svn,$($(PKG)_SITE_METHOD)),BR_NO_CHECK_HASH_FOR=$(notdir $(1))) \
92 $(EXTRA_ENV) $(DL_WRAPPER) \
91e776b5 93 -c $($(PKG)_DL_VERSION) \
c8ef0c03 94 -f $(notdir $(1)) \
9b88c604 95 -H $(PKGDIR)/$($(PKG)_RAWNAME).hash \
91e776b5 96 -n $($(PKG)_BASENAME_RAW) \
c8ef0c03
MH
97 -N $($(PKG)_RAWNAME) \
98 -o $(DL_DIR)/$(notdir $(1)) \
99 $(if $($(PKG)_GIT_SUBMODULES),-r) \
100 $(DOWNLOAD_URIS) \
0b600227 101 $(QUIET) \
78b92e50 102 -- \
91b34e0a 103 $($(PKG)_DL_OPTS)
6e6b99a5 104endef
This page took 3.191924 seconds and 4 git commands to generate.