"pkg: pkg is not installed" even after installing it
Perry Hutchison
perryh at pluto.rain.com
Sun Jan 10 04:25:28 UTC 2016
I am in the process of setting up a FreeBSD 10 system, which will be
my first experience with pkg(8). In the interest of minimizing the
need to start over after things go badly, I'm trying to carefully
explore how pkg behaves, on an older system (FreeBSD 8) that does
not normally use it:
Mount the 10.2 memstick image read-only (on FreeBSD 8):
# mdconfig -a -t vnode -u 0 -f /path/to/FreeBSD-10.2-RELEASE-i386-memstick.img
md0
# ll -d /dev/md0*
crw-r----- 1 root operator 0, 175 Nov 30 01:46 /dev/md0
crw-r----- 1 root operator 0, 176 Nov 30 01:46 /dev/md0p1
crw-r----- 1 root operator 0, 178 Nov 30 01:46 /dev/md0p2
crw-r----- 1 root operator 0, 179 Nov 30 01:46 /dev/md0p3
# file -s /dev/md0*
/dev/md0: x86 boot sector; ...
/dev/md0p1: data
/dev/md0p2: Unix Fast File system ...
/dev/md0p3: data
# gpart show md0
=> 3 1346448 md0 GPT (657M)
3 32 1 freebsd-boot (16K)
35 1344368 2 freebsd-ufs (656M)
1344403 2048 3 freebsd-swap (1.0M)
# mount -r -t ufs /dev/md0p2 /mnt
Chroot into the image and run "pkg -N". Yes, this is running a newer
userland on an older kernel, so it might fail with an unimplemented
system call if the commands I run use kernel facilities not present
in the older kernel. However I don't actually get any error messages.
# chroot -u 105 -g 0 -G 105,0,5,20,25 /mnt which pkg
/usr/sbin/pkg
# chroot -u 105 -g 0 -G 105,0,5,20,25 /mnt ldd usr/sbin/pkg
usr/sbin/pkg:
libarchive.so.6 => /usr/lib/libarchive.so.6 (0x28071000)
libfetch.so.6 => /usr/lib/libfetch.so.6 (0x2810f000)
libucl.so.1 => /usr/lib/private/libucl.so.1 (0x28121000)
libsbuf.so.6 => /lib/libsbuf.so.6 (0x28133000)
libssl.so.7 => /usr/lib/libssl.so.7 (0x28136000)
libcrypto.so.7 => /lib/libcrypto.so.7 (0x28193000)
libm.so.5 => /lib/libm.so.5 (0x28323000)
libc.so.7 => /lib/libc.so.7 (0x2834a000)
libz.so.6 => /lib/libz.so.6 (0x284bf000)
libbz2.so.4 => /usr/lib/libbz2.so.4 (0x284d3000)
liblzma.so.5 => /usr/lib/liblzma.so.5 (0x284e3000)
libbsdxml.so.4 => /lib/libbsdxml.so.4 (0x28506000)
# chroot -u 105 -g 0 -G 105,0,5,20,25 /mnt pkg -N
pkg: pkg is not installed
(as expected)
Mount a tmpfs on the (otherwise read-only) /usr/local, and copy
pkg.tgz there, so it will be visible in the chroot environment.
# set MD4UL=`mdconfig -a -t swap -s 30m`
# echo /dev/$MD4UL
/dev/md1
# newfs -b 4096 -f 512 -m 0 -n /dev/$MD4UL
Warning: changing optimization to space because minfree is less than 8%
/dev/md1: 30.0MB (61440 sectors) block size 4096, fragment size 512
using 4 cylinder groups of 7.50MB, 1921 blks, 3856 inodes.
super-block backups (for fsck -b #) at:
144, 15512, 30880, 46248
# tunefs -p /dev/$MD4UL
...
tunefs: maximum blocks per file in a cylinder group: (-e) 512
...
tunefs: optimization preference: (-o) space
...
# tunefs -e 1921 -o time /dev/$MD4UL
tunefs: maximum blocks per file in a cylinder group changes from 512 to 1921
tunefs: optimization preference changes from space to time
tunefs: should optimize for space with minfree < 8%
# tunefs -p /dev/$MD4UL
...
tunefs: maximum blocks per file in a cylinder group: (-e) 1921
...
tunefs: optimization preference: (-o) time
...
# mount /dev/$MD4UL /mnt/usr/local
# mkdir /mnt/usr/local/pkg
# chmod 777 /mnt/usr/local /mnt/usr/local/pkg
# cp -p /path/to/pkg.txz* /mnt/usr/local/pkg
# ll /mnt/usr/local/pkg
total 2445
-r--r--r-- 1 perryh perryh 2487404 Jul 29 18:13 pkg.txz
-r--r--r-- 1 perryh perryh 727 Jul 30 17:59 pkg.txz.sig
# chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt pkg add -f /usr/local/pkg/pkg.tgz
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Note, no error messages. However:
# chroot -u 105 -g 0 -G 105,0,5,20,25 /mnt pkg -N
pkg: pkg is not installed
Why does it claim that pkg is not installed, when it just got through
installing it? Or, if the install failed part way through, why was there
no error message? And yes, the "pkg add" really did install something --
/mnt/usr/local/sbin did not exist before running "pkg add" -- and what it
installed is at least partly functional:
# ls -lR /mnt/usr/local
total 1
drwxrwxrwx 2 root wheel 512 Jan 9 18:11 pkg
drwxr-xr-x 2 perryh wheel 512 Jan 9 18:19 sbin
/mnt/usr/local/pkg:
total 2445
-r--r--r-- 1 perryh perryh 2487404 Jul 29 18:13 pkg.txz
-r--r--r-- 1 perryh perryh 727 Jul 30 17:59 pkg.txz.sig
/mnt/usr/local/sbin:
total 4472
-rwxr-xr-x 1 root wheel 4559004 Jul 29 18:13 pkg-static
# chroot -u 105 -g 0 -G 105,0,5,20,25 /mnt pkg-static help
Usage: pkg [-v] [-d] [-l] [-N] [-j <jail name or id>|-c <chroot path>|-r <rootdir>] [-C <configuration file>] [-R <repo config dir>] [-o var=value] [-4|-6] <command> [<args>]
Global options supported:
-d Increment debug level
-j Execute pkg(8) inside a jail(8)
-R Execute pkg(8) using relocating installation to <rootdir>
-c Execute pkg(8) inside a chroot(8)
-C Use the specified configuration file
-R Directory to search for individual repository configurations
-l List available commands and exit
-v Display pkg(8) version
-N Test if pkg(8) is activated and avoid auto-activation
-o Override configuration option from the command line
-4 Only use IPv4
-6 Only use IPv6
Commands supported:
add Compatibility interface to install a package
alias List the command line aliases
annotate Add, modify or delete tag-value style annotations on packages
audit Reports vulnerable packages
autoremove Removes orphan packages
backup Backs-up and restores the local package database
check Checks for missing dependencies and database consistency
clean Cleans old packages from the cache
config Display the value of the configuration options
convert Convert database from/to pkgng
create Creates software package distributions
delete Deletes packages from the database and the system
fetch Fetches packages from a remote repository
help Displays help information
info Displays information about installed packages
install Installs packages from remote package repositories and local archives
lock Locks package against modifications or deletion
plugins Manages plugins and displays information about plugins
query Queries information about installed packages
register Registers a package into the local database
remove Deletes packages from the database and the system
repo Creates a package repository catalogue
rquery Queries information in repository catalogues
search Performs a search of package repository catalogues
set Modifies information about packages in the local database
ssh Package server (to be used via ssh)
shell Opens a debug shell
shlib Displays which packages link against a specific shared library
stats Displays package database statistics
unlock Unlocks a package, allowing modification or deletion
update Updates package repository catalogues
updating Displays UPDATING information for a package
upgrade Performs upgrades of packaged software distributions
version Displays the versions of installed packages
which Displays which package installed a specific file
For more information on the different commands see 'pkg help <command>'.
More information about the freebsd-questions
mailing list