<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>6303</bug_id>
          
          <creation_ts>2014-05-09 19:31:01 +0000</creation_ts>
          <short_desc>Perforce does not take variables from executing shell</short_desc>
          <delta_ts>2016-06-21 11:14:11 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>1.5.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Low</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>Future</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Volker">lists.volker</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>andrew</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>ross.burton</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>43223</commentid>
    <comment_count>0</comment_count>
    <who name="Volker">lists.volker</who>
    <bug_when>2014-05-09 19:31:01 +0000</bug_when>
    <thetext>Perforce works in a way that you define in your shell some variables like
  P4PORT=&apos;&lt;hostname/IP of server&gt;:&lt;port&gt;&quot;
  P4USER=&apos;myperforceuser&apos;
  P4PASSWD=&apos;myperfocepasswd&apos;
beside this, perforce also expects a P4CLIENT variable (which, if required, in my opinion should be always managed (created+deleted) by Yocto. That is just to check for the amount of variables you need

Jenkins does provide for example a way to provide these information to the shell which fetches the data.

If I try now to fetch code from perforce
   SRC_URI = &quot;p4://depot/my-project/...&quot;
the build fails first because the P4PORT is not know. The error output itself is not helpful, nor clear (the variable should be checked and the issue told to the user).

So you modify your recipe as following:
    SRC_URI = &quot;p4://depot/my-project/...&quot;
    P4PORT=&apos;XXXX:YYYY&apos;

Now you get a somewhat more helpful error message:
   Exception: ExecutionError: Execution of &apos;None -p XXXX:YYYY changes -m 1 //depot/myproject/...&apos; failed with exit code 127:
   /bin/sh: 1: None: not found

So we have to tell the name of the perforce client (always p4 or p4.exe), modify it again
    SRC_URI = &quot;p4://depot/my-project/...&quot;
    P4PORT=&apos;XXXX:YYYY&apos;
    FETCHCOMMAND_p4 = &quot;p4&quot;

And you get another error:
Exception: ExecutionError: Execution of &apos;p4 -p XXXX:YYYY changes -m 1 //depot/my-project/...&apos; failed with exit code 1:
Perforce password (P4PASSWD) invalid or unset.


Yet, all these variables are availble in the shell executing
   bitbake -c fetch my-test-project

Also adding P4PASSWD to the recipe like P4PORT does not fix it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43224</commentid>
    <comment_count>1</comment_count>
    <who name="Volker">lists.volker</who>
    <bug_when>2014-05-09 20:22:47 +0000</bug_when>
    <thetext>   export P4PASSWD=&apos;mypasswd&apos;
   export P4USER=&apos;my-p4-user&apos; works

I did not find a way to use the shell variable I have already set on the configuration. Else the yocto perforce lib indicates that you can also provide the username and password in the SRC_URI.

Providing the perforce user+password in the code itself is a really bad idea.

I also did not find documentation about the entire perforce usage, only a post on the mailinglist.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43230</commentid>
    <comment_count>2</comment_count>
    <who name="Volker">lists.volker</who>
    <bug_when>2014-05-09 21:20:39 +0000</bug_when>
    <thetext>To explain the issue with the P4CLIENT (also called &quot;workspace&quot;):
The P4CLIENT defines which part of the perforce tree is fetched and where it is stored.

Actually the part that is fetched is known via SRC_URI (in the previous example //depot/my-project/...). But it is not know where to sync/copy the data to. And perforce does not provide a way (I am not familiar with the latest version) to put it to a folder that is not configured in workspace.

It seems also that the perforce fetch library uses the the default perforce workspace defined outside of the plugin in the shell variable P4CLIENT. As result you can&apos;t define where to copy the data to which is against the fact that the data should be copied to the yocto workspace.

I also don&apos;t think it would be a good idea to reuse and existing perforce workspace. A work around would be creating for the fetch an individual perforce workspace (as Jenkins does it for example).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43243</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-05-11 14:23:52 +0000</bug_when>
    <thetext>Basically, the way the bitbake perforce fetcher works is that its expecting to get these variables from the url. The fetcher certainly needs a default fallback if FETCHCOMMAND_p4 = &quot;p4&quot; is unset so I will add that.

Do things work better if you specific a url containing the user/passwd/port?

p4://depot:user:passwd:port@my-project/ is I think the format the fetcher code is expecting although its rather unclear and some of the other url parsing improvements may have badly affected this fetcher.

I&apos;m going off the code in bitbake/lib/bb/fetch2/perforce.py. I&apos;ve never used perforce and don&apos;t have access to an install of it so the fetcher is maintained simply by people sending patches to it as a best effort on our part.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43244</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-05-11 14:26:52 +0000</bug_when>
    <thetext>http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=50067e069c8cbc0d339819494f22ae7623d47aa6</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43343</commentid>
    <comment_count>5</comment_count>
    <who name="Volker">lists.volker</who>
    <bug_when>2014-05-14 21:04:00 +0000</bug_when>
    <thetext>I actually never tested the username:password option. I can&apos;t add username + passwords into the SCM.

I did only test which variables in the recipe are required to get it working without an error.

But there is more work to do to get it running. And of course you need a perforce access to modify &amp; test it.

Actually, the issue should be more the place where to fetch the data to (perforce workspace configuration) than bringing the variables in via BB_ENV_EXTRAWHITE.


Right now I fetch the data in the build script, so I don&apos;t need a fix. But at least the issues with perforce should be documented here, thats why I submitted this ticket.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45807</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-09-24 17:09:06 +0000</bug_when>
    <thetext>Since we&apos;ve addressed the simple issues that we can and since I don&apos;t have perforce, I&apos;m moving this to a future enhancement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63122</commentid>
    <comment_count>7</comment_count>
    <who name="Andrew Bradford">andrew</who>
    <bug_when>2016-06-17 18:33:52 +0000</bug_when>
    <thetext>Are the changes in https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=26447a0d0bf5ceaac382a78c1dbd00807dbab706 enough to warrant closing this issue?

Username, password, P4PORT, and other variables which can be specified within P4CONFIG can now automatically be used by the perforce fetcher so that you do not need to specify them in a recipe if you don&apos;t want to so long as your env has the P4CONFIG variable defined properly and the &apos;p4&apos; executable is in your path.

A sane default is used for FETCHCMD_p4.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63183</commentid>
    <comment_count>8</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2016-06-21 11:14:11 +0000</bug_when>
    <thetext>I&apos;d say so - if anyone disagrees they can re-open.

Closed in bitbake 6298696bb94a127cdec7964315f6891ba92cd026.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>