Opened 15 years ago

Closed 15 years ago

#21082 closed defect (fixed)

MacPorts 1.8.0 deletes ${prefix} if it is a symlink

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts 1.8.1
Component: base Version: 1.8.0
Keywords: Cc: merlyn@…, anddam (Andrea D'Amore), alakazam@…, dh@…, blb@…, mike@…, ketanpadegaonkar+macports@…, jmroot (Joshua Root)
Port:

Description

If you install MacPorts 1.8.0 in a certain prefix, say /a, and then move it some place else, say /b, and make a symlink at /a pointing to /b, then "port install" works ok, but "port deactivate" and "port uninstall" will both remove the symlink at /a, thus breaking the installation. This did not happen with 1.7.1. This bug was reported on the mailing list by Randal L. Schwartz.

Attached is a script I wrote to test for the problem. It will download MacPorts base trunk to /tmp/mpbase, download the portindex and zlib portfile to /tmp/mpdports, and compile MacPorts and install it in the prefix /tmp/mpone. It will move /tmp/mpone to /tmp/mptwo and create a symlink at /tmp/mpone pointing to /tmp/mptwo. It will install zlib, downloading the zlib distfile in /tmp/mpdistfiles, and then deactivate zlib. It will state whether /tmp/mpone still exists, and then delete /tmp/mpone and /tmp/mptwo.

As an argument to the script, you can specify the revision of trunk you want to test. Testing on Leopard I get:

$ sudo ./symlinkbug.sh 55000
[snip]
Bug present in base rev 55000: /tmp/mpone is gone
$ sudo ./symlinkbug.sh 50000
[snip]
Bug absent in base rev 50000: /tmp/mpone exists
$

Now we just need to do some bisecting and figure out which revision between 50000 and 55000 caused the problem. I suggest first looking at the revision that merged in the GSoC '08 privileges code, and the revisions that changed from calling system executables to calling Tcl functions.

Attachments (3)

symlinkbug.sh (1.8 KB) - added by ryandesign (Ryan Carsten Schmidt) 15 years ago.
patch-port-symlinks.diff (1.3 KB) - added by dbevans (David B. Evans) 15 years ago.
Rough patch
bug_absent.log (3.8 KB) - added by jmroot (Joshua Root) 15 years ago.
behaviour on 10.6

Download all attachments as: .zip

Change History (29)

Changed 15 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: symlinkbug.sh added

comment:1 Changed 15 years ago by ryandesign (Ryan Carsten Schmidt)

This isn't quite right yet: my test was tainted by the fact I chose to put things in /tmp, which is itself a symlink. Running the test script can cause /tmp to be deleted. Please wait until I have fixed the script.

Changed 15 years ago by dbevans (David B. Evans)

Attachment: patch-port-symlinks.diff added

Rough patch

comment:2 Changed 15 years ago by dbevans (David B. Evans)

I have had the same problem on my system. I was running out of disk space on my main disk so moved /opt/local to a second disk with a link link this

/opt/local  -> /Volumes/disk2/opt/local

Note that any symlink that appears in the 'directory' portion of a path that is being deactivated or uninstalled will be deleted.

Attached is a patch that fixes the problem for me although someone who knows more about MacPorts could probably do it better.

comment:3 Changed 15 years ago by jmroot (Joshua Root)

See also #13707.

comment:4 Changed 15 years ago by anddam (Andrea D'Amore)

Cc: and.damore@… added

Cc Me!

comment:5 Changed 15 years ago by alakazam@…

Cc: alakazam@… added

Cc Me!

Changed 15 years ago by jmroot (Joshua Root)

Attachment: bug_absent.log added

behaviour on 10.6

comment:6 Changed 15 years ago by jmroot (Joshua Root)

The script tells me that the bug is absent in trunk on my 10.6 system. Output attached. Can someone attach debug output from an affected system?

comment:7 Changed 15 years ago by ryandesign (Ryan Carsten Schmidt)

If you ran the script as is, please check whether it has deleted your /tmp symlink and recreated a directory /tmp. If so, delete the directory /tmp and replace it with a symlink to /private/tmp. I will try to attach a revised script that does not use /tmp.

comment:8 Changed 15 years ago by dh@…

Cc: dh@… added

Cc Me!

comment:9 Changed 15 years ago by ryandesign (Ryan Carsten Schmidt)

Has duplicate #21297.

comment:10 Changed 15 years ago by blb@…

Cc: blb@… added

comment:11 in reply to:  7 Changed 15 years ago by jmroot (Joshua Root)

Replying to ryandesign@…:

If you ran the script as is, please check whether it has deleted your /tmp symlink and recreated a directory /tmp.

Nope, /tmp is still fine.

comment:12 Changed 15 years ago by dh@…

Here is the decision to destroy /opt revealed in the -d output ...

DEBUG: /opt/local/bin is not empty
DEBUG: /opt/local is not empty
DEBUG: deactivating link: /opt
DEBUG: / is not empty

comment:13 Changed 15 years ago by jmroot (Joshua Root)

So apparently file normalize is broken on the affected systems. Interestingly, it works correctly even in tclsh8.4 on 10.6. So r49347 is probably where the regression appeared. Unfortunately compat filenormalize was broken in other ways.

comment:14 in reply to:  13 ; Changed 15 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jmr@…:

Interestingly, it works correctly even in tclsh8.4 on 10.6.

All my testing has been on 10.6, where I was able to observe the issue.

comment:15 in reply to:  14 Changed 15 years ago by jmroot (Joshua Root)

Replying to ryandesign@…:

All my testing has been on 10.6, where I was able to observe the issue.

Well, I'm unable to explain that. The behaviour I'm seeing is exactly consistent with a bug that was fixed in Tcl 8.4.10 or so (Leopard and Tiger ship with 8.4.7). In any case, the changes in r57436 and r57441 seem to fix this on Leopard.

comment:16 Changed 15 years ago by jmroot (Joshua Root)

Would anyone care to confirm or deny the effectiveness of the attempted fix?

comment:17 Changed 15 years ago by mike@…

Cc: mike@… added

Cc Me!

comment:18 Changed 15 years ago by mike@…

Have not tested patch, but can confirm bug exhibited if macports is installed in $HOME, /Users is a symlink, OS X 10.5, MacPorts 1.8.0 and tclsh 8.4.

e.g. of buggy behaviour:

$ port uninstall bzip2
--->  Deactivating bzip2 @1.0.5_2+darwin
Error: port uninstall failed: error deleting "/Users": permission denied

comment:19 Changed 15 years ago by ketanpadegaonkar+macports@…

Cc: ketanpadegaonkar+macports@… added

Cc Me!

comment:20 in reply to:  2 ; Changed 15 years ago by ketanpadegaonkar+macports@…

Replying to devans@…:

Attached is a patch that fixes the problem for me although someone who knows more about MacPorts could probably do it better.

I've patched my copy of macports with the patch. This patch has worked fine for me, so a +1 if that helps move this ahead.

comment:21 in reply to:  20 ; Changed 15 years ago by jmroot (Joshua Root)

Replying to ketanpadegaonkar+macports@…:

I've patched my copy of macports with the patch. This patch has worked fine for me, so a +1 if that helps move this ahead.

The patch attached to this ticket or the one I committed to trunk?

comment:22 Changed 15 years ago by jmroot (Joshua Root)

Cc: jmr@… added

comment:23 in reply to:  21 Changed 15 years ago by ketanpadegaonkar+macports@…

Replying to jmr@…:

The patch attached to this ticket or the one I committed to trunk?

I've used the the patch attached to this ticket. I did not want to compile the change sets that were checked in into svn.

comment:24 Changed 15 years ago by jmroot (Joshua Root)

Back to waiting for someone to test it then...

comment:25 Changed 15 years ago by alakazam@…

Trunk no longer removes my symlinks (I'm using one to version /opt/local/etc, and it hasn't been reset for a couple of days now).

comment:26 Changed 15 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.