Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 182346

Summary: portage-2.1.3_rc3 removes files when moving from a directory to a symlink to that directory or vice versa
Product: Portage Development Reporter: Marien Zwart (RETIRED) <marienz>
Component: CoreAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: critical CC: ferringb, ingmar
Priority: High Keywords: InVCS, REGRESSION
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 193766, 181949    
Attachments: use device/inode numbers are used to determine ownership

Description Marien Zwart (RETIRED) gentoo-dev 2007-06-17 16:47:44 UTC
For testing the following works:

ln -s actual /tmp/sym

in testapp-1's src_install(): mkdir -p "${D}/tmp/sym"; touch "${D}/tmp/sym/file"

in testapp-2's src_install(): mkdir -p "${D}/tmp/actual"; touch "${D}/tmp/actual/file"

Now downgrading from testapp-2 to testapp-1 does:

>>> /tmp/sym/file
 * pkg_postinst testapp-1
>>> sys-apps/testapp-1 merged.

 sys-apps/testapp
    selected: 2 
   protected: 1 
     omitted: none

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

>>> Unmerging sys-apps/testapp-2...
 * pkg_prerm testapp-2
No package files given... Grabbing a set.
<<<        obj /tmp/actual/file
--- !owned dir /tmp
<<<        dir /tmp/actual

so it ends up removing the file it just installed, because it does not realise /tmp/actual/file and /tmp/sym/file are the same file (and apparently there is no mtime check). Upgrading from testapp-1 to testapp-2 has the same problem.

I'm marking this critical because you can hit this with python when upgrading from 2.4.3 to 2.4.4-r4 on amd64 with /usr/lib a symlink to /usr/lib64 or vice versa. Older pythons installed their pure-python files in /usr/lib64, newer pythons install them in /usr/lib. So when you upgrade between those versions using this version of portage, most of python gets wiped.
Comment 1 Zac Medico gentoo-dev 2007-06-17 22:18:30 UTC
Created attachment 122367 [details, diff]
use device/inode numbers are used to determine ownership

This should solve the problem.  It uses the same code that collision-protect uses to prevent false negatives when determining ownership.
Comment 2 Zac Medico gentoo-dev 2007-06-17 23:38:40 UTC
This has been released in 2.1.3_rc4.