How to create a PkgBase based chroot directory tree (for example)

From: Mark Millard <marklmi_at_yahoo.com>
Date: Thu, 21 Nov 2024 20:18:52 UTC
Some context:

I used url: "pkg+http://pkg.FreeBSD.org/${ABI}/base_weekly"
as it was somewhat older then the kernel that the system
was running. (Newer worlds on older kernels can be a problem.)

What I grabbed also grabbed the kernels, for example. That
might not be desired.

For reference on the system in use, before this activity
I had in place:

# more /usr/local/etc/pkg/repos/base.conf 
base: {
    url: "pkg+http://pkg.FreeBSD.org/${ABI}/base_weekly",
    mirror_type: "srv",
    signature_type: "fingerprints",
    fingerprints: "/usr/share/keys/pkg",
    enabled: yes
}

What did I do starting from that? . . .

I created an empty: /usr/obj/DESTDIRs/main-amd64-pbase/

I the copied over just the tree: /usr/obj/DESTDIRs/main-amd64-pbase/usr/share/keys/pkg
into the that newly created area. This produced:

/usr/obj/DESTDIRs/main-amd64-pbase/usr/
/usr/obj/DESTDIRs/main-amd64-pbase/usr/share
/usr/obj/DESTDIRs/main-amd64-pbase/usr/share/keys
/usr/obj/DESTDIRs/main-amd64-pbase/usr/share/keys/pkg
/usr/obj/DESTDIRs/main-amd64-pbase/usr/share/keys/pkg/revoked
/usr/obj/DESTDIRs/main-amd64-pbase/usr/share/keys/pkg/trusted
/usr/obj/DESTDIRs/main-amd64-pbase/usr/share/keys/pkg/trusted/pkg.freebsd.org.2013102301

With just that much of a directory tree present, I
was then able to do the following. (I did the fetch
stage separately from the update stage.)

# pkg-static -r /usr/obj/DESTDIRs/main-amd64-pbase/ install -F -rbase -g 'FreeBSD-*'
# pkg-static -r /usr/obj/DESTDIRs/main-amd64-pbase/ install -U -rbase -g 'FreeBSD-*'
# chroot /usr/obj/DESTDIRs/main-amd64-pbase/
# freebsd-version -kru
15.0-CURRENT
15.0-CURRENT
15.0-CURRENT
# exit
# 

After later setting some more up in the chroot :

# ~/pkgbase-snapshot-list.sh 
Via pkg-static info -C -x '^FreeBSD-' . . .
   1 FreeBSD-*-15.snap20241117111205
   8 FreeBSD-*-15.snap20241116201407
   2 FreeBSD-*-15.snap20241116191014
   1 FreeBSD-*-15.snap20241116040924
  16 FreeBSD-*-15.snap20241115155402
 328 FreeBSD-*-15.snap20241115030705
  66 FreeBSD-*-15.snap20241114232424
   4 FreeBSD-*-15.snap20241114162618
   1 FreeBSD-*-15.snap20241113231628
   1 FreeBSD-*-15.snap20241113125231
   1 FreeBSD-*-15.snap20241113091125
   1 FreeBSD-*-15.snap20241112035500
   1 FreeBSD-*-15.snap20241108205938
   1 FreeBSD-*-15.snap20241108132953
   1 FreeBSD-*-15.snap20241107061333
   1 FreeBSD-*-15.snap20241107020356
   5 FreeBSD-*-15.snap20241104155004
   1 FreeBSD-*-15.snap20241103222744
   1 FreeBSD-*-15.snap20241029132733
   1 FreeBSD-*-15.snap20241028160252
  97 FreeBSD-*-15.snap20241026125659
Instead via /var/cache/pkg/*.snap*.pkg . . .
   1 FreeBSD-*-15.snap20241117111205
   8 FreeBSD-*-15.snap20241116201407
   2 FreeBSD-*-15.snap20241116191014
   1 FreeBSD-*-15.snap20241116040924
  16 FreeBSD-*-15.snap20241115155402
 328 FreeBSD-*-15.snap20241115030705
  66 FreeBSD-*-15.snap20241114232424
   4 FreeBSD-*-15.snap20241114162618
   1 FreeBSD-*-15.snap20241113231628
   1 FreeBSD-*-15.snap20241113125231
   1 FreeBSD-*-15.snap20241113091125
   1 FreeBSD-*-15.snap20241112035500
   1 FreeBSD-*-15.snap20241108205938
   1 FreeBSD-*-15.snap20241108132953
   1 FreeBSD-*-15.snap20241107061333
   1 FreeBSD-*-15.snap20241107020356
   5 FreeBSD-*-15.snap20241104155004
   1 FreeBSD-*-15.snap20241103222744
   1 FreeBSD-*-15.snap20241029132733
   1 FreeBSD-*-15.snap20241028160252
  97 FreeBSD-*-15.snap20241026125659


SIDE NOTE
I learned that base_weekly does not have have
FreeBSD-dtb , unlike base_latest .
END SIDE NOTE

===
Mark Millard
marklmi at yahoo.com