Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 15403 - portage-2.0.46-r12 and higher does't remove all symlinks
Summary: portage-2.0.46-r12 and higher does't remove all symlinks
Status: VERIFIED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: High critical (vote)
Assignee: Nicholas Jones (RETIRED)
URL:
Whiteboard:
Keywords:
: 16080 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-02-09 20:36 UTC by Alastair Tse (RETIRED)
Modified: 2011-10-30 22:21 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
fixes problem with symlinks to files not being removed on unmerge (portage-symlink1.patch,337 bytes, patch)
2003-02-09 20:38 UTC, Alastair Tse (RETIRED)
Details | Diff
log of a merge-unmerge cycle for smpeg (smpeg-merge.log,3.84 KB, text/plain)
2003-02-10 09:21 UTC, Alastair Tse (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alastair Tse (RETIRED) gentoo-dev 2003-02-09 20:36:33 UTC
i recently emerge'd and then unmerge'd smpeg, and i noticed that portage doesn't 
remove all the symlinks properly. specifically, it showed this while unmerging:

..
<<<        obj /usr/share/aclocal/smpeg.m4
--- !destn sym /usr/lib/libsmpeg.so
<<<        obj /usr/lib/libsmpeg.la
..
<<<        obj /usr/bin/glmovie
<<<        sym /usr/lib/libsmpeg-0.4.so.0
<<<        dir /usr/share/doc/smpeg-0.4.4-r4
<<<        dir /usr/include/smpeg

And then I checked whether the symlink was really left behind:

mcvaio ~ % file /usr/lib/libsmpeg.so
/usr/lib/libsmpeg.so: broken symbolic link to libsmpeg-0.4.so.0.1.3

So I took a dive into the code and found two problems with the symlink handling. 

1. when a symlink is found to be pointing to something that is still valid
, it doesn't add it to "mysyms", hence does not get removed near the end. The 
patch attached (for portage.py) fixes this.

2. after reviewing the code, the logic suggests that portage will not remove 
symlink to directories properly. because it checks for broken symlinks BEFORE it 
removes all the directories, and doesn't do a second sweep of left over symlinks 
to see if they are still valid. If someone can confirm my observations, I'd be 
happy to make a patch for that problem as well.
Comment 1 Alastair Tse (RETIRED) gentoo-dev 2003-02-09 20:38:05 UTC
Created attachment 8111 [details, diff]
fixes problem with symlinks to files not being removed on unmerge

this is the patch for the first problem
Comment 2 Nicholas Jones (RETIRED) gentoo-dev 2003-02-10 02:18:43 UTC
This is desired behavior. If a file (symlink or regular) does not match
it's installed value, then it has been changed... The change is assumed
to be intentional by the user or portage, and thus won't be modified.
Otherwise things will break when you forceably remove their files.

The second problem is not valid as they are deleted if they match.
Comment 3 Alastair Tse (RETIRED) gentoo-dev 2003-02-10 09:19:48 UTC
Sorry to flog this bug more, but I think you might of missed some of my points 
why I think this is a bug.

I'm going to attach a log of a simple merge and unmerge cycle of 
media-libs/smpeg so you can se exactly what I mean.

Notice that the merge happens without any problems, and as you expect, it lists 
the real libs before the symlinks, eg:

>>> /usr/lib/libsmpeg-0.4.so.0.1.3
>>> /usr/lib/libsmpeg-0.4.so.0 -> libsmpeg-0.4.so.0.1.3
>>> /usr/lib/libsmpeg.so -> libsmpeg-0.4.so.0.1.3

If it was unmerged in that order, then the problem I reported wouldn't of 
happened, because the obj file in this part would have been removed before the 
symlinks were iterated in unmerge(). But notice that in the unmerge, they are 
not unmerge in that particular order:

..
<<<        obj /usr/share/aclocal/smpeg.m4
--- !destn sym /usr/lib/libsmpeg.so
<<<        obj /usr/lib/libsmpeg.la
<<<        obj /usr/lib/libsmpeg.a
<<<        obj /usr/lib/libsmpeg-0.4.so.0.1.3
<<<        obj /usr/include/smpeg/smpeg.h
<<<        obj /usr/include/smpeg/MPEGvideo.h
...

Notice that because of either the sort() not working (during unmerge()) as 
expected, or if smpeg has a weird way of naming libs, we cannot assume that the symlinks will be iterated after their target object files.

And then ultimately, I've ended up with a dangling symlink /usr/lib/libsmpeg.so:

% file /usr/lib/libsmpeg.so
/usr/lib/libsmpeg.so: broken symbolic link to libsmpeg-0.4.so.0.1.3

This might not be a serious critical portage bug (I mean its only a little symlink - I didn't mark it as critical :), but at least either the smpeg ebuild should be fixed so that the lib naming isn't funny enough to make portage fail removing the symlink.

As for the second bug, I have yet to see an ebuild with a symlinked dir, but I could try and play around to make an ebuild that has something like that.

Comment 4 Alastair Tse (RETIRED) gentoo-dev 2003-02-10 09:21:29 UTC
Created attachment 8125 [details]
log of a merge-unmerge cycle for smpeg
Comment 5 SpanKY gentoo-dev 2003-02-20 09:03:31 UTC
*** Bug 16080 has been marked as a duplicate of this bug. ***
Comment 6 SpanKY gentoo-dev 2003-02-20 09:04:11 UTC
valid points imo 
Comment 7 Klaus-J. Wolf 2003-02-20 09:47:23 UTC
Comment on #c2

The problem of non-removed symlinks exists with several packages, e.g. with blackdown-jdk:

/opt/blackdown-jdk-1.4.1/jre/plugin/i386/netscape7 -> mozilla
/opt/blackdown-jdk-1.4.1/jre/lib/i386/server/libjsig.so -> ../libjsig.so

As you can clearly see, the referenced files are part of the package; so while they are removed, their references are not.

This I'd consider a bug.
Comment 8 Martin Holzer (RETIRED) gentoo-dev 2003-02-20 12:19:33 UTC
2.0.47-r2 is stable now
Comment 9 SpanKY gentoo-dev 2003-02-20 12:24:21 UTC
true, can you guys verify that this still happens with 2.0.47-r2 ? 
Comment 10 Klaus-J. Wolf 2003-02-20 12:34:23 UTC
Yes, same problem with 2.0.47-r2 (see PR 16080).
Comment 11 Alastair Tse (RETIRED) gentoo-dev 2003-02-20 13:14:53 UTC
Yes, this still happens with portage-2.0.47-r2:

# emerge unmerge smpeg
 
 media-libs/smpeg
    selected: 0.4.4-r4
   protected: none
     omitted: none
[...]
<<<        obj /usr/share/doc/smpeg-0.4.4-r4/CHANGES.gz
<<<        obj /usr/share/aclocal/smpeg.m4
--- !destn sym /usr/lib/libsmpeg.so
<<<        obj /usr/lib/libsmpeg.la
<<<        obj /usr/lib/libsmpeg.a
<<<        obj /usr/lib/libsmpeg-0.4.so.0.1.3
[...]
<<<        obj /usr/bin/glmovie
<<<        sym /usr/lib/libsmpeg-0.4.so.0
<<<        dir /usr/share/doc/smpeg-0.4.4-r4
<<<        dir /usr/include/smpeg
[...]

# file /usr/lib/libsmpeg.so
/usr/lib/libsmpeg.so: broken symbolic link to libsmpeg-0.4.so.0.1.3

# emerge info
Portage 2.0.47-r2 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r3)
=================================================================
System uname: 2.4.19-gentoo-r10 i686 Celeron (Mendocino)

Comment 12 Nicholas Jones (RETIRED) gentoo-dev 2003-02-21 05:20:07 UTC
fixed in cvs for -r3
Comment 13 Nicholas Jones (RETIRED) gentoo-dev 2003-02-22 07:58:38 UTC
out shortly
Comment 14 Nicholas Jones (RETIRED) gentoo-dev 2003-02-22 08:26:43 UTC
out shortly
Comment 15 Alastair Tse (RETIRED) gentoo-dev 2003-02-24 18:58:51 UTC
i can verify that portage-2.0.47-r3 removes symlinks correctly. thanks!
Comment 16 Klaus-J. Wolf 2003-02-26 16:59:58 UTC
Sorry, I still have got a problem. portage-2.0.47-r4 still fails to un-install a package completely. If that corresponds to the symlink problem, I can't say.

# emerge blackdown-jdk
...
# emerge --unmerge blackdown-jdk
...
--- !empty dir /opt/blackdown-jdk-1.4.1/jre/plugin/i386
--- !empty dir /opt/blackdown-jdk-1.4.1/jre/plugin
--- !empty dir /opt/blackdown-jdk-1.4.1/jre
--- !empty dir /opt/blackdown-jdk-1.4.1
--- !empty dir /opt
--- !empty dir /etc
>>> Regenerating /etc/ld.so.cache...

 * GNU info directory index is up-to-date.

# ls -lR /opt/blackdown-jdk-1.4.1/

/opt/blackdown-jdk-1.4.1/:
total 1
drwxr-xr-x    3 root     root           72 Feb 26 22:54 jre

/opt/blackdown-jdk-1.4.1/jre:
total 1
drwxr-xr-x    3 root     root           72 Feb 26 22:53 plugin

/opt/blackdown-jdk-1.4.1/jre/plugin:
total 1
drwxr-xr-x    2 root     root           48 Feb 26 22:54 i386

/opt/blackdown-jdk-1.4.1/jre/plugin/i386:
total 0
Comment 17 Klaus-J. Wolf 2003-02-27 05:16:17 UTC
I committed comment #16 as Bug #16460.