More info on rebuilding ports after upgrade to 8.0

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:

Code:
# 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
 
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.
 
1) portupgrade depends on it.
2) portupgrade depends on it.
3) portupgrade depends on it.
4) portupgrade depends on it.

:e
 
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.
 
Back
Top