pkg upgrade not working properly [was: pkgng messed up]

Lowell Gilbert freebsd-questions-local at
Thu May 22 19:03:06 UTC 2014

Nagy László Zsolt <gandalf at> writes:

> All right, I guess nobody knows the answer. I give up on this
> one. Very bad first impression on pkg!

There *is* no "the answer." Once you manage to mess up your ports
database, there's no guarantee you'll ever be able to recover the data
that was lost. Fortunately, it is much more difficult to mess up the
ports database under pkgng than it was under the previous package
infrastructure, so in general things get much easier.

The thing you have to keep in mind is that pkgng actually stores its
data differently than the old package system did, and except for a few
special utilities like "pkg convert" (also known as pkg-convert(8)) and
"pkg2ng", they won't recognize changes made by the other system. I'm
just guessing, but my suspicion is that you did something like using
pkg_add after you converted your packages to pkgng. That won't work;
pkgng's database has no way to know that you added a package without
telling it.

> Next question: how do I remove all packages and reinstall all of them
> completely, from binaries?

A week or so ago, I suggested that this might be the easiest approach.

> Is this possible with the pkg command? Or should I use pkg_delete

If my suspicions are correct, neither one will do it, although a
combination of "pkg_delete -a" and "pkg delete -a" would probably do
better than either one alone.

I think a better course of action would be go around both old and new
commands; once you decide to remove anything anyway, there's no downside
to just deleting everything. The fundamenal approach is brute force:
"rm -rf /usr/local/* /var/db/pkg/*" (or something similar). Before doing
that, try to collect a list of leaf ports that you'll want to reinstall
later (this will save you a lot of time, unless your memory is a lot
better than mine), and any configuration files under /usr/local that you
have modified (I'd recommend just moving off the whole of /usr/local to
some safe place until the reinstall procedure is complete, but that may
be overkill in some cases). After emptying /usr/local and /var/db/pkg,
delete /usr/sbin/pkg_* to keep yourself from accidentally using them
again. Then reinstall packages with "pkg install". 

Depending on what version of FreeBSD you're using, you might need to set
a variable in make.conf to get various utilities to know to use
pkgng. [I doubt this is necessary or useful any more, but I'm not
completely sure.]

Good luck.

More information about the freebsd-questions mailing list