pkg_which does not find package

I just updated the glade3 port

Code:
# pkg_replace glade3\*

...

===>   Running ldconfig
/sbin/ldconfig -m /usr/local/lib
===>   Registering installation for glade3-gnome-3.8.3
--->  Cleaning '/usr/ports/devel/glade3'

Now pkg_which does not find the package for the file, but it is in pkg_plist of glade3 and it is in /var/db/pkg/glade3-gnome-3.8.3/+CONTENTS (BTW, this takes one minute which is much slower than before that "USING PKGNG" message appeared some days ago ...)

Code:
# pkg_which /usr/local/include/libgladeui-1.0/gladeui/glade.h
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... USING PKGNG
- 2515 packages found (-0 +0)  done]
?
#

I did pkgdb -fu,which took exactly seven minutes and didn't help. Can I go back to pkg-"old generation"? I ran pkg2ng and pkgdb -fu again, which ran for 45 minutes reading 30-40 MB/s without any output until I interrupted it.

9.1-STABLE
 
Once you convert your database to PKGNG (e.g. run # pkg2ng) you cannot (must not) use the pkg_* tools anymore, but you have to add
Code:
WITH_PKGNG=yes
in your /etc/make.conf and use the pkg(8)() utilities (see $ pkg help for list of commands, and then $ pkg help which for example to see the manpage for the $ pkg which command). So you can use # pkg which ... However, there is no official FreeBSD PKGNG repository yet (but there is a PC-BSD one).

From what I've heard, transition back from PKGNG to pkg_* isn't possible. There is one option that I can think of: install ports-mgmt/portmaster, and then reinstall all ports without PKGNG enabled (this is a slightly modified list of commands, which you can find at the botton of portmaster(8)()):
  1. # portmaster --list-origins > ~/installed-port-list,
  2. # portmaster -ty --clean-distfiles,
  3. # portmaster --check-port-dbdir,
  4. # portmaster -Faf,
  5. # pkg remove -fa,
  6. # rm -rf /usr/local/lib/compat/pkg
  7. # make -C /usr/ports/ports-mgmt/pkg deinstall,
  8. make sure your /etc/make.conf file doesn't contain any mention of theWITH_PKGNG variable,
  9. check again if /usr/local (but I guess you can keep most, if not all, files under /usr/local/etc) and /var/db/pkg are empty.
  10. now reinstall portmaster, # make -C /usr/ports/ports-mgmt/portmaster,
  11. reinstall all your packages from before: # portmaster `cat ~/installed-port-list`,
  12. if you still want to keep using ports-mgmt/portupgrade, run # pkgdb -fu, and delete ports-mgmt/portmaster.

It's not the most elegant solution, but I cannot think of anything else.

On the other hand, you can keep using the PKGNG, as long as you know that you cannot use the pkg_* tools anymore, since it has the # pkg autoremove option, which automatically removes unneeded orphaned dependencies, # pkg check can check for various problems you have with the installed ports (checksum inconsistencies, missing dependencies and/or shared libraries) and so on. These are the reasons I keep it.
 
According to pkgdb I have 2718 ports installed, but the list of portmaster --list-origins has 1121 lines.

I don't really want to reinstall all ports...

Where does the USING PKGNG in pkgdb come from? I have no WITH_PKGNG in make.conf.
 
Uffff, this is a lot of ports. The portmaster entry should be smaller, because it only shows the root ports (so, if you install these, it will automatically install the other 1000, since those are just the dependencies).

I can see why you don't want to install all those ports. One such way is to use an old backup of the /usr+/var partitions if you have it. As @vermaden says, there's two types of people: those who make backups, and those who wish they had. Maybe reinstalling ports isn't necessary. But rest assured, that simply unsetting PKGNG won't revert you to the way it was, and will only leave you with broken/inconsistent ports, so you'll have to fix them later, and saving them at that time will be more painful than now. For the next time, keep in mind that changing settings, without knowing what they do, is generally a bad idea.

portmaster doesn't need explicit definition of WITH_PKGNG anymore, but rather just checks for presence of /usr/local/bin/pkg (or /usr/sbin/pkg), as was noted in /usr/ports/UPDATING. Perhaps this is true now for portupgrade as well, but I don't think it was noted anywhere (pkgdb is a portupgrade utility).
 
Last edited by a moderator:
The PKGNG check in ports-mgmt/portmaster is now done with pkg info pkg so if you even once have enabled the use of PKGNG and you have packages registered in the PKGNG database, portmaster will think that you're using PKGNG. Uninstall ports-mgmt/pkg and delete /var/db/pkg/local.sqlite as instructed in UPDATING (this really shows how mandatory it is to really read the UPDATING file):

Code:
20130627:
  AFFECTS: users of ports-mgmt/portmaster
  AUTHOR: bdrewery@FreeBSD.org

  Since June 22nd, portmaster no longer relies on 'WITH_PKGNG' to be defined,
  or ports to be checked out to enable pkgng support.

  It now considers whether or not pkg is installed and registered with itself.

  I.e., if this returns data, pkgng is considered in use:

    # pkg info pkg

  It's possible that you may have tested pkgng in the past, ran pkg2ng, and
  never fully committed to it by setting WITH_PKGNG. If this is the case,
  uninstall pkg with pkg_info/pkg_delete and also remove the stale database,
  rm /var/db/pkg/local.sqlite.

  This could manifest itself as portmaster -L showing the wrong versions, or
  portmaster no longer detecting installed packages correctly.

  Note that PORTS still require WITH_PKGNG=yes in make.conf if you are not
  running CURRENT.
 
I deinstalled pkg and removed /var/db/pkg/local.sqlite. Now pkg_which works again, thank you. I will probably get problems, but better than a fresh install of everything. Someday I will have to do it...
 
I have a backup. But, 1) it was both too new (with PKGNG) and too old (new ports installed), 2) I didn't know what to restore.

