<?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>13574</bug_id>
          
          <creation_ts>2019-10-04 19:39:03 +0000</creation_ts>
          <short_desc>Package installation fails if target directory is a symlink</short_desc>
          <delta_ts>2019-12-06 15:58:20 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Yocto Project Subprojects</classification>
          <product>opkg</product>
          <component>opkg</component>
          <version>0.4.1</version>
          <rep_platform>All</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>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>0.4.2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Melanie">melanie</reporter>
          <assigned_to name="Alejandro del Castillo">alejandro.delcastillo</assigned_to>
          
          
          
          <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>85221</commentid>
    <comment_count>0</comment_count>
    <who name="Melanie">melanie</who>
    <bug_when>2019-10-04 19:39:03 +0000</bug_when>
    <thetext>Some packages fail to install with the following message:

Collected errors:
 * check_data_file_clashes: Package &lt;name&gt; wants to install directory /lib/
   But that path is currently a file

On my system, /lib is a symlink that points to /usr/lib.
It seems that opkg is not able to handle this situation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85323</commentid>
    <comment_count>1</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2019-10-11 18:22:58 +0000</bug_when>
    <thetext>I don&apos;t think package managers are suppose to follow directory symlinks
when installing files...it&apos;s my understanding that dpkg will fail in
that situation too:

(bb) adelcast@delcastillo2 ~/dpkg $ tree a_1.0
a_1.0
├── DEBIAN
│   └── control
├── myfile
└── tmp
    ├── lib
    └── lib64 -&gt; lib/

4 directories, 2 files
(bb) adelcast@delcastillo2 ~/dpkg $ tree b_1.0
b_1.0
├── DEBIAN
│   └── control
├── myfile2
└── tmp
    └── lib64
        └── otherfile

(bb) adelcast@delcastillo2 ~/dpkg $ sudo dpkg -i a_1.0.deb
Selecting previously unselected package a.
(Reading database ... 620831 files and directories currently installed.)
Preparing to unpack a_1.0.deb ...
Unpacking a (1.0) ...
Setting up a (1.0) ...
(bb) adelcast@delcastillo2 ~/dpkg $ sudo dpkg -i b_1.0.deb
Selecting previously unselected package b.
(Reading database ... 620834 files and directories currently installed.)
Preparing to unpack b_1.0.deb ...
Unpacking b (1.0) ...
dpkg: error processing archive b_1.0.deb (--install):
 trying to overwrite &apos;/tmp/lib64&apos;, which is also in package a 1.0
Errors were encountered while processing:
 b_1.0.deb

The package needs to be authored in a way that doesn&apos;t assume symlinks are going to be followed. Closing as not a bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85348</commentid>
    <comment_count>2</comment_count>
    <who name="Melanie">melanie</who>
    <bug_when>2019-10-15 16:58:40 +0000</bug_when>
    <thetext>I am reopening this issue because I believe that the error message in your example is not caused by the symlink itself but by the conflict between different packages.

The debian policy manual [1] describes the details of unpack phase of installation or upgrade and states the following:
&quot;A directory will never be replaced by a symbolic link to a directory or vice versa; instead, the existing state (symlink or not) will be left alone and dpkg will follow the symlink if there is one.&quot;

In addition there is a comment in the dpkg source code [2] with further details.

Based on all these informations I still believe that opkg should be able to handle such situations (follow symlinks) when installing debian packages.

[1] https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
[2] https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/src/unpack.c#n1340</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85462</commentid>
    <comment_count>3</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2019-10-28 21:44:42 +0000</bug_when>
    <thetext>What is not clear to me is why my example using dpkg failed? You say that the problem is not due to symlinks but to a conflict between packages...could you expand on which conflict pakcage A and B  have, on your view?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85475</commentid>
    <comment_count>4</comment_count>
    <who name="Melanie">melanie</who>
    <bug_when>2019-11-02 10:48:41 +0000</bug_when>
    <thetext>I must admit that it is not clear to me either.

The dpkg error message in your example states that Package B tries to overwrite &apos;/tmp/lib64&apos; (the symlink from Package A), but the debian policy manual clearly describes how to handle such situations (follow the symlink, do NOT overwrite it).

Did you use a dpkg version from dpkg.org or from elsewhere (i.e. BusyBox)?

Maybe it would make sense to ask the dpkg folks [1] for a statement on that topic ...



[1] https://wiki.debian.org/Teams/Dpkg</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85581</commentid>
    <comment_count>5</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2019-11-21 00:13:35 +0000</bug_when>
    <thetext>Posted on debian mailing list: https://lists.debian.org/debian-dpkg/2019/11/msg00001.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85609</commentid>
    <comment_count>6</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2019-11-22 19:37:59 +0000</bug_when>
    <thetext>The error on my example was not due to a dpkg policy, but by the symlink being followed living on tmpfs. The setting on /proc/sys/fs/protected_symlinks (1) toggles the symlink behavior on tmpfs.

Opkg then should follow symlinks at install time, and this bug is valid.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85761</commentid>
    <comment_count>7</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2019-12-06 15:58:20 +0000</bug_when>
    <thetext>Fixed on commit 445fe1b3345ae64b20807ff4c362af273cb247ed</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>