# More info on rebuilding ports after upgrade to 8.0



## labaigrazu (Feb 9, 2010)

Howdy mates!

Recently I was upgrading one box, which previously was running 7.2 to 8.0. I was reading through FreeBSDâ€™s handbook section â€œ24.2 FreeBSD Updateâ€ and encountered these lines, which needed to be executed in order to rebuild and reinstall all 3-party programs form ports collection:


```
# portupgrade -f ruby
# rm /var/db/pkg/pkgdb.db
# portupgrade -f ruby18-bdb
# rm /var/db/pkg/pkgdb.db /usr/ports/INDEX-*.db
# portupgrade -af
```
Since I am technologically curious person I was wondering can anyone give me more inside about what actually these command do and why they are needed. Duh I know that first line forces rebuild of port â€œrubyâ€, the second deletes /var/db/pkg/pkgdb.db file, third forces rebuild of â€œruby18-bdbâ€ port, fourth again deletes /var/db/pkg/pkgdb.db and /usr/ports/INDEX-*.db (all files which begin with INDEX- and end with â€œ.dbâ€) and fifth forces rebuild of all ports installed.

What I am asking is:

1. Elaborate please why port ruby needs to be rebuilt (as I understand this is because all or part of it was destroyed when upgrade was performed)?

2. What is the inner reason of deleting /var/db/pkg/pkgdb.db file at this stage on line two?

3. Elaborate please why port ruby18-bdb needs to be rebuilt at this stage? As far as I understand this is rubyâ€™s interface to some database engine.

4. What is the inner reason of deleting again /var/db/pkg/pkgdb.db file and all INDEX-*.db files on line four?

5. Well fifth line orders the rebuilt of all ports, which is obviousâ€¦  No need to explain why. 

Thank YOU all guys (and girls) for taking your time to read and hopefully answer my questions!

I wish you all a very nice day!

Best regards to all,
Paulius

P.S.
Correct me if I am wrong but all these steps need to be taken if portupgrade was installed on the old OS, which got upgraded. Not from the ports collection after upgrade was made, with the help of portsnap fetch update ports were updated and then portupgrade installed?

Now I know Iâ€™ve put here very lot of questions... :stud


----------



## DutchDaemon (Feb 9, 2010)

Portupgrade uses the Ruby scripting language to manipulate the database that portupgrade uses to keep track of installed ports. Why the package database needs to be removed twice, I don't know, but I assume it is to make sure portupgrade does not choke on stale data. Same goes for the INDEX database which needs to be retrieved/rebuilt to match the new major FreeBSD version.


----------



## SirDice (Feb 9, 2010)

1) portupgrade depends on it.
2) portupgrade depends on it. 
3) portupgrade depends on it.
4) portupgrade depends on it.

:e


----------



## fronclynne (Feb 9, 2010)

The first three steps can be turned into:`#  cd /usr/ports/lang/ruby18 && make deinstall reinstall clean && cd ../../databases/ruby-bdb && make deinstall reinstall clean`*, then remove your database files, and procede.

The reason, as SirDice pointed out, is that ruby/portupgrade can get very angry under certain out-of-date database conditions, which I don't entirely understand.


*All this does is bypass the whole redundant ruby/portupgrade database rebuilding & removal stuffs.


----------



## DutchDaemon (Feb 9, 2010)

Thanks, SirDice, for pointing that out, btw.


----------



## nORKy (Feb 10, 2010)

And what about portmaster users ?


----------



## SirDice (Feb 10, 2010)

nORKy said:
			
		

> And what about portmaster users ?



Portmaster doesn't use ruby and/or a db to store the info.


----------



## tangram (Feb 10, 2010)

That's why I like ports-mgmt/portmaster. Simply sh script with no dependencies


----------



## troberts (Feb 11, 2010)

Speaking of Portmaster. It has gotten some great updates in the last month or so.


----------