BTW, I still have that backup with a pkgdb.db which is a bit larger than the current one.
 
OK. I'm not sure if you should really reinstall yet, it's best to see what the senior members will say.

It's good that you already have a backup, in case something "funny" happens while you're rebuilding the ports -- this way you can write the error output somewhere safe, restore the files from the backup, and fix those problems first, and this way you can do it on a system that relatively works ;) (so you can have X, a functional browser, and your favorite text editor again). If you have enough space on the hard drive, I would make another backup.

As for the restoring part, once you have a backup, like it is described in those two HOW-TOs, you can simply overwrite (restore) the entire partition to the way it was at the time when the backup was created: it's like restoring the frozen file system.
 
OK, cool. BTW, portmaster and portupgrade both have options to use packages as well. For example, en excerpt from portmaster(8)():
Code:
[cmd="$"]man portmaster[/cmd]
...
     -P|--packages
         use packages, but build port if not available

     -PP|--packages-only
         fail if no package is available.  The -PP option must stand alone on
         the command line.  In other words, you cannot do -PPav (for example).

     --packages-build
         use packages for all build dependencies

     --packages-if-newer
         use package if newer than installed even if the package is not the
         latest according to the ports tree

and an excerpt from portupgrade(1)():
Code:
[cmd="$"]man portupgrade[/cmd]
...
     -P
     --use-packages         Use packages instead of ports whenever available.
                            portupgrade searches the local directories listed
                            in PKG_PATH for each package to install or upgrade
                            the current installation with, and if none is
                            found, pkg_fetch(1) is invoked to fetch one from a
                            remote site.  If it does not work either, the port
                            is used.

                            However, the source will still be used if the port
                            is listed in USE_PORTS_ONLY variable in
                            pkgtools.conf.

     -PP
     --use-packages-only    Never use the port even if a package is not avail-
                            able either locally or remotely, although you
                            still have to keep your ports tree up-to-date so
                            that portupgrade can check out what the latest
                            version of each port is

This way you can make a compromise between installation speed and performance. But I think you're doing a good job as it is ;).
 
Back
Top