On 04/15/10 01:14 PM, Danek Duvall wrote:
Shawn Walker wrote:
On 04/14/10 04:44 PM, Danek Duvall wrote:
Shawn Walker wrote:
http://cr.opensolaris.org/~swalker/pkg-529-2/
generic.py:
- line 863: fsobj_checkpath() doesn't appear to be called in any
removal contexts, though if it were, the error on line 871 woudln't
be appropriate.
I wasn't sure that we wanted/needed to do that.
So in what contexts would "not destination_fmri" be true?
That was probably a leftover from similar logic I have in another place;
I've removed it.
- line 866: is there any way we can run into the usual problem with
os.path.commonprefix(), in that it doesn't actually act on path
components, but characters?
I don't anticipate it, was there a specific scenario you envisioned?
Let's say that final_path is /usr/share/foo/thing.html. And let's say that
/usr/share/foo is a symlink to ../shopping/foo. Then parent_path is
/usr/share/foo, and real_parent_path is /usr/shopping/foo. Because of the
behavior of commonprefix(), cmn_path is /usr/sh, which doesn't exist, so
the join on line 868 doesn't make much sense.
Even if it did the right thing, it doesn't make sense anyway, since in
that case '/tmp/' would be the common prefix so the join would produce
'/tmp/foo' which obviously isn't right either.
However, I think this will work intead:
parent_path = os.path.dirname(final_path)
real_parent_path = os.path.realpath(parent_path)
if parent_path != real_parent_path:
# Now test each component of the parent path until one is found
# to be a link. When found, that's the parent that has been
# redirected to some other location.
tmp = parent_path
while 1:
if os.path.islink(tmp):
# We've found the parent that changed locations.
break
# Drop the final component.
tmp = os.path.split(tmp)[0]
parent_dir = tmp
parent_target = os.path.realpath(parent_dir)
print ("Cannot install '%(final_path)s'; parent "
"directory %(parent_dir)s is a link to "
"%(parent_target)s. To continue, move the "
"directory to its original location and try "
"again.") % locals()
$ test.py
Cannot install '/tmp/share/foo/thing.html'; parent directory
/tmp/share/foo is a link to /tmp/shopping/foo. To continue, move the
directory to its original location and try again.
Cheers,
-Shawn
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss