Suggested port command enhancement?

Ryan Schmidt ryandesign at macports.org
Tue Jun 3 15:50:00 PDT 2008


On Jun 3, 2008, at 06:30, Tabitha McNerney wrote:

> As seen in some recent threads, I think I have mentioned that I'm  
> building a system that audits and keeps track of MacPorts on some  
> Xserves that I work on. The port command, as Rainer, et al is quite  
> flexible and can be used to source a lot of information.
>
> But I believe I have identified a nice future feature of the port  
> command. What I would like to do is conduct an audit of all ports  
> that have been fetched (thus in a separate fetch phase) but not yet  
> installed. I can in fact write a parsing program that looks at:
>
> $prefix/var/macports/build
>
> which contains underscore-substituted names of directories that  
> have not yet been built, such as:
>
> _opt_local_var_macports_sources_rsync.macports.org_release_ports_textp 
> roc_scrollkeeper
>
> In a text processing language, its relatively easy to write a  
> parser that plucks the name from the above filesystem directory  
> structure, such as:
>
> scrollkeeper
>
> by chunking the name into pieces based on the underscore "_" as a  
> separator to split up the name from. However, I discovered there  
> are some ports whose names also include underscores, like this:
>
> _opt_local_var_macports_sources_rsync.macports.org_release_ports_audio 
> _libsdl_mixer
>
> Alas, the final underscore in the above example that separates  
> "lisdl" and "mixer" --> "libsdl_mixer" in fact does not map to a  
> final directory on the file system named "mixer" but rather the  
> above maps to:
>
> /opt/local/var/macports/sources/rsync.macports.org/release/ports/ 
> audio/libsdl_mixer
>
> There are ways to work with this situation of course (in my text  
> processing script I can try to map the build directory name to a  
> fully path name) but considering that some ports have underscores  
> in their names (and who knows, maybe many underscores in the  
> future?), it would be really neat if the port command in the future  
> could offer a feature to just return a list of port names who have  
> only been fetched but not installed yet. Maybe, in fact, it might  
> be nice for port to be able to audit each phase of ports all the  
> way from fetch to installed in the steps along the way?
>
> Hopefully this is an inspirational idea for advancing MacPorts?

Why do you want to identify ports that have been fetched but not built?

I myself would like to identify ports that have been fetched but not  
installed. Maybe that's the same thing you meant. I often install  
ports to verify bugs others have reported, and while I generally  
remember to uninstall them afterward, I sometimes forget to clean the  
distfiles, so I'm left with distfiles I don't need which I'd like to  
remove. This also applies to distfiles for older versions of ports I  
do still use.

With the new "port distfiles" target, I think it could be implemented  
like this:

1. Get the list of all distfiles (find /opt/local/var/macports/ 
distfiles -type f)
2. Get the list of installed ports (port installed)
3. For each installed port foo, get the list of distfiles (port  
distfiles foo) and remove them from the list of distfiles
4. All the distfiles that are left in the list at the end aren't used  
for any installed port and can be removed to save space

The one missing piece of the puzzle is the dist_subdir. Often this is  
the port name, but a port can override this. I don't know of a way to  
get the port command to tell me a port's dist_subdir.

Now that I think about it, the second missing piece is that "port  
distfiles" shows the distfiles for the current version of the port.  
It won't show you distfiles for an older version of that port you  
have installed. But that might be ok if you generally keep your ports  
up to date and don't want to install older versions.



More information about the macports-users mailing list