# Rebuild of ports after upgrade?



## mlager (May 3, 2012)

Just bringing some systems up from 8.3-REL to 9.0-REL. Everything's gone smoothly. I've always wondered what the final word is on rebuilding all ports after a release from one branch to the next. I use portupgrade, what is the proper way to rebuild all ports? Any advice would be appreciated.


----------



## wblock@ (May 3, 2012)

The procedure at the end of the portmaster(8) man page is quicker than rebuilding everything in place and gets rid of unwanted leftovers.


----------



## Mayhem30 (Feb 10, 2013)

wblock@ said:
			
		

> The procedure at the end of the portmaster(8) man page is quicker than rebuilding everything in place and gets rid of unwanted leftovers.



I have a question about this step :



> 8. Manually check /usr/local and /var/db/pkg to make sure that they are really empty



So if I follow the procedure you are recommending, will my /usr/local/etc/ directory be deleted as well?

I do not want to lose my config files.


----------



## trh411 (Feb 10, 2013)

Mayhem30 said:
			
		

> I have a question about this step :
> 
> So if I follow the procedure you are recommending, will my /usr/local/etc/ directory be deleted as well?
> 
> I do not want to lose my config files.



Yes. That is why Step 8 recommends backing up everything below /usr/local (e.g. /usr/local/etc) that you want to save. The procedure re-installs all your ports from scratch, so /usr/local should be confirmed as empty (Step 9) before you start.


----------



## Mayhem30 (Feb 10, 2013)

Does this also remove my port config files? (eg - will have to redo all the 'make config' on them)

Could you also let me know which step # deletes /usr/local/* files?

All I'm seeing is :



> 7. rm -rf /usr/local/lib/compat/pkg


----------



## wblock@ (Feb 10, 2013)

Port config options are stored in /var/db/ports.  They will still be there.  Some ports will have changed, and will show the options config screen again before building.

I personally do not remove or empty out /usr/local, particularly /usr/local/etc.  I do make a backup of /usr/local/etc first.

Step 7 there just removes old libraries.


----------



## Mayhem30 (Feb 10, 2013)

wblock@ said:
			
		

> I personally do not remove or empty out /usr/local, particularly /usr/local/etc.  I do make a backup of /usr/local/etc first.



Ok, now I'm confused - do any of the 10 steps actually wipe out the /usr/local directory?

If so, which step #?


----------



## wblock@ (Feb 10, 2013)

Step 6, pkg_delete -a, deletes all installed packages and most of their files in /usr/local.


----------



## Mayhem30 (Feb 10, 2013)

wblock@ said:
			
		

> Step 6, pkg_delete -a, deletes all installed packages and most of their files in /usr/local.



Thank you, I see where the confusion lies now. I was looking at the web version of the man page, not the man page on the server. They are quite different.

If pkg_delete -a clears most of the /usr/local/ directory, someone should revise the instructions.



> 6. pkg_delete -a
> 7. rm -rf /usr/local/lib/compat/pkg
> 8. Back up any files in /usr/local you wish to save, such as configuration files in /usr/local/etc
> 9. Manually check /usr/local and /var/db/pkg to make sure that they are really empty
> ...



Isn't it too late for Step #8 since Step #6 just wiped out all that information?


----------



## wblock@ (Feb 10, 2013)

The online version of that man page has not been regenerated lately.

Ports config files in /usr/local/etc are not supposed to be deleted if they have been modified.  So any that were customized by the user are supposed to be left, while any example config files will be replaced by newer versions when the port is reinstalled.  Some ports do not do that correctly, and can wipe out custom config files.  So yes, I would back up all of /usr/local/etc before deleting packages.

Please enter a PR to get that man page changed.


----------



## Mayhem30 (Feb 11, 2013)

Thank you.


----------



## Mayhem30 (Feb 14, 2013)

Just a heads up for anyone considering using this method - set aside lots of free time.

One of the biggest issues I ran in to was this step #11 : portmaster `cat ~/installed-port-list`

Besides the fact it failing the initial build process 10 times (massive failures in _archivers/xz_, _archivers/unzip_), it did not install the correct versions of my previous ports.

For example :

databases/mysql51-server --> installed MySQL 5.5
mail/dovecot --> installed Dovecot 2.x
lang/python26 --> installed python26 and 27 (even though I have no ports than depend on either version)

... and the list goes on.

I had to pretty much deinstall half my ports and install the correct versions when everything was finished.

All the ports installed correctly (without errors) when I did them manually. 

If your upgrading the OS, you may want to consider option #2 :



> Alternatively you could use portmaster -a -f -D to do an ``in place''
> update of your ports.  If that process is interrupted for any reason you
> can use portmaster -a -f -D -R to avoid rebuilding ports already rebuilt
> on previous runs.


----------

