Opened 10 years ago

Last modified 10 years ago

#44493 reopened enhancement

Support globs in port versions

Reported by: ora.et.labora@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 2.3.1
Keywords: Cc:
Port:

Description

Out of consistency reasons, I'm very much surprised to notice that the following is *not* working:

$ port echo installed and gcc\*
gcc45                          @4.5.4_6 
gcc45                          @4.5.4_8 
gcc45                          @4.5.4_9 
[..]

$ port uninstall installed and gcc45@\*
Error: No ports matched the given expression

while this works very well:

$ port uninstall installed and gcc45\*
--->  Uninstalling gcc45 @4.5.4_8
--->  Cleaning gcc45
--->  Deactivating gcc45 @4.5.4_9
--->  Cleaning gcc45
--->  Uninstalling gcc45 @4.5.4_9
--->  Cleaning gcc45

Change History (10)

comment:1 Changed 10 years ago by mf2k (Frank Schima)

Resolution: worksforme
Status: newclosed

You have typed too many characters - including an "@". Wildcards are supported. In your case you want:

port echo installed and gcc*

To uninstall all installed gcc ports type:

sudo port uninstall gcc*

comment:2 Changed 10 years ago by mf2k (Frank Schima)

Also, this format is what I use:

port installed gcc*

comment:3 in reply to:  1 ; Changed 10 years ago by ora.et.labora@…

Replying to mf2k@…:

You have typed too many characters - including an "@". Wildcards are supported. In your case you want:

port echo installed and gcc*

No, I haven't typed to many characters. I repeat myself, it is for consistency reasons. See, it is for example possible to install a particular version of a port. Here I'm taking port "gcc" as an example, it is however not "gcc" related. So, I can do this:

$ port install gcc@4.5.4_8  

Later on, I would like to remove all 4.5.4 versions hanging around, so my target is to be able to express this like

$ port uninstall gcc@4.5.4\*

I'm not familiar at the moment how you, the MacPorts community, name something like "gcc@4.5.4_8". Let's agree for the sake of discussion that "gcc@4.5.4_8" is the canonical port name, that "gcc" is the port's base-name, that "4.5.4_8" is the version part and that "@" is the separator terminal character.

The above "uninstall" command does not work as expected, cause the wildcard is only supported on the base-name of the port name and *not* supported on the version part.

My request for enhancement is about to support wildcards on the complete port name.


To uninstall all installed gcc ports type:

True, but you missed the point: it is not about uninstalling *all* ports but very selectively uninstalling ports!

comment:4 in reply to:  2 ; Changed 10 years ago by ora.et.labora@…

Replying to mf2k@…:

Also, this format is what I use:

port installed gcc*

You probably meant

port _some_action_ installed gcc*

while I wrote

$ port uninstall installed and gcc45\*

I used the "$" sign to indicate that the command can be typed like this into the (shell) terminal.

Further, I used and expressis verbis to combine the two boolean expressions installed and gcc45*. I have no clue my those logical operators are not mentioned in the guide, man port seems to be the authorative source by now.

comment:5 in reply to:  4 ; Changed 10 years ago by mf2k (Frank Schima)

Replying to ora.et.labora@…:

port install gcc@4.5.4_8

Versions cannot be used with the install command. Macports only installs the latest version of any port.

Replying to mf2k@…:

Also, this format is what I use:

port installed gcc*

You probably meant

port _some_action_ installed gcc*

No, I meant what I typed.

while I wrote

$ port uninstall installed and gcc45\*

I used the "$" sign to indicate that the command can be typed like this into the (shell) terminal.

Further, I used and expressis verbis to combine the two boolean expressions installed and gcc45*. I have no clue my those logical operators are not mentioned in the guide, man port seems to be the authorative source by now.

This makes no sense to me. You can only uninstall installed ports. One would never type port uninstall installed and anything. In your sample code, simply type:

port uninstall gcc45*

That will uninstall all installed versions of gcc45.

