New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #11759 (closed defect: fixed)

Opened 6 years ago

Last modified 5 years ago

BUG: case-sensitive port uninstall

Reported by: yunzheng.hu@… Owned by: eridius@…
Priority: High Milestone: MacPorts 1.7.0
Component: base Version:
Keywords: port uninstall case-sensitive Cc: jmpp@…, ryandesign@…, jmr@…, raimue@…, pguyot@…
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

Portfile (672 bytes) - added by yunzheng.hu@… 6 years ago.
example Portfile of MyPort
patch-macports-case-sensitive-uninstall.diff (483 bytes) - added by raimue@… 5 years ago.
case_fixes.diff (13.4 KB) - added by jmr@… 5 years ago.
a more comprehensive case-preservation patch

Change History

Changed 6 years ago by yunzheng.hu@…

example Portfile of MyPort

comment:1 Changed 6 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 6 years ago by jmpp@…

  • Priority changed from Blocker to Important

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 6 years ago by ryandesign@…

  • 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 6 years ago by eridius@…

  • Cc eridius@… added
  • Status changed from new to assigned
  • Owner changed from macports-dev@… to eridius@…

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

comment:5 Changed 6 years ago by jmpp@…

  • Milestone changed from Needs developer review to MacPorts base bugs

Milestone Needs developer review deleted

comment:6 Changed 6 years ago by nox@…

  • Priority changed from Important to High
  • Version 1.4 deleted

Changed 5 years ago by raimue@…

comment:7 Changed 5 years ago by raimue@…

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 5 years ago by raimue@…

Added a simple testcase in r34190.

comment:9 Changed 5 years ago by jmr@…

  • Milestone changed from MacPorts base bugs to MacPorts 1.6.1

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

Changed 5 years ago by jmr@…

a more comprehensive case-preservation patch

comment:10 Changed 5 years ago by jmr@…

  • 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 5 years ago by raimue@…

Your patch looks much better!

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

comment:12 Changed 5 years ago by jmr@…

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

comment:13 Changed 5 years ago by jmr@…

  • 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 5 years ago by pguyot@…

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 5 years ago by jmr@…

Thanks Paul. Committed the filemap change in r37621.

comment:16 Changed 5 years ago by ryandesign@…

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

comment:17 Changed 5 years ago by jmr@…

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 5 years ago by jmr@…

Updated ChangeLog in r38332.

comment:19 Changed 5 years ago by raimue@…

  • Status changed from assigned to closed
  • Resolution set to fixed

Marking fixed.

Note: See TracTickets for help on using tickets.