All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override
@ 2017-07-05 12:33 Marcin Niestroj
  2017-07-05 14:48 ` Peter Korsgaard
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Niestroj @ 2017-07-05 12:33 UTC (permalink / raw)
  To: buildroot

Allow BR2_PRIMARY_SITE and BR2_PRIMARY_SITE_ONLY .config options to be
overriden by environment variables with the same names.

This is usefull for CI build environments, so primary site can be
overridden without .config change. That way download can be speeded up
if using mirror servers in the same network as CI.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
---
 Makefile                     | 6 ++++++
 docs/manual/common-usage.txt | 6 ++++++
 package/pkg-download.mk      | 8 ++++++++
 3 files changed, 20 insertions(+)

diff --git a/Makefile b/Makefile
index 19d8b442a3..d7a929fb41 100644
--- a/Makefile
+++ b/Makefile
@@ -208,6 +208,12 @@ endif
 ifneq ($(BR2_CCACHE_DIR),)
 BR_CACHE_DIR := $(BR2_CCACHE_DIR)
 endif
+ifneq ($(BR2_PRIMARY_SITE),)
+BR_PRIMARY_SITE := $(BR2_PRIMARY_SITE)
+endif
+ifneq ($(BR2_PRIMARY_SITE_ONLY),)
+BR_PRIMARY_SITE_ONLY := $(BR2_PRIMARY_SITE_ONLY)
+endif
 
 # Need that early, before we scan packages
 # Avoids doing the $(or...) everytime
diff --git a/docs/manual/common-usage.txt b/docs/manual/common-usage.txt
index a22da20188..e27e3ab2e7 100644
--- a/docs/manual/common-usage.txt
+++ b/docs/manual/common-usage.txt
@@ -90,6 +90,12 @@ to +make+ or set in the environment:
 * +BR2_DL_DIR+ to override the directory in which
   Buildroot stores/retrieves downloaded files
   +
+* +BR2_PRIMARY_SITE+ to override .config primary site to download
+  package sources from.
+  +
+* +BR2_PRIMARY_SITE_ONLY+ to override .config primary site only
+  download option.
+  +
   Note that the Buildroot download directory can also be set from the
   configuration interface, so through the Buildroot +.config+ file. See
   xref:download-location[] for more details on how you can set the download
diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index fbbc2d7391..e271371ceb 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -217,6 +217,14 @@ endef
 # sites serve just plain files.
 ################################################################################
 
+# Restore the BR2_PRIMARY_SITE(_ONLY) that were overridden by the .config file
+ifneq ($(origin BR_PRIMARY_SITE),undefined)
+BR2_PRIMARY_SITE = $(BR_PRIMARY_SITE)
+endif
+ifneq ($(origin BR_PRIMARY_SITE_ONLY),undefined)
+BR2_PRIMARY_SITE_ONLY = $(BR_PRIMARY_SITE_ONLY)
+endif
+
 define DOWNLOAD
 	$(call DOWNLOAD_INNER,$(1),$(notdir $(1)),DOWNLOAD)
 endef
-- 
2.13.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override
  2017-07-05 12:33 [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override Marcin Niestroj
@ 2017-07-05 14:48 ` Peter Korsgaard
  2017-07-05 15:01   ` Marcin Niestroj
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Korsgaard @ 2017-07-05 14:48 UTC (permalink / raw)
  To: buildroot

>>>>> "Marcin" == Marcin Niestroj <m.niestroj@grinn-global.com> writes:

 > Allow BR2_PRIMARY_SITE and BR2_PRIMARY_SITE_ONLY .config options to be
 > overriden by environment variables with the same names.

 > This is usefull for CI build environments, so primary site can be
 > overridden without .config change. That way download can be speeded up
 > if using mirror servers in the same network as CI.

You can already pass these as make arguments (E.G. make
BR2_PRIMARY_SITE=".."). Is there any real reason why that cannot be used
by the CI setup instead?

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override
  2017-07-05 14:48 ` Peter Korsgaard
@ 2017-07-05 15:01   ` Marcin Niestroj
  2017-07-05 15:33     ` Peter Korsgaard
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Niestroj @ 2017-07-05 15:01 UTC (permalink / raw)
  To: buildroot

Hi,

On 05.07.2017 16:48, Peter Korsgaard wrote:
>>>>>> "Marcin" == Marcin Niestroj <m.niestroj@grinn-global.com> writes:
> 
>   > Allow BR2_PRIMARY_SITE and BR2_PRIMARY_SITE_ONLY .config options to be
>   > overriden by environment variables with the same names.
> 
>   > This is usefull for CI build environments, so primary site can be
>   > overridden without .config change. That way download can be speeded up
>   > if using mirror servers in the same network as CI.
> 
> You can already pass these as make arguments (E.G. make
> BR2_PRIMARY_SITE=".."). Is there any real reason why that cannot be used
> by the CI setup instead?
> 

1. Environment variable allows to set this configuration in a single
place, so in case of multiple CI jobs we do not need to modify the
"make" step in each one.
2. In case of CI setups that are configured by a file in project git
repository (such as gitlab CI) we do not need to hardcode
BR2_PRIMARY_SITE there.
3. As a developer I want to have BR2_PRIMARY_SITE set in ~/.bashrc or
something similar, so I do not need to issue
"make BR2_PRIMARY_SITE=some_really_long_uri" every time in multiple
Buildroot projects / board configurations that I have on my workstation.

