Patchwork [bitbake-devel,RFC,1/1] bitbake/cooker.py: set the PREFERRED_VERSION from command line

login
register
mail settings
Submitter Robert Yang
Date Jan. 6, 2014, 10:53 a.m.
Message ID <4d61da4f684bc292dd35b407c2dfa9ce5e6633c4.1389005562.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/64109/
State New
Headers show

Comments

Robert Yang - Jan. 6, 2014, 10:53 a.m.
We can't set the PREFERRED_VERSION from the command line, this will make
it possible:

$ P_V="3.81" bitbake make
$ P_V="3.81" bitbake make-native

Then the make-3.81 and make-native-3.81 will be built (the default is
3.82)

Another we that we have originally thought was:

$ export BB_PRESERVE_ENV=1
$ PREFERRED_VERSION_make = 3.81 bitbake make

This worked for make, but didn't work for make-native since
we can't use "-" in a shell environment variable.

TODO:
* This is just a RFC and open for discussion, any comments is
  appreciated.

* It only can set the PREFERRED_VERSION for the pkg_to_build, we can
  make it more flexible, for example, if we found the keyword
  PREFERRED_VERSION in the P_V, we can set it for any recipe:
  (assume core-image-sato RDEPENDS on make)
  $ P_V="PREFERRED_VERSION_make=3.81" bitbake core-image-sato

* BTW, another questions, can we change the PREFERRED_VERSION to P_V
  or PF_V, and the PREFERRED_PROVIDER to P_P ot PF_P, please ? They are
  a little long to type and easy to make typos currently.

[YOCTO #4965]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 bitbake/lib/bb/cooker.py     | 5 +++++
 bitbake/lib/bb/cookerdata.py | 1 +
 scripts/oe-buildenv-internal | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)
Richard Purdie - Jan. 7, 2014, 1:18 p.m.
On Mon, 2014-01-06 at 18:53 +0800, Robert Yang wrote:
> We can't set the PREFERRED_VERSION from the command line, this will make
> it possible:
> 
> $ P_V="3.81" bitbake make
> $ P_V="3.81" bitbake make-native
> 
> Then the make-3.81 and make-native-3.81 will be built (the default is
> 3.82)
> 
> Another we that we have originally thought was:
> 
> $ export BB_PRESERVE_ENV=1
> $ PREFERRED_VERSION_make = 3.81 bitbake make
> 
> This worked for make, but didn't work for make-native since
> we can't use "-" in a shell environment variable.
> 
> TODO:
> * This is just a RFC and open for discussion, any comments is
>   appreciated.
> 
> * It only can set the PREFERRED_VERSION for the pkg_to_build, we can
>   make it more flexible, for example, if we found the keyword
>   PREFERRED_VERSION in the P_V, we can set it for any recipe:
>   (assume core-image-sato RDEPENDS on make)
>   $ P_V="PREFERRED_VERSION_make=3.81" bitbake core-image-sato

Well, this defines a different version of PREFERRED_VERSION with
completely different semantics to the other one. I don't think this is
acceptable or a good way to avoid this problem and will ultimately just
confuse more users.

> * BTW, another questions, can we change the PREFERRED_VERSION to P_V
>   or PF_V, and the PREFERRED_PROVIDER to P_P ot PF_P, please ? They are
>   a little long to type and easy to make typos currently.

No, this would be extremely confusing with PV and other variables.
Please use copy and paste or something ;-).

A better way of handling things might be to translate "__" to "-" when
importing variables from the environment so you could set:

PREFERRED_VERSION_make__native = "3.81"

I'm open to other ideas but don't like P_V at all, particularly when it
behaves differently to PREFERRED_VERSION.

Cheers,

Richard

Patch

diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index db4cb51..a6c30b8 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -180,6 +180,11 @@  class BBCooker:
         self.data = self.databuilder.data
         self.data_hash = self.databuilder.data_hash
 
+        P_V = self.data.getVar('P_V')
+        if P_V and len(self.configuration.pkgs_to_build) == 1:
+            pkg = ''.join(self.configuration.pkgs_to_build)
+            logger.info("Setting PREFERRED_VERSION_%s to %s" % (pkg, P_V))
+            self.data.setVar("PREFERRED_VERSION_%s" % pkg, P_V)
         #
         # Special updated configuration we use for firing events
         #
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 6200b0e..faf71da 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -128,6 +128,7 @@  class CookerConfiguration(object):
         self.dry_run = False
         self.tracking = False
         self.interface = []
+        self.pkgs_to_build = []
 
         self.env = {}
 
diff --git a/scripts/oe-buildenv-internal b/scripts/oe-buildenv-internal
index bba6f8f..5c17a9a 100755
--- a/scripts/oe-buildenv-internal
+++ b/scripts/oe-buildenv-internal
@@ -106,4 +106,4 @@  export BB_ENV_EXTRAWHITE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
 SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
-SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR"
+SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR P_V"