<?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>9827</bug_id>
          
          <creation_ts>2016-06-27 06:44:34 +0000</creation_ts>
          <short_desc>package.bbclass does not treat directory symlinks properly, leading to build failures</short_desc>
          <delta_ts>2016-08-11 06:27:17 +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>Meta-yocto</product>
          <component>meta-yocto</component>
          <version>2.0</version>
          <rep_platform>Other</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>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Heinz Wrobel">Heinz.Wrobel</reporter>
          <assigned_to name="Markus Lehtonen">markus.lehtonen</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>63333</commentid>
    <comment_count>0</comment_count>
      <attachid>3252</attachid>
    <who name="Heinz Wrobel">Heinz.Wrobel</who>
    <bug_when>2016-06-27 06:44:34 +0000</bug_when>
    <thetext>Created attachment 3252
Simple recipe with package.bbclass symlink bug test cases

[This is reported based on QorIQ-SDK-V2.0-20160527-yocto, which is built upon poky 2.0 jethro per poky.conf, running on CentOS 6.8 x64]

Turns out that poky/meta/package.bbclass is not handling directory symlinks properly in populate_packages() when the package files are split into sub-packages. Depending on how the user specifies FILES variable content, building the recipe can fail, also if the preferred rpm provider is set to be an rpm.org version 4.
It should be noted that rpm.org and rpm5 are separate developments and unfortunately not quite compatible. Unfortunately, the recipe names in Yocto are &quot;rpm&quot; as if they were just different versions of the same tree. Software requiring rpm.org version 4 can&apos;t be added easily without fixing up other recipes like consolekit 0.4.6 because of the packaging bug(s) described below.

The attached mini recipe provides four test cases to illustrate how directory symlinks are improperly handled. Two test cases show generic failures, one test case show a failure provoked if rpm 4 is used, and one test case shows a work around that is possible, but totally non-obvious.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63545</commentid>
    <comment_count>1</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2016-06-30 19:45:32 +0000</bug_when>
    <thetext>Thank you for the easily reproducible test cases. I tested it quickly and it seems that populate_packages() is not handling directory symlinks coherently. Test cases #1 and #2 are valid and they fail with ipkg, too. However, we do not really support rpm4 anymore so testcase #3 won&apos;t probably get fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63564</commentid>
    <comment_count>2</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2016-07-01 07:35:07 +0000</bug_when>
    <thetext>Hmm, taking a closer look I&apos;m not entirely sure about this. Suppose you have a directory structure like this:
    var
    ├── foo
    │   └── bar
    │       └── file
    └── symlink -&gt; foo/bar/

Looking at your test cases
#1: FILES_{PN} = &quot;var/ var/foo var/foo/bar var/symlink var/symlink/file&quot;
#2: FILES_{PN} = &quot;var/ var/symlink var/symlink/file&quot;

all the files after &quot;var/&quot; are redundant because they&apos;re already included by it. Basically, I think it shouldn&apos;t fail just because you&apos;re referencing files twice. But, I think the problem here is listing files under symlinked directories in the first place. The ordering of FILES_{PN} becomes significant.
What if you defined
FILES_{PN} = &quot;var/symlink/file var/&quot;
or just
FILES_{PN} = &quot;var/symlink/file&quot;

Looking at package.bbclass it looks like it would probably require significant changes to make all the symlink corner cases work perfectly. To be honest, I&apos;m not sure it is worth jumping through hoops and risking breaking something else for this.

What we could do, for example, would be to detect files under symlinked directories that were listed in FILES_{PN}, &quot;truncate&quot; it&apos;s path to the symlink directory and print a warning that the user should use real paths instead of symlinks. For example, &quot;var/symlink/file&quot; would be truncated to &quot;var/symlink&quot;.

What do you think?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63565</commentid>
    <comment_count>3</comment_count>
    <who name="Heinz Wrobel">Heinz.Wrobel</who>
    <bug_when>2016-07-01 07:58:22 +0000</bug_when>
    <thetext>Key thing is to eliminate the obscure, seemingly non-deterministic behavior.

Yes, if populate_packages() would check all file specs to see if any mid-path components are dir symlinks, I would write up your approach as follows:

File specs with mid-path dir symlinks could either be truncated with clear warning that the recipe X needs to be fixed, or simple rejected with an error. In essence, if a dir symlink is used, it must be the last path component only, and any other use must be clearly flagged as being a bad idea, explaining that dir symlinks may only be at the end of any path.
Net result would be that any recipe would have to specify real paths only.

A concern that I have is what this means for existing recipes. If a recipe uses &quot;{localstatedir}log&quot;, how should it know that a distro doesn&apos;t really provide that path but &quot;{localstatedir}volatile/log&quot; in reality?
In other words, how would a recipe deal with symlinks beyond its control or provided by means outside the .bb file?