-- 
Regards,
Marcin Niestroj

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override
  2017-07-05 15:01   ` Marcin Niestroj
@ 2017-07-05 15:33     ` Peter Korsgaard
  2017-07-06 10:01       ` Marcin Niestroj
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Korsgaard @ 2017-07-05 15:33 UTC (permalink / raw)
  To: buildroot

>>>>> "Marcin" == Marcin Niestroj <m.niestroj@grinn-global.com> writes:

 > Hi,
 > On 05.07.2017 16:48, Peter Korsgaard wrote:
 >>>>>>> "Marcin" == Marcin Niestroj <m.niestroj@grinn-global.com> writes:
 >> 
 >> > Allow BR2_PRIMARY_SITE and BR2_PRIMARY_SITE_ONLY .config options to be
 >> > overriden by environment variables with the same names.
 >> 
 >> > This is usefull for CI build environments, so primary site can be
 >> > overridden without .config change. That way download can be speeded up
 >> > if using mirror servers in the same network as CI.
 >> 
 >> You can already pass these as make arguments (E.G. make
 >> BR2_PRIMARY_SITE=".."). Is there any real reason why that cannot be used
 >> by the CI setup instead?
 >> 

 > 1. Environment variable allows to set this configuration in a single
 > place, so in case of multiple CI jobs we do not need to modify the
 > "make" step in each one.

Ok, but this is just a one-time step, right?

> 2. In case of CI setups that are configured by a file in project git
 > repository (such as gitlab CI) we do not need to hardcode
 > BR2_PRIMARY_SITE there.

You can always do 'make BR2_PRIMARY_SITE="$BR2_PRIMARY_SITE"' to grab
the value from the environment instead of hardcoding it.

> 3. As a developer I want to have BR2_PRIMARY_SITE set in ~/.bashrc or
 > something similar, so I do not need to issue
 > "make BR2_PRIMARY_SITE=some_really_long_uri" every time in multiple
 > Buildroot projects / board configurations that I have on my workstation.

We really try to not add any more magic environment variables affecting
the build.

You could always add a brmake shell alias in your ~/.bashrc which passes
these arguments.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override
  2017-07-05 15:33     ` Peter Korsgaard
@ 2017-07-06 10:01       ` Marcin Niestroj
  2017-07-06 11:09         ` Peter Korsgaard
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Niestroj @ 2017-07-06 10:01 UTC (permalink / raw)
  To: buildroot

On 05.07.2017 17:33, Peter Korsgaard wrote:
>>>>>> "Marcin" == Marcin Niestroj <m.niestroj@grinn-global.com> writes:
> 
>   > Hi,
>   > On 05.07.2017 16:48, Peter Korsgaard wrote:
>   >>>>>>> "Marcin" == Marcin Niestroj <m.niestroj@grinn-global.com> writes:
>   >>
>   >> > Allow BR2_PRIMARY_SITE and BR2_PRIMARY_SITE_ONLY .config options to be
>   >> > overriden by environment variables with the same names.
>   >>
>   >> > This is usefull for CI build environments, so primary site can be
>   >> > overridden without .config change. That way download can be speeded up
>   >> > if using mirror servers in the same network as CI.
>   >>
>   >> You can already pass these as make arguments (E.G. make
>   >> BR2_PRIMARY_SITE=".."). Is there any real reason why that cannot be used
>   >> by the CI setup instead?
>   >>
> 
>   > 1. Environment variable allows to set this configuration in a single
>   > place, so in case of multiple CI jobs we do not need to modify the
>   > "make" step in each one.
> 
> Ok, but this is just a one-time step, right?

That is right.

> 
>> 2. In case of CI setups that are configured by a file in project git
>   > repository (such as gitlab CI) we do not need to hardcode
>   > BR2_PRIMARY_SITE there.
> 
> You can always do 'make BR2_PRIMARY_SITE="$BR2_PRIMARY_SITE"' to grab
> the value from the environment instead of hardcoding it.

Thanks for that hint. It covers the most desirable use case for me.

> 
>> 3. As a developer I want to have BR2_PRIMARY_SITE set in ~/.bashrc or
>   > something similar, so I do not need to issue
>   > "make BR2_PRIMARY_SITE=some_really_long_uri" every time in multiple
>   > Buildroot projects / board configurations that I have on my workstation.
> 
> We really try to not add any more magic environment variables affecting
> the build.
> 
> You could always add a brmake shell alias in your ~/.bashrc which passes
> these arguments.
> 

I still think that using environment variable with make command instead
of brmake alias is more comfortable for a developer. But I get your
point, so I will not insist on this patch :)

-- 
Regards,
Marcin Niestroj

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override
  2017-07-06 10:01       ` Marcin Niestroj
@ 2017-07-06 11:09         ` Peter Korsgaard
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2017-07-06 11:09 UTC (permalink / raw)
  To: buildroot

>>>>> "Marcin" == Marcin Niestroj <m.niestroj@grinn-global.com> writes:

Hi,

 > I still think that using environment variable with make command instead
 > of brmake alias is more comfortable for a developer. But I get your
 > point, so I will not insist on this patch :)

I understand. The problem is that it is very difficult to remove
features once people start using it, and we try very hard to keep
Buildroot (relatively) simple. Part of this is to not have multiple ways
of doing the same thing.

Sorry.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-06 11:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-05 12:33 [Buildroot] [PATCH] download: allow for BR2_PRIMARY_SITE(_ONLY) environment override Marcin Niestroj
2017-07-05 14:48 ` Peter Korsgaard
2017-07-05 15:01   ` Marcin Niestroj
2017-07-05 15:33     ` Peter Korsgaard
2017-07-06 10:01       ` Marcin Niestroj
2017-07-06 11:09         ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.