Opened 13 years ago

Closed 12 years ago

#11759 closed defect (fixed)

BUG: case-sensitive port uninstall

Reported by: yunzheng.hu@… Owned by: kballard (Lily Ballard)
Priority: High Milestone: MacPorts 1.7.0
Component: base Version:
Keywords: port uninstall case-sensitive Cc: jmpp@…, ryandesign (Ryan Schmidt), jmroot (Joshua Root), raimue (Rainer Müller), pguyot (Paul Guyot)
Port:

Description

Port does not uninstall a port correctly when there is case sensitivity involved.

For example. 1) the port is installed as 'MyPort'. (notice the case) 2) you try to uninstall the port with 'port uninstall myport' (notice the all lower case) 3) it says it is uninstalled. but it actually is not. 4) you try to reinstall the port with 'port install MyPort' but this fails, because binaries are still there.

I attached a example Port, it is actually the 'bwm-ng' port (simple program) but named as 'MyPort' Run the steps above to reproduce.

Attachments (3)

Portfile (672 bytes) - added by yunzheng.hu@… 13 years ago.
example Portfile of MyPort
patch-macports-case-sensitive-uninstall.diff (483 bytes) - added by raimue (Rainer Müller) 12 years ago.
case_fixes.diff (13.4 KB) - added by jmroot (Joshua Root) 12 years ago.
a more comprehensive case-preservation patch

Download all attachments as: .zip

Change History (22)

Changed 13 years ago by yunzheng.hu@…

Attachment: Portfile added

example Portfile of MyPort

comment:1 Changed 13 years ago by yunzheng.hu@…

correctly formatted steps:

  • 1) the port is installed as 'MyPort'. (notice the case)
  • 2) you try to uninstall the port with 'port uninstall myport' (notice the all lower case)
  • 3) it says it is uninstalled. but it actually is not.
  • 4) you try to reinstall the port with 'port install MyPort' but this fails, because binaries are still there.

comment:2 Changed 13 years ago by jmpp@…

Priority: BlockerImportant

Is every single file installed by the port left behind when uninstall is called on it with a non-matching case? I'm figuring there's a problem at the registry level here.

In any case, we should probably not ignore case when querying installed ports, since we do take casing into consideration as an integral part of the port name when installing it. Any thoughts from base hackers?

-jmpp

comment:3 Changed 13 years ago by ryandesign (Ryan Schmidt)

Cc: jmpp@… ryandesign@… added

I am not a base hacker but I will comment anyway.

Yes, every single file is still there. A new MacPorts user reported this problem to me today in reference to the ImageMagick port.

As a Mac user, I expect things to work case-insensitively. But if you say case is an integral part of MacPorts at many levels, then it's probably easier to just enforce the case sensitivity at the port uninstall command (and wherever else it's currently not enforced). Then sudo port uninstall myport should output the message Error: port uninstall failed: Registry error: myport not registered as installed just like it does for any other port that is not installed. If we wanted to be really nice, we could then do a case-insensitive comparison with installed ports, and print an additional message if we find a match: Did you mean to type "port uninstall MyPort"? Same goes for port install, port info, etc.

comment:4 Changed 13 years ago by kballard (Lily Ballard)

Cc: eridius@… added
Owner: changed from macports-dev@… to eridius@…
Status: newassigned

Bug #12107 is a duplicate of this, but with some good info.

comment:5 Changed 13 years ago by jmpp@…

Milestone: Needs developer reviewMacPorts base bugs

Milestone Needs developer review deleted

comment:6 Changed 13 years ago by nox@…

Priority: ImportantHigh
Version: 1.4

Changed 12 years ago by raimue (Rainer Müller)

comment:7 Changed 12 years ago by raimue (Rainer Müller)

Added patch file with a proposed fix. I don't know if this is the right place to fix this, as now all accesses by [filemap list] will be case-insensitive. At the moment we allow to install both "MyPort" and "myport" at the same time without complaining, so this might really lead to problems. Or this should also be fixed.

Some more comments: The problem is not the uninstall phase, but deactivate (that is in registry1.0/portimage.tcl). Deactivate tries to find the files using this command, where $name is exactly what you typed in on the command line.

set imagefiles [registry::port_registered $name]

With this I followed the code path until I found the compare in the filemap itself as the first possible location to fix this.

comment:8 Changed 12 years ago by raimue (Rainer Müller)

Added a simple testcase in r34190.

comment:9 Changed 12 years ago by jmroot (Joshua Root)

Milestone: MacPorts base bugsMacPorts 1.6.1

I think we should aim to get this resolved for the next release.

Changed 12 years ago by jmroot (Joshua Root)

Attachment: case_fixes.diff added

a more comprehensive case-preservation patch

comment:10 Changed 12 years ago by jmroot (Joshua Root)

Cc: jmr@… raimue@… added; yunzheng.hu@… eridius@… removed

Attached a new patch which I think is the right way to fix this. The most important part is that registry::installed now always returns the port name with canonical case. This alone would fix the deactivation bug. The rest of the patch is making sure that correctly-cased port names are used in a bunch of places where previously it could have been whatever the user typed in.

comment:11 Changed 12 years ago by raimue (Rainer Müller)

Your patch looks much better!

With this patch applied, the testcase in trunk/base/tests/test/case-insensitive-deactivate passes.

comment:12 Changed 12 years ago by jmroot (Joshua Root)

Committed to trunk in r37349, now that I've tested that upgrade still works properly.

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

Cc: pguyot@… added

I think that raimue's patch should actually be applied as well. The flat-file registry prevents us from having ports with names that differ only in case when running on a case-insensitive filesystem (even if we considered allowing them a good idea). My patch extends that restriction to case-sensitive filesystems. I made sure to use the canonical name whenever possible, but it's pretty easy to end up using the name as entered by the user, so it could easily happen in future code, breaking things again. We should therefore make the filemap treat port names case-insensitively as well.

Of course, my reasoning falls down if the filemap code is used for anything other than associating file paths with port names. Is it?

comment:14 Changed 12 years ago by pguyot (Paul Guyot)

I believe it's not. It's used for registry1.0 (to store the path/port mapping of every file in the system) and in the trace code (as a path/port mapping temporarily used during build).

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

Thanks Paul. Committed the filemap change in r37621.

comment:16 Changed 12 years ago by ryandesign (Ryan Schmidt)

What remains to be done to resolve this bug? Has the ChangeLog been updated?

comment:17 Changed 12 years ago by jmroot (Joshua Root)

The bug is completely fixed in trunk AFAICT. Looks like I did forget to update the ChangeLog though.

I've left tickets targeted at 1.6.1 open when the fixes are not yet in the 1.6 branch. If we decide to skip 1.6.1 and branch the next release off from current trunk, this can be closed.

comment:18 Changed 12 years ago by jmroot (Joshua Root)

Updated ChangeLog in r38332.

comment:19 Changed 12 years ago by raimue (Rainer Müller)

Resolution: fixed
Status: assignedclosed

Marking fixed.

Note: See TracTickets for help on using tickets.