242 views
# Bootstrapping pkgbase from scratch Assuming you have a jail or zfs boot environment, for example, on an existing system, it should be possible to set up directly from base system packages. # Obvious Choice Fails Badly From a 15.x host, I should be able to bootstrap pkg into an empty directory / system. ``` $ uname -a FreeBSD wintermute.skunkwerks.at 15.0-ALPHA4 FreeBSD 15.0-ALPHA4 stable/15-n280351-b15ef791f91f GENERIC amd64 $ /usr/sbin/pkg \ -o ABI=FreeBSD:14:amd64 \ -o IGNORE_OSVERSION=yes \ -o AUTOCLEAN=yes \ -o INSTALL_AS_USER=yes \ -r FreeBSD-ports \ --rootdir . \ bootstrap -f pkg: Setting ABI requires setting OSVERSION, guessing the OSVERSION as: 1400000 pkg: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommended pkg(8) is already installed. Forcing reinstallation through pkg(7). The package management tool is not yet installed on your system. Do you want to fetch and install it now? [y/N]: y Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:15:amd64/latest, please wait... ^c ``` ## Non-obvious Choice Works But There Must Be a Better Way - let's assume /tmp/mnt represents a new jail/boot env/whatever - drop FreeBSD public signing key ``` $ mkdir /tmp/mnt $ cd /tmp/mnt $ mkdir -p usr/share/keys/pkg/trusted etc/pkg $ cp -v /usr/share/keys/pkg/trusted/pkg.freebsd.org.2013102301 \ usr/share/keys/pkg/trusted/ ``` - and this `pkg.conf` - use `FreeBSD-ports` for 15.x and `FreeBSD` for 14.x ``` # etc/pkg/FreeBSD.conf FreeBSD-ports: { url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", enabled: yes } FreeBSD-kmods: { url: "pkg+https://pkg.FreeBSD.org/${ABI}/kmods_latest", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", enabled: yes } FreeBSD-base: { url: "pkg+https://pkg.FreeBSD.org/${ABI}/base_release_${VERSION_MINOR}", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", enabled: yes } ``` - bootstrap pkg ``` $ /usr/local/sbin/pkg-static \ -o ABI=FreeBSD:14:amd64 \ -o OSVERSION=1403000 \ -o AUTOCLEAN=yes \ -o INSTALL_AS_USER=yes \ -r FreeBSD-ports \ --rootdir . \ --repo-conf-dir etc/pkg \ install -y pkg ... pkg-static: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommended Updating FreeBSD-ports repository catalogue... Fetching meta.conf: 100% 179 B 0.2kB/s 00:01 Fetching data.pkg: 100% 10 MiB 712.1kB/s 00:15 Processing entries: 100% FreeBSD-ports repository update completed. 36568 packages processed. Updating FreeBSD-kmods repository catalogue... Fetching meta.conf: 100% 179 B 0.2kB/s 00:01 Fetching data.pkg: 100% 30 KiB 30.9kB/s 00:01 Processing entries: 0% Processing entries: 100% FreeBSD-kmods repository update completed. 210 packages processed. Updating FreeBSD-base repository catalogue... Fetching meta.conf: 100% 179 B 0.2kB/s 00:01 Fetching data.pkg: 100% 48 KiB 49.1kB/s 00:01 Processing entries: 100% FreeBSD-base repository update completed. 525 packages processed. All repositories are up to date. The following 8 package(s) will be affected (of 0 checked): New packages to be INSTALLED: FreeBSD-clibs: 14.3p4 [FreeBSD-base] FreeBSD-libarchive: 14.3p4 [FreeBSD-base] FreeBSD-libbsm: 14.3p4 [FreeBSD-base] FreeBSD-libbz2: 14.3p4 [FreeBSD-base] FreeBSD-liblzma: 14.3p4 [FreeBSD-base] FreeBSD-openssl-lib: 14.3p4 [FreeBSD-base] FreeBSD-runtime: 14.3p4 [FreeBSD-base] pkg: 2.3.1 [FreeBSD-ports] Number of packages to be installed: 8 The process will require 66 MiB more space. 18 MiB to be downloaded. [1/8] Fetching pkg-2.3.1.pkg: 100% 12 MiB 740.9kB/s 00:17 ... Checking integrity... done (0 conflicting) ... [8/8] Extracting pkg-2.3.1: 100% ldconfig: mkstemp(/var/run/ld-elf.so.hints.yMHGSC): Permission denied ldconfig: mkstemp(/var/run/ld-elf32.so.hints.7dGFPQ): Permission denied ``` # Almost Works - install some bits from pkgbase - `${VERSION_MINOR}` is obtained from `OSVERSION` thus 14.3-RELEASE ``` # /usr/local/sbin/pkg-static \ -o ABI=FreeBSD:14:amd64 \ -o IGNORE_OSVERSION=yes \ -o AUTOCLEAN=yes \ --rootdir /mnt \ --repo-conf-dir /mnt/etc/pkg/ \ install FreeBSD-runtime FreeBSD-utilities # mv etc/pkg/FreeBSD.conf.pkgsave etc/pkg/FreeBSD.conf ``` - list available packages, split by boot environment and jail (no kernel nor tools) ``` # /usr/local/sbin/pkg-static \ -o ABI=FreeBSD:14:amd64 \ -o IGNORE_OSVERSION=yes \ -o AUTOCLEAN=yes \ --rootdir /mnt \ --repo-conf-dir /mnt/etc/pkg/ \ rquery -r FreeBSD-base %n \ | egrep -v '[-](lib32|dbg|tests|src.*)$ \ | tee etc/pkg-base.lst \ | egrep -v '[-](kernel.*|bootloader|bsnmp|clang|cxgbe-tools|dtrace|lld|lldb|mlx-tools|rescue)' \ | tee etc/jail-base.lst' ``` ## 14.3-RELEASE Boot Environment - you probably need most of these packages for a bootable system > this list is only valid for 14.3-RELEASE, other versions > will have a different set of packages! - install all of these for a bootable system ``` # /usr/local/sbin/pkg \ -o ABI=FreeBSD:14:amd64 \ -o IGNORE_OSVERSION=yes \ -o AUTOCLEAN=yes \ --rootdir /mnt \ --repo-conf-dir /mnt/etc/pkg/ \ install $(cat etc/pkg-base.lst) # mv etc/pkg/FreeBSD.conf.pkgsave etc/pkg/FreeBSD.conf ``` ## 14.3-RELEASE Jail Install ``` # /usr/local/sbin/pkg \ -o ABI=FreeBSD:14:amd64 \ -o IGNORE_OSVERSION=yes \ -o AUTOCLEAN=yes \ --rootdir /mnt \ --repo-conf-dir /mnt/etc/pkg/ \ install $(cat etc/pkg-jail.lst) # mv etc/pkg/FreeBSD.conf.pkgsave etc/pkg/FreeBSD.conf ```