To address your request. You are correct that wildcards cannot be used on specific versions. Honestly, that hardly seems useful. One can always uninstall singular versions by typing the complete name as reported by the port installed command e.g.

port uninstall gcc45 @4.5.4_8 

or all versions as I specified above. I'm not seeing In what situation your request is useful?

comment:6 Changed 10 years ago by mf2k (Frank Schima)

Resolution: worksforme
Status: closedreopened

All that said. I will re-open the ticket should another committer want to take this on.

Last edited 10 years ago by mf2k (Frank Schima) (previous) (diff)

comment:7 Changed 10 years ago by ora.et.labora@…

This makes no sense to me. You can only uninstall installed ports. One would never type port uninstall installed and anything. In your sample code, simply type:

Sorry to disagree, but it makes very much sense to me: I working nowadays a lot with the echo action. For example, to see which versions of gcc are installed, I'm typing:

$ port echo installed and gcc\*

Then I'm starting to refine the select expression to narrow down what I'm really interested in:

$ port echo installed and gcc4\*

Eventually, when happy with my selection, I only exchange the action to that what I really want to do. In my example above, I just used uninstall as example action. It could be any other action as well, i.e.

$ port dependents installed and gcc4\*

I hope that you finally agree that uninstall installed and .. makes sense.

Btw, I regard port installed as just another shortcut for port echo installed where I clearly prefer the second variant due to its "subject verb object" structure. While it makes non sense to remove action "installed", it would be good to mark this action as "deprecated".


Honestly, that hardly seems useful. One can always uninstall singular versions by typing the complete name as reported by the port installed command e.g.

Please re-think this argument again for one moment and please elaborate why wildcards have been introduced?

comment:8 Changed 10 years ago by ora.et.labora@…

Nevertheless, thanks for keeping this enhancement request open. Perhaps I can myself come up with a patch demonstrating this enhancement.

comment:9 in reply to:  3 Changed 10 years ago by larryv (Lawrence Velázquez)

Summary: Support wildcard on versionsSupport globs in port versions

Your point about consistency is taken, but MacPorts is not really designed to work with different versions of ports. For instance…

Replying to ora.et.labora@…:

Here I'm taking port "gcc" as an example, it is however not "gcc" related. So, I can do this:

$ port install gcc@4.5.4_8

…this does not work in the general case. It might work for activating an inactive port gcc@4.5.4_8 (I have not tried it because I use port activate for this purpose), but if such a port is not present, you will get the latest version of gcc.

Supporting wildcards in versions would work rather differently than the way wildcards currently work. I believe a glob is internally transformed into a list of matching portnames before the action is executed; the expansion is done using the port index and does not consider any installed ports. Globbing on the version string would have to consult the registry.

The relevant code is in port.tcl, although one could make the argument that globs should be handled by macports.tcl.

comment:10 in reply to:  5 Changed 10 years ago by larryv (Lawrence Velázquez)

Replying to mf2k@…:

This makes no sense to me. You can only uninstall installed ports. One would never type port uninstall installed and anything. In your sample code, simply type:

port uninstall gcc45*

That will uninstall all installed versions of gcc45.

This wouldn’t work. That command would expand to port uninstall gcc45 (since there is only one port name that matches that glob) and would throw an error if there were more than one gcc45 installed. The installed and FOO expression is necessary because only the installed pseudo-portname breaks out the separate installed ports:

% sudo port uninstall scala2.11
--->  The following versions of scala2.11 are currently installed:
--->      scala2.11 @2.11.1_0
--->      scala2.11 @2.11.2_0 (active)
Error: port uninstall failed: Registry error: Please specify the full version as recorded in the port registry.
% sudo port uninstall installed and scala2.11
--->  Uninstalling scala2.11 @2.11.1_0
--->  Cleaning scala2.11
--->  Deactivating scala2.11 @2.11.2_0
--->  Cleaning scala2.11
--->  Uninstalling scala2.11 @2.11.2_0
--->  Cleaning scala2.11
%
Note: See TracTickets for help on using tickets.