Generating a list of all installed software (or something like that).

Neil neil at voidfx.net
Fri Dec 5 08:41:17 PST 2008


On 5 Dec 2008, at 09:04, Tim Visher wrote:

> On Fri, Dec 5, 2008 at 8:37 AM, Joshua Root <jmr at macports.org> wrote:
>> Mikael Gripenstedt wrote:
>>> On Dec 5, 2008, at 13:16 , Tim Visher wrote:
>>>
>>>> Hello Everyone,
>>>>
>>>> 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.
>>>>
>>>> --
>>>> In Christ,
>>>>
>>>> Timmy V.
>>>>
>>>> http://burningones.com/
>>>> http://five.sentenc.es/ - Spend less time on e-mail
>>>
>>> Hi Timmy,
>>>
>>> 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.
>>
>> - Josh
>> _______________________________________________
>> macports-users mailing list
>> macports-users at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
>>
>
> Wow do I feel sheepish.  I can't believe I couldn't think to do that
> all by me'lonesome... :\
>
> Thanks a lot everyone!

(Almost) totally untested:
$ port install | sed 's/(active)$//' | sed 's/^/install/' | grep -v  
'The following ports are currently installed:' > my_ports.txt
<trash your partition, reformat, reinstall>
$ port -F my_ports.txt

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:'
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.

Hope it helps.

-N.


More information about the macports-users mailing list