Opened 15 years ago

Closed 15 years ago

#17477 closed enhancement (fixed)

Integrate *_select tools into port

Reported by: blb@… Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts 1.8.0
Component: base Version: 1.7.0
Keywords: select Cc: lperry (Perry Lee), kngspook@…, MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), arthur@…
Port:

Description

Currently there are two *_select ports, gcc_select and python_select, and an increasing need for more (perl, ruby, others?). This would work better if they were brought into just one tool, and as Rainer points out putting them into port itself make sense.

Attachments (1)

port.tcl.diff (4.9 KB) - added by lperry (Perry Lee) 15 years ago.

Download all attachments as: .zip

Change History (14)

Changed 15 years ago by lperry (Perry Lee)

Attachment: port.tcl.diff added

comment:1 Changed 15 years ago by lperry (Perry Lee)

Cc: perry@… added

I've attached a patch that integrates some of the *_select tools' functionality in port.

The syntax is port select <module> <action> <options>, with the following actions currently available: list, set

perry@phoenix ~/src/macports-trunk/base/src/port $ sudo port select python list
Available Versions:
        none
        python25
        python25-apple
perry@phoenix ~/src/macports-trunk/base/src/port $ python
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
perry@phoenix ~/src/macports-trunk/base/src/port $ sudo port select python set python25
Selecting version python25 for python
perry@phoenix ~/src/macports-trunk/base/src/port $ python
Python 2.5.2 (r252:60911, Dec  6 2008, 18:32:57) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D

comment:2 Changed 15 years ago by raimue (Rainer Müller)

Perry, your patch looks good.

But wouldn't it make more sense to have this in port1.0 or macports1.0 in the API, e.g. for use in the MacPorts.framework if anyone ever gets back to it?

Some additional thoughts about the syntax, I would prefer:

port select [--set|--list] <group>

comment:3 Changed 15 years ago by kngspook@…

Cc: kngspook@… added

Cc Me!

comment:4 in reply to:  2 ; Changed 15 years ago by kngspook@…

Replying to raimue@…:

Some additional thoughts about the syntax, I would prefer:

port select [--set|--list] <group>

Well, that might imply/be interpreted by a lot of people that "--set" and "--list" are optional. If we go that route, then maybe some additional logic should be in place that basically states:

  • if they give only port select something, then treat it like a list command
  • if they give port select something valid-selection, then treat it like a set command
  • if they give port select something invalid-selection, then show an error stating as such and give them the list of valid picks.

comment:5 in reply to:  4 Changed 15 years ago by lperry (Perry Lee)

Replying to kngspook@…:

Replying to raimue@…:

Some additional thoughts about the syntax, I would prefer:

port select [--set|--list] <group>

Well, that might imply/be interpreted by a lot of people that "--set" and "--list" are optional. If we go that route, then maybe some additional logic should be in place that basically states:

  • if they give only port select something, then treat it like a list command
  • if they give port select something valid-selection, then treat it like a set command
  • if they give port select something invalid-selection, then show an error stating as such and give them the list of valid picks.
Both suggestions seem reasonable. "--setlist" seems more in line with the other port commands (and consistency is certainly good :)). For now, I'll implement the logic you brought up. It makes sense to me, and if users find it confusing, we can always tweak it then.

Also, I'll move the code to port1.0 -- after the discussion in IRC, it seems like that is the most reasonable place to put it (factoring in the whole reality differing from ideals ;)).

One additional command that I'm thinking of implementing is to show the currently selected version (the current *_select tools don't show this). I'll likely try to add this command after implementing the above suggestions.

comment:6 Changed 15 years ago by lperry (Perry Lee)

I've changed the syntax to "--listsetshow" and added some of the logic (e.g., if no commands are specified, port select assumes the show command is intended. The show command has not been implemented yet, but --list and --set work. You can see the changes here: http://trac.macports.org/browser/users/perry/base-select
perry@phoenix ~/src/macports-users-perry/base-select $ sudo port select
Error: port select [--list|--set|--show] [<group> [<version]]
perry@phoenix ~/src/macports-users-perry/base-select $ sudo port select python
Error: The 'show' command failed. Enable debug mode to see why.
perry@phoenix ~/src/macports-users-perry/base-select $ sudo port select --list python
Available Versions:
        base
        none
        python25
        python25-apple
perry@phoenix ~/src/macports-users-perry/base-select $ sudo port select python python25
Selecting 'python25' for 'python' succeeded. 'python25' is now active.
perry@phoenix ~/src/macports-users-perry/base-select $ sudo port select --set python python25-apple
Selecting 'python25-apple' for 'python' succeeded. 'python25-apple' is now active.
perry@phoenix ~/src/macports-users-perry/base-select $ sudo port select --set python foo
Selecting 'foo' for 'python' failed. Enable debug mode to see why.

comment:7 Changed 15 years ago by lperry (Perry Lee)

I forgot to mention that I created a proc in macports1.0 called mportselect. It returns "" on error (using ui_debug to indicate the nature of the error). The only two files that have been modified are port/port.tcl and macports1.0/macports.tcl.

comment:8 Changed 15 years ago by lperry (Perry Lee)

For the sake of completeness (mostly as a proof of concept), I've quickly implemented --show in r44056. It needs to be written ASAP (for reasons that will be obvious when you look at the code ;)).

The main problem is that the currently selected version is not logged when using a *_select tool (and of course port select). Using the current method I've implemented won't work if (1) more than one version symlinks to the same file or (2) there are no symlinks (e.g., 'none' for the 'python' group).

We should standardize how the currently selected version for each group is logged. One thought is have a symlink in the confpath that points to the currently selected version. As an example:

perry@phoenix /opt/local/etc/select/python $ ls -l
total 20
-rw-r--r-- 2 root admin 310 2008-12-16 20:34 base
-rw-r--r-- 2 root admin  24 2008-12-16 20:34 none
-rw-r--r-- 2 root admin 344 2008-12-06 18:35 python25
-rw-r--r-- 2 root admin 151 2008-12-16 20:34 python25-apple
lrwxr-xr-x 1 root admin   8 2008-12-19 23:24 selected -> python25

comment:9 Changed 15 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Cc: mcalhoun@… added

Cc Me!

comment:10 Changed 15 years ago by arthur@…

Cc: arthur@… added

Cc Me!

comment:11 Changed 15 years ago by lperry (Perry Lee)

Since my last update, I've integrated Rainer's latest changes to *_select (specifically --show now uses the 'current' symlink to determine the selected version) and added more specific error messages to port select (r44676).

After more testing, I'll likely merge the code into trunk/base since all of the essential functionality seems to be there now.

comment:12 Changed 15 years ago by lperry (Perry Lee)

Merged into trunk/base in r44693.

For now I'll leave this ticket open for feedback. If it ends up being inactive for some time, I'll go ahead and close it, assuming all is well ;).

comment:13 Changed 15 years ago by lperry (Perry Lee)

Resolution: fixed
Status: newclosed

Closing.

Note: See TracTickets for help on using tickets.