# Questions on updating all ports with portmaster



## jtl (Jan 16, 2011)

I have some questions related to the portmaster(8) directions for updating all ports.  When executing [cmd=]portmaster --check-port-dbdir[/cmd] (step 4) I am asked many questions about whether or not to delete various items:

```
===>>> Building list of installed port names

===>>> Checking /var/db/ports
	===>>> PackageKit does not seem to be installed
Delete /var/db/ports/PackageKit? y/n [n] 


	===>>> amanda does not seem to be installed
Delete /var/db/ports/amanda? y/n [n] 


	===>>> autoconf262 does not seem to be installed
Delete /var/db/ports/autoconf262? y/n [n] 


	===>>> automake110 does not seem to be installed
Delete /var/db/ports/automake110? y/n [n]
.
.
.
```

Should I be choosing yes and deleting these?

Also, [cmd=]rm -rf /usr/local/lib/compat/pkg[/cmd] (step 7) returns 
	
	



```
Operation not permitted
```
 on a number of libraries such as libc.so.5.  I'm assuming I should manually delete these.  In fact, step 8 says to confirm that /usr/local and /var/db/pkg are really empty, but when I got to this step they weren't remotely empty and I'm wondering if I should manually remove everything.  I answered no to all the requests to delete from the [cmd=]portmaster --check-port-dbdir[/cmd] command and maybe that's part of the reason these directories weren't empty.

Finally, step 9 says to reinstall portmaster.  How should this be done?

Thanks for any help.


----------



## wblock@ (Jan 16, 2011)

The man page says --check-port-dbdir means "check for stale entries in /var/db/ports".  These would be ports that aren't installed any more and may not exist any more, so deleting them should be fine.

Check the flags on /usr/local/lib/compat/pkg:
`# ls -ldo /usr/local/lib/compat/pkg`
If any flags are set, use chflags(1) to clear them.  Oh, and don't forget to log in as root or su(1) to root.

I would strongly recommend making a backup of /usr/local/etc before starting this process.  Ports aren't supposed to delete customized config files, but some still do.  There may be other things in there you want to keep.  If you have the space, back up all of /usr/local.  You can always delete it later.

Install portmaster the same as usual, from ports.  This is only needed because step 6 deleted all the installed ports.


----------



## DutchDaemon (Jan 16, 2011)

At my request, the author of portmaster has added a new 'point 8' to the manual about saving files in /usr/local/etc/. This may or may not have appeared in your version yet.


```
Using portmaster to do a complete reinstallation of all your ports:
           1. portmaster --list-origins > ~/installed-port-list
           2. Update your ports tree
           3. portmaster -ty --clean-distfiles
           4. portmaster --check-port-dbdir
           5. portmaster -Faf
           6. pkg_delete '*'
           7. rm -rf /usr/local/lib/compat/pkg
[B]           8. Back up any files in /usr/local you wish to save,
              such as configuration files in /usr/local/etc[/B]
           9. Manually check /usr/local and /var/db/pkg
              to make sure that they are really empty
           10. Re-install portmaster
           11. portmaster `cat ~/installed-port-list`
```


----------



## jtl (Jan 16, 2011)

@wblock
Thanks.  I reran [cmd=]portmaster -y --check-port-dbdir[/cmd] adding the -y option to simplify things and it completed without any problems.  The [cmd=]pkg_delete '*'[/cmd] command left many items not deleted due to dependencies so I reran it with the -f option.  This greatly reduced the number of items remaining in /usr/local, and /var/db/pkg now contains only the file pkgdb.db.    I've backed up /usr/local/etc, but before I proceed I want to confirm that I should in fact wipe out everything under /usr/local and delete /var/db/pkg/pkgdb.db; all subdirectories such as bin, etc, include, info, lib and others. will be recreated as needed - is this right?

@DutchDaemon
Thanks for that update.  My version doesn't have the new step 8 and doesn't include the -ty options on step 3.  I've backed up /usr/local/etc.


----------



## wblock@ (Jan 16, 2011)

Installing all your ports *shoul*d recreate everything, but making a backup of /usr/local in case something doesn't go right.  You could just use the existing /usr/local as a backup:
`# mv /usr/local /usr/local.bak`
`# mkdir -m 755 /usr/local`


----------



## dougb@ (Jan 16, 2011)

jtl said:
			
		

> @wblock
> Thanks.  I reran [cmd=]portmaster -y --check-port-dbdir[/cmd] adding the -y option to simplify things and it completed without any problems.  The [cmd=]pkg_delete '*'[/cmd] command left many items not deleted due to dependencies so I reran it with the -f option.



Warren was kind enough to point this thread out to me, and recommended pkg_delete -a here which I've just updated the svn version of the docs to include. That'll be in the next release. 



			
				jtl said:
			
		

> This greatly reduced the number of items remaining in /usr/local, and /var/db/pkg now contains only the file pkgdb.db.    I've backed up /usr/local/etc, but before I proceed I want to confirm that I should in fact wipe out everything under /usr/local



No one can tell you if it's "safe" to do that, you have to use your own judgment. If you're concerned, back it up. Better safe than sorry. 



			
				jtl said:
			
		

> and delete /var/db/pkg/pkgdb.db;



Yes, THAT file you can safely delete. It's portupgrade's database, and if you decide to go back to using portupgrade then it will recreate that for you. 



			
				jtl said:
			
		

> all subdirectories such as bin, etc, include, info, lib and others. will be recreated as needed - is this right?



Yes. 



			
				jtl said:
			
		

> @DutchDaemon
> Thanks for that update.  My version doesn't have the new step 8 and doesn't include the -ty options on step 3.  I've backed up /usr/local/etc.



If you're going to use portmaster to manage your ports step 1 should always be to update that first. 


hth,

Doug


----------

