<?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>12317</bug_id>
          
          <creation_ts>2017-11-07 12:37:12 +0000</creation_ts>
          <short_desc>using DEFAULT_PREFERENCE with SRCREV = &quot;${AUTOREV}&quot; can&apos;t work</short_desc>
          <delta_ts>2017-11-30 21:12:21 +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>2.4</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.5</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andreas Fenkart">afenkart</reporter>
          <assigned_to name="Paul Eggleton">bluelightning</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</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>78019</commentid>
    <comment_count>0</comment_count>
    <who name="Andreas Fenkart">afenkart</who>
    <bug_when>2017-11-07 12:37:12 +0000</bug_when>
    <thetext>In ticket: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7306. It was said that PV needs to contain the actual revision.

I followed the idea from the manual:
http://www.yoctoproject.org/docs/2.2/mega-manual/mega-manual.html#var-DEFAULT_PREFERENCE

- use a versioned recipe by default foobar_1.0.bb
- add foobar_git versioned recipe with DEFAULT_PREFERENCE=-1

in local.conf I then override the PREFERRED_VERSION
PREFERRED_VERSION_foobar = &quot;git&quot;

If a add the SRCREV to PV, I have to update the local.conf each time
the repository head changes, since the version is now e.g. gitr502+2621bc6.
The version is not &quot;git&quot; at all

When not addinng the SRCREV to the name I run into the problem as in ticket 7306 above:
This is because since all task stamps are still valid. None contains the git revision. With PV containing the git revision, this worked since the stamp filename (=siginfo files) contained PV, hence it was recreated whenever the src repository changed

I worked around this problem like this:

+python () {
+    git_rev=bb.fetch2.get_srcrev(d).split(&apos;+&apos;)[1]
+    d.setVar(&apos;GIT_REV&apos;, git_rev)
+}
+
+## force-add the git revision to the sstate siginfo file
+# previously PV contained GITPKGV, hence the siginfo filename itself contained
+# the git revision. But then we can&apos;t set PREFERRED_VERSION statically, because
+# the PV is not constant. PV=GITPKGV=gitrXXX-YYYYYYYY
+do_fetch[VARDEPS] += &quot;${GIT_REV}&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78029</commentid>
    <comment_count>1</comment_count>
    <who name="Andreas Fenkart">afenkart</who>
    <bug_when>2017-11-07 15:53:09 +0000</bug_when>
    <thetext>
FYI: simplified workaround to just this
+do_fetch[VARDEPS] += &quot;${SRCPV}&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78044</commentid>
    <comment_count>2</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2017-11-08 02:51:40 +0000</bug_when>
    <thetext>Did you try:

PREFERRED_VERSION_foobar = &quot;git%&quot;

?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78096</commentid>
    <comment_count>3</comment_count>
    <who name="Andreas Fenkart">afenkart</who>
    <bug_when>2017-11-09 10:35:10 +0000</bug_when>
    <thetext>yes, that solved the problem, sorry the noise. I wasn&apos;t aware I could use patterns to set the preferred version.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78097</commentid>
    <comment_count>4</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2017-11-09 10:48:50 +0000</bug_when>
    <thetext>No problem, marking resolved.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78098</commentid>
    <comment_count>5</comment_count>
    <who name="Andreas Fenkart">afenkart</who>
    <bug_when>2017-11-09 12:24:10 +0000</bug_when>
    <thetext>I must have made an error while testing before, retested again and it seems patterns don&apos;t work, I tested with yocto-2.4:

NOTE: Started PRServer with DBfile: /home/afenkart/dSS/dss-oe/poky-rescue-devel-build/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 35763, PID: 2461
NOTE: preferred version %git% of rescue-system not available (for item rescue-system)
NOTE: versions of rescue-system available: 1.1.0 1.1.0+gitrAUTOINC+e695223c1e
NOTE: Resolving any missing task queue dependencies
NOTE: preferred version %git% of rescue-system not available (for item rescue-system-dev)
NOTE: versions of rescue-system available: 1.1.0 1.1.0+gitrAUTOINC+e695223c1e
NOTE: preferred version %git% of rescue-system not available (for item rescue-system)
NOTE: versions of rescue-system available: 1.1.0 1.1.0+gitrAUTOINC+e695223c1e

the recipe part:
 inherit gitpkgv
 PV = &quot;1.1.0+gitr${SRCPV}&quot;
 PKGV = &quot;1.1.0+gitr${GITPKGV}&quot;
 PR = &quot;r0&quot;

site.conf:
-PREFERRED_VERSION_rescue-system = &quot;git&quot;
+PREFERRED_VERSION_rescue-system = &quot;%git%&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78129</commentid>
    <comment_count>6</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2017-11-09 19:29:33 +0000</bug_when>
    <thetext>Hang on - if what you are trying to match is git&lt;something&gt; why are you using &quot;%git%&quot; and not &quot;git%&quot; as I suggested? Does that make a difference?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78185</commentid>
    <comment_count>7</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2017-11-13 19:43:56 +0000</bug_when>
    <thetext>Marking NEEDINFO - Andreas, could you answer my most recent question? Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78196</commentid>
    <comment_count>8</comment_count>
    <who name="Andreas Fenkart">afenkart</who>
    <bug_when>2017-11-14 08:20:34 +0000</bug_when>
    <thetext>I used both ways, first git% then, since the log output has a leading prefix, I used %git% just as a try. Shall I retry with another pattern?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78197</commentid>
    <comment_count>9</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2017-11-14 11:10:44 +0000</bug_when>
    <thetext>I believe you want &quot;1.1.0+git%&quot; here after re-reading above.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78284</commentid>
    <comment_count>10</comment_count>
    <who name="Andreas Fenkart">afenkart</who>
    <bug_when>2017-11-20 10:31:42 +0000</bug_when>
    <thetext>Sorry was not online last week.

I rechecked with:
-PREFERRED_VERSION_rescue-system = &quot;git&quot;
+PREFERRED_VERSION_rescue-system = &quot;1.1.0+git%&quot;

And that indeed works:
- prefers the _git.bb recipe over the _1.1.0.bb recipe
- picks up changes when the upstream head is changed
- the generated package can be depended on from a taks/rootfs recipe

So far that seems to solve all my problem, the only sour taste to remain is that I must not forget to update the site.conf/local.conf whenever I bump the base version (=1.1.0 -&gt; 1.2.0). But that will produce a bitbake warning, saying that recipe 1.1.0-gitrxxx is not found.

I see that you already updated the documentation and clarified the point:
http://www.yoctoproject.org/docs/2.2/mega-manual/mega-manual.html#var-PREFERRED_VERSION</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78425</commentid>
    <comment_count>11</comment_count>
    <who name="Stephen K Jolley">sjolley.yp.pm</who>
    <bug_when>2017-11-30 16:18:06 +0000</bug_when>
    <thetext>It appears the NEEDINFO was answered.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78447</commentid>
    <comment_count>12</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2017-11-30 21:12:21 +0000</bug_when>
    <thetext>OK, great, I think we can consider this resolved unless you have further issues. 

I have however filed bug 12390 to cover the issue that % only works at the end of an expression - either we need to make it work anywhere, or properly document it as only working at the end since it appears we aren&apos;t currently mentioning that.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>