sudo port upgrade all

Ryan Schmidt ryandesign at macports.org
Thu Nov 27 17:47:16 PST 2008


On Nov 27, 2008, at 04:17, David Epstein wrote:

> I mistakenly did sudo port upgrade all, instead of sudo port upgrade
> installed, and left my machine for 24 hours. It seems that a huge  
> amount of
> stuff was installed, which I now want to get rid of.
>
> The first point I will make is that this has happened to other  
> users before,
> as one can see by searching the list for "port upgrade all", and  
> port should
> not allow this to happen without making sure that the reader knows  
> what
> he/she is doing. I was working with the default version of  
> "sources.conf".
> Please point me to a link specifying the procedure to be followed when
> requesting an improvement to MacPorts. I wonder if anyone has time or
> interest to provide this additional protection to naive users?
>
> Secondly I would welcome some helpful suggestions about how to  
> recover from
> this situation. I want to identify the unnecessary installs, and  
> uninstall
> them. I don't want to use -f, for fear of damaging my existing  
> installation.
>
> Unless there is a way of detecting dates of installation using some  
> feature
> of "port", the most hopeful route for me seems to be to use Unix  
> "find".
> However, I don't understand the file structure of /opt/local well  
> enough.
> How can I construct a find command that will get me only new  
> installs, with
> only one hit per install? What I am talking about here is the fact  
> that
> there are many files associated with each install, and I don't want a
> separate find hit for each of these files.
>
> Assuming that I can construct a list of unwanted ports, I can  
> uninstall
> everything in the list, except that dependencies will prevent this.  
> If I
> pass uninstall commands repeatedly over the list, what happens when  
> it hits
> ports that have already been uninstalled? Or is there a better way.  
> Again, I
> don't want to use force.
>
> Finally, does port uninstall (if successful) remove ALL the files  
> associated
> with an install, or is some debris left that needs to be further  
> cleaned?
>
> thanks for your help in my predicament.


One problem here is that if you "sudo port upgrade x" and port x is  
not already installed, MacPorts installs it. It would make more sense  
to me if MacPorts would instead issue an error ("cannot upgrade port  
x because it is not installed") and exit. Anyone know why "upgrade"  
installs a port if it's not installed?

I don't know a good way to clean this up automatically, since  
MacPorts doesn't know which ports you meant to install/upgrade and  
which ones you didn't. I suggest you look at the output of "port  
installed" and decide which ports you want to have and which ones you  
don't.

For each port x you don't want, run "sudo port uninstall x". If other  
ports depend on it, it'll tell you what those ports are and won't let  
you uninstall it yet. In that case, run "sudo port uninstall" for  
each listed dependent, and so forth on up the chain, until it lets  
you uninstall it, unless of course you realize that the port you're  
in the process of uninstalling is in fact a dependency of a port you  
want to keep.

As Emmanuel mentioned, you've also ended up with lots of distfiles  
you may not need. You could go to a lot of effort to delete only  
those distfiles you don't need, and keep those you might need if you  
want to reinstall a port, or you could just "sudo port clean --all  
all" to remove the distfiles of every port. If you later do need to  
reinstall a port, it will download its distfile again.

Preventing this from happening in the future by keeping people from  
using the "all" pseudo-port with the "upgrade" or "install" targets  
would be good, but I don't think it's that straightforward, since  
AFAIK MacPorts *first* expands the pseudo-port to a list of ports,  
and *then* hands that list to the "upgrade" or "install" target; the  
targets do not see a difference between you typing "all" and you  
typing the names of all 5163 ports. One possible remedy would be to  
have a sanity check for "install" and "upgrade" (any other targets?)  
to have it bail out if more than n ports are requested, where n is, I  
don't know, 100? 200? I have over 300 ports installed, but not many  
of those need upgrading; one would use "sudo port upgrade outdated"  
to upgrade only the outdated ports; "sudo port upgrade installed"  
wouldn't be a good thing to run. Comments on this strategy, or  
suggestions for other strategies to prevent this situation?





More information about the macports-users mailing list