pkg version mismatch with and without -I

Hi, could someone explain the following and maybe give a hand too:

Recently I upgraded my ports database on a FreeBSD 9.2-RELEASE system to pkgng. However, now when I do pkg version without the -I switch I get only “?” statuses, as in the following snippet:

Code:
tn@bahtin [~]$ pkg version -v
apr-1.4.8.1.5.3                    ?   orphaned: devel/apr1
atk-2.8.0                          ?   orphaned: accessibility/atk
autoconf-2.69                      ?   orphaned: devel/autoconf

With -I, everything seems OK:

Code:
tn@bahtin [~]$ pkg version -Iv     
apr-1.4.8.1.5.3                    =   up-to-date with index
atk-2.8.0                          =   up-to-date with index
autoconf-2.69                      =   up-to-date with index

Now there are two things I don’t understand:

  • First, according to man pkg-version “?” means “The installed package does not appear in the index”. However, -I specifically uses the INDEX file. Are there two different indices or am I just not understanding something?
  • Second, according to the same man page, “This could be due to an out of date index” but there’re no pointers as to how to get the index up-to-date. What command to run?

Could it be I’ve misused the portmaster and portsnap commands somehow? I’m a newbie to FreeBSD and find it difficult sometimes with so many different tools to use. I’ve already tried to search this forum (and googled even farther afield) but it’s tricky with the short command and switch names.
 
Hi! It’s portsnap fetch update which updates the INDEX files (at least here it says so in the very last line of the command output). When using later pkg version (which uses by default the -P option) your packages are compared to the ports tree, not to the INDEX. Maybe you have this tree installed in a non-standard directory? Is the output of pkg config PORTSDIR consistent with the PORTSDIR directory used in /etc/portsnap.conf?
 
I did a portsnap fetch; portsnap update both yesterday and again today to make sure it’s done (i.e. I didn’t know before now you could combine those commands in a single run). No good: pkg version still reports “?” statuses while pkg version -I works fine. The ports tree hasn’t been moved to a non-standard location, its /usr/ports.
 
I guess so since freebsd-update says “No updates needed”.

Code:
tn@bahtin [~]$ pkg -v
1.2.4_1

EDIT: GOT IT! So simple. For whatever reason the directory tree one level below /usr/ports has 700 access rights. That is, the first level like /usr/ports/editors has 775 rights (root:wheel) but anything below that is strictly 700. Maybe this is because I’ve run portsnap and similar commands with sudo and my umask is 077?
 
SuperOscar said:
  • First, according to man pkg-version “?” means “The installed package does not appear in the index”. However, -I specifically uses the INDEX file. Are there two different indices or am I just not understanding something?
  • Second, according to the same man page, “This could be due to an out of date index” but there’re no pointers as to how to get the index up-to-date. What command to run?

Yes, there can be multiple index files. The documentation is a bit misleading here:
  • pkg version -P is the default. It tries to use the ports tree to determine the most current version of a package. It does this by simply running make -VPKGVERSION for every installed package. This is why it is so slow.
  • pkg version -I also uses the ports tree. However, it does not run make but uses the ports index files /usr/ports/INDEX.
  • pkg version -R becomes the default in case there is no ports tree. It uses repository catalogues to determine the most current version of a package. These catalogues are for packages what /usr/ports/INDEX is for ports.

To update those index files you either run
  • portsnap fetch update which updates the ports tree and builds a new /usr/ports/INDEX or
  • pkg update which reads the repository configurations from /usr/local/etc/pkg/repos/ and then downloads the catalogues to /var/db/pkg/. This should not be necessary since it is done automatically when using pkg version -R.
 
I'm glad you solved it by looking at permissions, I learnt something new today. :) And thanks to @worldi for the nice summary!

Just to clarify:
SuperOscar said:
I guess so since freebsd-update says “No updates needed”.

Code:
tn@bahtin [~]$ pkg -v
1.2.4_1
freebsd-update will never tell you anything about pkg since it only takes care of updating and upgrading the base system. pkg updates itself through binary packages ( pkg install pkg) and can also be updated through the ports-mgmt/pkg port.
 
Last edited by a moderator:
Yeah, thanks to @worldi for the excellent description! Had I known before that plain pkg version inspects the ports tree I might have guessed the permissions problem sooner; it seems to cause me trouble in almost all the systems I have but I still cannot force myself to use the Ubuntu-style 002 or Debian-style 022 umasks (even though I’m the sole user of my machines).
 
Last edited by a moderator:
Back
Top