Generating a list of all installed software (or something like that).
Neil
neil at voidfx.net
Fri Dec 5 13:47:59 PST 2008
On 5 Dec 2008, at 16:31, Ryan Schmidt wrote:
> On Dec 5, 2008, at 10:41, Neil wrote:
>
>> On 5 Dec 2008, at 09:04, Tim Visher wrote:
>>
>>> On Fri, Dec 5, 2008 at 8:37 AM, Joshua Root wrote:
>>>
>>>> Mikael Gripenstedt wrote:
>>>>
>>>>> On Dec 5, 2008, at 13:16 , Tim Visher wrote:
>>>>>
>>>>>> I'd be interested in generating a complete list of all software
>>>>>> I have
>>>>>> installed through MacPorts so that I don't have to back up my
>>>>>> installation in case of a hard drive failure. Basic use case
>>>>>> would be
>>>>>> that if my disk fails, I just download MacPorts again, and then
>>>>>> run
>>>>>> this script through it and after awhile I get my exact install
>>>>>> back
>>>>>> the way I had it n-days before the crash. Any way to do this?
>>>>>>
>>>>>> This has been inspired by APTonCD's ability to generate a list of
>>>>>> everything you've installed through apt for various purposes,
>>>>>> if you
>>>>>> want to know an analogue.
>>>>>
>>>>> port list installed
>>>>>
>>>>> Will give you a list of installed software. Is this what you were
>>>>> looking for?
>>>>
>>>> You actually want 'port installed' rather than 'port list
>>>> installed',
>>>> because 'port list' shows you the version in the index, which may
>>>> not be
>>>> the same as what's installed.
>>>
>>> Wow do I feel sheepish. I can't believe I couldn't think to do that
>>> all by me'lonesome... :\
>>
>> (Almost) totally untested:
>> $ port install | sed 's/(active)$//' | sed 's/^/install/' | grep -v
>> 'The following ports are currently installed:' > my_ports.txt
>
> I'm sure you meant "port installed" as the first bit on that line.
>
>> <trash your partition, reformat, reinstall>
>> $ port -F my_ports.txt
>
> Probably prefaced by "sudo".
>
>> Break down of the first line:
>> 1. Get list of ports.
>> 2. Strip out "(active)"
>> 3. Prefix each line with "install" (so port -F knows what action to
>> do with each port)
>> 4. Remove the line at the top: 'The following ports are currently
>> installed:'
>
> Using "sed 1d" to remove the header line is shorter and allows for
> the specific message to be changed either through localization or by
> a wording change in some future version of MacPorts.
Ah, I didn't know; I actually have barely ever used sed before this
(and after this, I suppose).
>> 5. Send to file.
>>
>> Caveats:
>> 1. If you, like me, always want the most recent port installed, not
>> a specific one, then you can drop | sed 's/@[^+]*//'
>> | into the chain of seds in line 1, and that should filter out all
>> the version information (and still leave variants).
>> 2. This list contains things that were installed as dependencies.
>> If dependencies have been eliminated since you installed stuff
>> last, they'll get installed again, even though this time they're
>> not needed. MacPorts is currently working towards remedying that
>> situation.
>>
>> Personally, I just have a textfile with the ports and variants I
>> want in it.
>
> Well, there are several big problems with this method.
>
> First, MacPorts cannot install specific versions of ports, only the
> version specified in your portfiles. Any version number specified in
> your install command is totally ignored. Also you can only have one
> version of a port installed at a time. So if you had php5 @5.2.5_0,
> and then at some point you used "sudo port upgrade php5" which
> upgraded you to php5 @5.2.6_2 (and left php5 @5.2.5_0 around,
> deactivated), and now you wanted to trash your drive and reinstall
> those ports exactly, you can't, because MacPorts doesn't have a
> command to let you do that. You can only install the current version
> of php5, which as of yesterday is php5 @5.2.7_0. There are
> instructions for how to manually get back to an older version if
> that's really necessary:
>
> http://trac.macports.org/wiki/howto/InstallingOlderPort
>
> Second, if you just install ports in alphabetical order, you're
> likely to get the wrong variants of things installed, as later ports
> are installed automatically as dependencies of earlier ones. For
> example, I have the subversion port installed with the +mod_dav_svn
> and +tools variants. But subversion is a build dependency of ffmpeg.
> ffmpeg appears in the alphabetically-sorted list of ports before
> subversion. So as soon as you try to install ffmpeg (on Tiger or
> earlier, on which Apple doesn't provide the svn program), it will
> first install subversion -- with no variants selected. When you
> later come to subversion in your list of installed ports, it will be
> rebuilt with the +mod_dav_svn +tools variants but it won't be able
> to activate it because another version is already active. So what
> you really need to do is install the ports in dependency order,
> where the first ports to be installed are the ones that don't have
> any dependencies, then you install ports that depend on the ports
> you've already installed, and so on until all ports are installed.
> Basically you reinvent the entire MacPorts dependency engine.
>
Thank you for those additions. I assume you mean with the semi-
automated I proposed above, not my little by-hand list.
I do think the custom list is the way to go (that's why I use it),
though it's easy to forget to add something to the list when you run
the port install (then again, if I forget something, it's not the end
of the world, I can always reinstall it when I remember, and if I
forgot it probably wasn't that important in the first place). But I
thought I'd offer an alternative, and if you're going to make a by-
hand list, it's a good place to start, I think.
I always want the most recent, so I toss the version numbers and let
ports do its thing with them. And I follow some rough rules for how I
order items on the list: languages (eg. perl, python, ruby, etc.),
then basically everything I picked variants for, standalone programs,
and then modules (eg. py25-readline). It has worked out pretty
decently for me so far.
More information about the macports-users
mailing list