Would sorting the paths to ensure all dir symlinks resolve properly help?

Again, I am concerned about side effects, but I don&apos;t know enough to understand all relationships here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63570</commentid>
    <comment_count>4</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2016-07-01 10:54:30 +0000</bug_when>
    <thetext>I quickly wrote a patch that should actually handle all cases. It is not very beautiful but shouldn&apos;t break anything. Please see:
http://git.openembedded.org/openembedded-core-contrib/commit/?h=marquiz/fixes&amp;id=39fe51eaead3d5b12e9c2539c02e0b086a8ee0c7

As you mentioned, a warning about dir symlinks might be a good addition.

Any comments?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64867</commentid>
    <comment_count>5</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2016-08-04 10:25:17 +0000</bug_when>
    <thetext>Patchset sent for review:
https://patchwork.openembedded.org/series/1127/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65054</commentid>
    <comment_count>6</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2016-08-11 06:27:17 +0000</bug_when>
    <thetext>Fixed in master:
http://git.openembedded.org/openembedded-core/commit/?id=29d1738329ddf4e63844a9ad1158a1d41e2ee343
http://git.openembedded.org/openembedded-core/commit/?id=27b285bd641d62f65154e6deec5146c0c8bb1458</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>3252</attachid>
            <date>2016-06-27 06:44:34 +0000</date>
            <delta_ts>2016-06-27 06:44:34 +0000</delta_ts>
            <desc>Simple recipe with package.bbclass symlink bug test cases</desc>
            <filename>bugtestrpmsymlink.tgz</filename>
            <type>application/x-gzip-compressed</type>
            <size>1759</size>
            <attacher name="Heinz Wrobel">Heinz.Wrobel</attacher>
            
              <data encoding="base64">H4sIAL3JcFcAA+1Y224bNxD1s76CVQI0QWXdJTsp0iJwklaInQS2UyNPBrXLlVivlluSa0Uw/O89
w73q4hhpjaZFd2BA9i7nkHPmzHDkaTKzwlgdL8xqEcroqrP34NaFHRyM0s/x+mdme73+wWAw6o/6
g/Fetzfodwd7bPTwR9m2xFiuGdvTg2fY/e51973/j9p0K//058PuQQkej4dfyP9oI//DHiTBug97
jN32P88/ZbvxrQ9R2zezrfpvT6cPvcc99X8w6h64+h/2BsPhYEj9f9Qb1/X/T9jZx5OTl6ef2AvW
PIcOWKA0s3PBIIi20jOWqYLJyFOLmFs5laG0q2bjeHL0+t3Za3L85cPxfr/d/cE9vHwzOX59dnn0
61tAs59/xvtAhuJ5p/P45uj9ycn7d5eZ6+WryeltJ3P+ceGPXhx2e8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dULnNeYxriS7G
Muf0HGRndU3p2vBtlVlzWaS+6SthwP424668s5ad+eBScyVLVQ66F0oXkRqSa1nteSSuT+QaRcSV
KSTlyd262WVLt6XFsl21MEnXC6dzAE/RcQ31cgCtVIL8c0+kLS+h0AuMyoWJz9ZalvDA3c9MJxFE
qK8KsSotZ9Q1S1qykaGsQ7pWshiElwoyjzTQalGGtyuc8zW/CFNFmPbZ6gZzuiYLysrCMq4lYHZr
s5fMS7S7P2lkGLZouguTYuAYtnu9dh+TgYxjelbhNptF3KiUTV0IKQypSzl+Nio9nccK90lAtDvi
XD4cG3SGEeV5bZJpuRInaKJ4J4RbkAEM1wHyMcihuForEX4ToCmZhat2456S/8JlcEeZDzfKPJXH
mnqoL7vCoD6eXaq5BKYioOqo9uRqT6AW4Bq8Qrfb7BjogOjPFtn3W26DAoJK05WtSQk1ieeJsv1X
QSpVtyWgHbUHKWEWLctjCakrV7501uI6nqH+Kw1Hq2Q2r+7cIkc31fqup9MldEe33hoNLua0zBZk
t/KZYnotVWLQkqyyaQdV0X72tDxMellGSi+QFjef07BellPxNWHOr0U2TdM+lYmJa3cv/o1Zoxyw
dukMEvPVJToohXHpOriP7yU3jWx/9ijVGn7csJX36Owa95PFYpV9acH5IQDcE26OrwDQQmlMgoxe
iDRWvjlCuFrL0kLSKdtyBShW+DKU3fnuaqm0r0axLguG7fuI+NXtncR8tQPxVTgJb15MqD/d6+YS
UPiGEds3AduY+XZA0Ia39X/Qaqutttpqq6222mqrrbbaaquttn+v/Ql7bccYACgAAA==
</data>

          </attachment>
      

    </bug>

</bugzilla>