Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Karoly Kasza <kaszak@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] Add proxy download support
Date: Tue, 21 Oct 2014 16:53:23 +0200	[thread overview]
Message-ID: <1413903203-33909-1-git-send-email-kaszak@gmail.com> (raw)

This patch adds support for downloading sources over a http proxy.
Supports wget with http, https & ftp targets, bzr, hg, svn.
Git does work with forcing https instead of git protocol.
Cvs is not supported, but Buildroot does not currently have any
packages relying on cvs repos (plus this would fall back to the
Buildroot mirror over http).

Signed-off-by: Karoly Kasza <kaszak@gmail.com>
---
 Config.in                |   25 +++++++++++++++++++++++++
 Makefile                 |    9 +++++++++
 support/download/wrapper |   26 ++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)

diff --git a/Config.in b/Config.in
index 9cefcbc..2e2b493 100644
--- a/Config.in
+++ b/Config.in
@@ -253,6 +253,31 @@ config BR2_CPAN_MIRROR
 
 endmenu
 
+config BR2_PROXY
+	bool "Use http proxy"
+	help
+	  Use a http proxy when downloading sources with various protocols.
+
+if BR2_PROXY
+
+config BR2_PROXY_URL
+	string "Http proxy URL"
+	help
+	  Http proxy URL in the form of <IP or FQDN>:<port>.
+
+config BR2_PROXY_USER
+	string "Http proxy username"
+	help
+	  Http proxy username (if needed).
+
+config BR2_PROXY_PASS
+	string "Http proxy password"
+	help
+	  Http proxy password (if needed).
+	  PLEASE NOTE! This password will be saved in the .config file!
+
+endif
+
 config BR2_JLEVEL
 	int "Number of jobs to run simultaneously (0 for auto)"
 	default "0"
diff --git a/Makefile b/Makefile
index 907a0fc..5dd40e8 100644
--- a/Makefile
+++ b/Makefile
@@ -338,6 +338,15 @@ TARGET_SKELETON = $(TOPDIR)/system/skeleton
 # should not be used as the root filesystem.
 TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
 
+ifeq ($(BR2_PROXY),y)
+BR_PROXY_URL = $(call qstrip,$(BR2_PROXY_URL))
+export BR_PROXY_URL
+BR_PROXY_USER = $(call qstrip,$(BR2_PROXY_USER))
+export BR_PROXY_USER
+BR_PROXY_PASS = $(call qstrip,$(BR2_PROXY_PASS))
+export BR_PROXY_PASS
+endif
+
 ifeq ($(BR2_CCACHE),y)
 CCACHE := $(HOST_DIR)/usr/bin/ccache
 BR_CACHE_DIR = $(call qstrip,$(BR2_CCACHE_DIR))
diff --git a/support/download/wrapper b/support/download/wrapper
index 8ae2797..b224474 100755
--- a/support/download/wrapper
+++ b/support/download/wrapper
@@ -44,6 +44,32 @@ tmpf="${tmpd}/output"
 # Doing the 'cd' here rather than in all helpers is easier.
 cd "${tmpd}"
 
+# Set the proxy environment variables.
+# cvs doesn't support proxies OOB, but there is currently no cvs
+# based package in Buildroot. Also, in that case after the download
+# fails, the wget method would be used from sources.buildroot.net.
+if [ -n "${BR_PROXY_URL}" ]; then
+# SVN does not support http_proxy environment variables, so we use
+# it's commandline arguments
+proxy_host=`echo $BR_PROXY_URL | cut -d":" -f1`
+proxy_port=`echo $BR_PROXY_URL | cut -d":" -f2`
+SVN="${SVN} --config-option servers:global:http-proxy-host=${proxy_host} \
+--config-option servers:global:http-proxy-port=${proxy_port}"
+if [ -n "${BR_PROXY_USER}" ] && [ -n "${BR_PROXY_PASS}" ]; then
+SVN="${SVN} --config-option servers:global:http-proxy-username=${BR_PROXY_USER} \
+--config-option servers:global:http-proxy-password=${BR_PROXY_PASS}"
+proxy="http://${BR_PROXY_USER}:${BR_PROXY_PASS}@${BR_PROXY_URL}"
+else
+proxy="http://${BR_PROXY_URL}"
+fi
+export http_proxy=${proxy}
+export https_proxy=${proxy}
+export ftp_proxy=${proxy}
+# While git does support http_proxy environment variables, we need to use
+# the config option below to force proxying over https instead of git
+GIT="${GIT} -c url.https://.insteadOf=git://"
+fi
+
 # If the helper fails, we can just remove the temporary directory to
 # remove all the cruft it may have left behind. Then we just exit in
 # error too.
-- 
1.7.10.4

             reply	other threads:[~2014-10-21 14:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 14:53 Karoly Kasza [this message]
2014-10-21 16:49 ` [Buildroot] [PATCH 1/1] Add proxy download support Yann E. MORIN
2014-10-21 18:23   ` Károly Kasza
2014-10-21 20:25     ` Yann E. MORIN
2014-10-21 21:35       ` Arnout Vandecappelle
2014-10-22  9:29       ` Károly Kasza
2014-10-24 23:23 ` Yann E. MORIN
2014-10-25  6:36   ` Károly Kasza
2014-10-26 10:38   ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413903203-33909-1-git-send-email-kaszak@gmail.com \
    --to=kaszak@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox