Hi,
I have recently been trying to use the Perforce fetcher in Bitbake to pull some
source from one of our repositories.
At the momment the fetcher uses the P4 environment variables to set the port,
username and clientspec. Perforce provides 3 mechanisms for providing this
information; enviroment variables; config files and command-line options - the
latter options over-riding the previous. Perforce will check for an environment
variable called "P4CONFIG" and search down the path to see if a config file of
the name provided by this variable is set and will use the configuration it
provides in preference to any environment variables. If this environment
variable is set in a shell used to run a bitbake operation, p4 will use the
options as set out in this file over the ones configured in the fetcher script.
The following patch changes the script to use the commandline options (which
always take precidence) rather than the environment variables.
Martyn
----
Index: lib/bb/fetch/perforce.py
===================================================================
--- lib/bb/fetch/perforce.py (revision 1080)
+++ lib/bb/fetch/perforce.py (working copy)
@@ -67,14 +67,15 @@
doparse = staticmethod(doparse)
def getcset(d, depot,host,user,pswd,parm):
+ p4opt = ""
if "cset" in parm:
return parm["cset"];
if user:
- data.setVar('P4USER', user, d)
+ p4opt += " -u %s" % (user)
if pswd:
- data.setVar('P4PASSWD', pswd, d)
+ p4opt += " -P %s" % (pswd)
if host:
- data.setVar('P4PORT', host, d)
+ p4opt += " -p %s" % (host)
p4date = data.getVar("P4DATE", d, 1)
if "revision" in parm:
@@ -85,8 +86,8 @@
depot += "@%s" % (p4date)
p4cmd = data.getVar('FETCHCOMMAND_p4', d, 1)
- bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s changes -m 1 %s" %
(p4cmd, depot))
- p4file = os.popen("%s changes -m 1 %s" % (p4cmd,depot))
+ bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s%s changes -m 1 %s"
% (p4cmd, p4opt, depot))
+ p4file = os.popen("%s%s changes -m 1 %s" % (p4cmd, p4opt, depot))
cset = p4file.readline().strip()
bb.msg.debug(1, bb.msg.domain.Fetcher, "READ %s" % (cset))
if not cset:
@@ -146,14 +147,15 @@
data.update_data(localdata)
# Get the p4 command
+ p4opt = ""
if user:
- data.setVar('P4USER', user, localdata)
+ p4opt += " -u %s" % (user)
if pswd:
- data.setVar('P4PASSWD', pswd, localdata)
+ p4opt += " -P %s" % (pswd)
if host:
- data.setVar('P4PORT', host, localdata)
+ p4opt += " -p %s" % (host)
p4cmd = data.getVar('FETCHCOMMAND', localdata, 1)
@@ -175,8 +177,8 @@
os.chdir(tmpfile)
bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
- bb.msg.note(1, bb.msg.domain.Fetcher, "%s files %s" % (p4cmd, depot))
- p4file = os.popen("%s files %s" % (p4cmd, depot))
+ bb.msg.note(1, bb.msg.domain.Fetcher, "%s%s files %s" % (p4cmd, p4opt,
depot))
+ p4file = os.popen("%s%s files %s" % (p4cmd, p4opt, depot))
if not p4file:
bb.error("Fetch: unable to get the P4 files from %s" % (depot))
@@ -193,7 +195,7 @@
dest = list[0][len(path)+1:]
where = dest.find("#")
- os.system("%s print -o %s/%s %s" % (p4cmd,
module,dest[:where],list[0]))
+ os.system("%s%s print -o %s/%s %s" % (p4cmd, p4opt,
module,dest[:where],list[0]))
count = count + 1
if count == 0:
--
Martyn Welch MEng MPhil MIET (Principal Software Engineer) T:+44(0)1327322748
GE Fanuc Intelligent Platforms Ltd, |Registered in England and Wales
Tove Valley Business Park, Towcester, |(3828642) at 100 Barbirolli Square,
Northants, NN12 6PF, UK T:+44(0)1327359444 |Manchester,M2 3AB VAT:GB 729849476
_______________________________________________
Bitbake-dev mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/bitbake-dev