# How to rebuild all programs?



## Laterport (Jan 25, 2014)

Hi everyone,  have updated from 9.2 to 10.0 using a standar*d* way: freebsd-update. After updating I see:



> ```
> root@test:~ # pkg version -v
> dialog4ports-0.1.5_2               =   up-to-date with port
> libffi-3.0.13_1                    =   up-to-date with port
> ...


----------



## wblock@ (Jan 25, 2014)

`pkg2ng`  must be run to convert the old package database into the new format used by FreeBSD 10 (see http://www.freebsd.org/releases/10.0R/relnotes.html#ports) .  However, it might overwrite the present database, losing track of the few programs listed above.

I would delete these packages with `pkg delete -ay`, then run `pkg2ng`.  The next step is to rebuild all ports.  That is required after the change from 9.2 to 10.0.

Here is a modified version of the portmaster procedure to allow for the new package tools:

```
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 -ay
              (or 'pkg_delete -a' for the old package tools)
           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
           10. Reinstall ports-mgmt/pkg and ports-mgmt/portmaster
               (or just ports-mgmt/portmaster for the old package tools)
           11. portmaster `cat ~/installed-port-list`
```

After all that, check to see that the short list of programs in the first post is installed, and reinstall them if needed.


----------



## von_Gaden (Jan 26, 2014)

Thank you for the instructions! Yesterday I tried to do that in my test environment in the same order except portmaster. I didn't suffer the absence of packages because migrating the database was my first job. But I'm most familiar with ports-mgmt/portupgrade and I attempted to use it for rebuilding ports. Something is wrong, because I get continuous:


```
[Updating the portsdb <format:bdb_btree> in [file]/usr/ports[/file] ... - 24576 port entries found  error] Remove and try again.
```

Is ports-mgmt/portupgrade unable to work with PKGNG?


----------



## wblock@ (Jan 26, 2014)

I think that ports-mgmt/portupgrade will work with pkg, but since it depends on Ruby and db42, it is not going to be able to do the same process as ports-mgmt/portmaster, which is only a shell script with no dependencies.  The two programs are not identical, and do not accept the same options.


----------



## ankscorek (Jan 27, 2014)

Can someone please help me out with this one

http://forums.freebsd.org/viewtopic.php?f=4&t=44397


----------



## wblock@ (Jan 27, 2014)

The procedure in the second post in this thread should work.


----------



## von_Gaden (Jan 27, 2014)

Thank you very much, @wblock@!
Your instructions are so precious because the all-questions-answering (and thus my favorite) official handbook is not completely updated yet. This is reasonable, because the topic is almost too new.
I've been using  FreeBSD in my production environments for over a decade and using the old `pkg_...` and `portupgrade -fa` is a habit for me. I'm not sure that you can easily find another OS that allows such long-term habits establishment in its users   . Well, it's time to clean-up our ports and packages! I'm sure I have at least 10 "leaves" in my systems. And let's start establishing our new habits with PKGNG.


----------



## ankscorek (Jan 27, 2014)

Thank You wblock

The old way helped again


----------



## MatiasColli (Jun 7, 2014)

The problem lies in a broken version of freebsd-update(8) which got fixed in FreeBSD 9.0-RC1. To fix your version simply run the following command:
`# sed -i '' -e 's/=_/=%@_/' /usr/sbin/freebsd-update`

Matias Colli
UNIX Administrator


----------

