Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 98827 - Symlinks with non-existant targets raises Exception on Darwin/OS X
Summary: Symlinks with non-existant targets raises Exception on Darwin/OS X
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All OS X
: High normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 81010 90765 106886 108082
  Show dependency tree
 
Reported: 2005-07-12 15:16 UTC by Kito (RETIRED)
Modified: 2005-11-25 04:36 UTC (History)
0 users

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


Attachments
Replaces lchown with os.chown when target is not a symlink (98827_lchown_normal_files.patch,1.15 KB, patch)
2005-07-18 09:01 UTC, Jason Stubbs (RETIRED)
Details | Diff
Turns lchown into a no-op on Darwin (98827_darwin_noop_lchown.patch,535 bytes, patch)
2005-07-18 09:05 UTC, Jason Stubbs (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kito (RETIRED) gentoo-dev 2005-07-12 15:16:23 UTC
Darwin/OS X has no permissions for symlinks, therefore when portage attempts to lchown a symlink 
with a non-existant target (or simply the target hasn't been moved from ${D} yet) it raises Exception 
and stops the merge.

  lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])


Is the statement that fails.

No, I'm not attaching a patch yet, want to investigate a little more first, but wanted to start the bug in 
case a portage guru has a good, clean, quick fix =)


Reproducible: Always
Steps to Reproduce:
1.
2.
3.




Portage 2.0.51.22-r1 (default-darwin/macos/progressive, gcc-3.3, libsystem-7.1-r0, 8.2.0 Power 
Macintosh)
===============================================================
==
System uname: 8.2.0 Power Macintosh powerpc
Unknown Host Operating System
dev-lang/python:     2.4.1
sys-apps/sandbox:    [Not Present]
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.7.9-r1, 1.8.5-r3, 1.9.5
sys-devel/binutils:  [Not Present]
sys-devel/libtool:   [Not Present]
virtual/os-headers:  7.1
ACCEPT_KEYWORDS="ppc-macos ~ppc-macos"
AUTOCLEAN="yes"
CBUILD="powerpc-apple-darwin8"
CFLAGS="-mcpu=G4 -O3 -pipe"
CHOST="powerpc-apple-darwin8"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/
qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig buildpkg distlocks fakeroot sfperms strict userpriv"
GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://adelie.polymtl.ca/ http://distro.ibiblio.org/pub/
linux/distributions/gentoo/ http://cudlug.cudenver.edu/gentoo/"
LC_ALL=""
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="ppc bitmap-fonts dvd emboss gif jpeg ldap libwww nls pam png ppc-macos python readline 
truetype truetype-fonts type1-fonts unicode userland_Darwin kernel_Darwin elibc_Darwin"
Unset:  ASFLAGS, CTARGET, LANG, LDFLAGS, LINGUAS
Comment 1 Jason Stubbs (RETIRED) gentoo-dev 2005-07-17 19:24:17 UTC
Portage currently aliases lchown to chown on Darwin. It would make more sense 
for lchown be aliased to a noop. Does that work for you? 
Comment 2 Marius Mauch (RETIRED) gentoo-dev 2005-07-18 06:51:58 UTC
I'd be careful about aliasing to a noop. lchown isn't only used on symlinks.
Comment 3 Kito (RETIRED) gentoo-dev 2005-07-18 08:43:10 UTC
Yeah, I think Marius is correct. Ideally it would only noop if the symlink target didn't exist, that way the 
symlinlk will just inherit perms from its parent.
Comment 4 Jason Stubbs (RETIRED) gentoo-dev 2005-07-18 09:01:23 UTC
Created attachment 63710 [details, diff]
Replaces lchown with os.chown when target is not a symlink

There's two case where lchown is used and the target is never a symlink;
changed both of those to use os.chown. Then there's one case where it can be
any type of file; converted that one to an if block based on stat information
that has already been read.
Comment 5 Jason Stubbs (RETIRED) gentoo-dev 2005-07-18 09:05:06 UTC
Created attachment 63711 [details, diff]
Turns lchown into a no-op on Darwin

The problem with lchown being aliased to chown is that file merging becomes
order dependent (and portage currently relies on it being not so). That is, the
target will get the wrong permissions if the symlink has different ownership
for some reason.
Comment 6 Kito (RETIRED) gentoo-dev 2005-07-18 12:42:17 UTC
This looks good to me. thanks jstubbs.
Comment 7 Kito (RETIRED) gentoo-dev 2005-07-24 09:58:04 UTC
ok, I spoke to soon. This still doesn't solve the problem of merging a symlink with a non-existant 
target. On line ~2800 of portage.py in movefile() there is another lchown I didn't see changed in your 
patch. If you change:

  lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])

to:

  os.chown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])

this will still raise:

  except Exception, e:
                        print "!!! failed to properly create symlink:"
Comment 8 Jason Stubbs (RETIRED) gentoo-dev 2005-10-23 04:14:50 UTC
Fixed in 2.0.53