summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--Makefile.inc1185
-rw-r--r--bin/cat/Makefile1
-rw-r--r--bin/cat/tests/Makefile4
-rw-r--r--bin/chflags/Makefile1
-rw-r--r--bin/chio/Makefile1
-rw-r--r--bin/chmod/Makefile1
-rw-r--r--bin/cp/Makefile1
-rw-r--r--bin/csh/Makefile1
-rw-r--r--bin/date/Makefile1
-rw-r--r--bin/date/tests/Makefile4
-rw-r--r--bin/dd/Makefile1
-rw-r--r--bin/dd/tests/Makefile4
-rw-r--r--bin/df/Makefile1
-rw-r--r--bin/domainname/Makefile1
-rw-r--r--bin/echo/Makefile1
-rw-r--r--bin/ed/Makefile1
-rw-r--r--bin/expr/Makefile1
-rw-r--r--bin/expr/tests/Makefile4
-rw-r--r--bin/freebsd-version/Makefile1
-rw-r--r--bin/getfacl/Makefile1
-rw-r--r--bin/hostname/Makefile1
-rw-r--r--bin/kenv/Makefile1
-rw-r--r--bin/kill/Makefile1
-rw-r--r--bin/ln/Makefile1
-rw-r--r--bin/ls/Makefile1
-rw-r--r--bin/ls/tests/Makefile4
-rw-r--r--bin/mkdir/Makefile1
-rw-r--r--bin/mv/Makefile1
-rw-r--r--bin/mv/tests/Makefile4
-rw-r--r--bin/pax/Makefile1
-rw-r--r--bin/pax/tests/Makefile4
-rw-r--r--bin/pkill/Makefile1
-rw-r--r--bin/pkill/tests/Makefile4
-rw-r--r--bin/ps/Makefile1
-rw-r--r--bin/pwait/Makefile1
-rw-r--r--bin/pwd/Makefile1
-rw-r--r--bin/rcp/Makefile3
-rw-r--r--bin/realpath/Makefile1
-rw-r--r--bin/rm/Makefile1
-rw-r--r--bin/rmail/Makefile1
-rw-r--r--bin/rmdir/Makefile1
-rw-r--r--bin/setfacl/Makefile1
-rw-r--r--bin/sh/Makefile1
-rw-r--r--bin/sh/tests/Makefile4
-rw-r--r--bin/sh/tests/builtins/Makefile3
-rw-r--r--bin/sh/tests/errors/Makefile3
-rw-r--r--bin/sh/tests/execution/Makefile3
-rw-r--r--bin/sh/tests/expansion/Makefile3
-rw-r--r--bin/sh/tests/parameters/Makefile3
-rw-r--r--bin/sh/tests/parser/Makefile3
-rw-r--r--bin/sh/tests/set-e/Makefile3
-rw-r--r--bin/sleep/Makefile1
-rw-r--r--bin/sleep/tests/Makefile4
-rw-r--r--bin/stty/Makefile1
-rw-r--r--bin/sync/Makefile1
-rw-r--r--bin/test/Makefile1
-rw-r--r--bin/test/tests/Makefile4
-rw-r--r--bin/tests/Makefile5
-rw-r--r--bin/uuidgen/Makefile1
-rw-r--r--cddl/lib/tests/Makefile5
-rw-r--r--cddl/sbin/tests/Makefile5
-rw-r--r--cddl/tests/Makefile5
-rw-r--r--cddl/usr.bin/tests/Makefile5
-rw-r--r--cddl/usr.sbin/tests/Makefile5
-rw-r--r--contrib/ntp/ntpd/ntp_control.c4
-rw-r--r--etc/Makefile15
-rw-r--r--etc/devd/Makefile9
-rw-r--r--etc/mtree/BSD.var.dist8
-rw-r--r--etc/pam.d/Makefile17
-rw-r--r--etc/periodic/daily/Makefile14
-rw-r--r--etc/periodic/monthly/Makefile8
-rw-r--r--etc/rc.d/Makefile84
-rw-r--r--gnu/lib/libgcc/Makefile1
-rw-r--r--gnu/lib/tests/Makefile5
-rw-r--r--gnu/tests/Makefile5
-rw-r--r--gnu/usr.bin/binutils/Makefile.inc1
-rw-r--r--gnu/usr.bin/diff/tests/Makefile4
-rw-r--r--gnu/usr.bin/gdb/Makefile.inc2
-rw-r--r--gnu/usr.bin/groff/Makefile.inc1
-rw-r--r--gnu/usr.bin/tests/Makefile5
-rw-r--r--include/Makefile84
-rw-r--r--lib/Makefile1
-rw-r--r--lib/atf/libatf-c++/tests/Makefile4
-rw-r--r--lib/atf/libatf-c++/tests/detail/Makefile3
-rw-r--r--lib/atf/libatf-c/tests/Makefile4
-rw-r--r--lib/atf/libatf-c/tests/detail/Makefile5
-rw-r--r--lib/atf/tests/Makefile5
-rw-r--r--lib/atf/tests/test-programs/Makefile4
-rw-r--r--lib/lib80211/Makefile1
-rw-r--r--lib/libalias/libalias/Makefile1
-rw-r--r--lib/libarchive/Makefile1
-rw-r--r--lib/libarchive/tests/Makefile4
-rw-r--r--lib/libauditd/Makefile1
-rw-r--r--lib/libbegemot/Makefile1
-rw-r--r--lib/libblocksruntime/Makefile1
-rw-r--r--lib/libbluetooth/Makefile1
-rw-r--r--lib/libbsdstat/Makefile1
-rw-r--r--lib/libbsm/Makefile1
-rw-r--r--lib/libbsnmp/Makefile.inc1
-rw-r--r--lib/libbz2/Makefile1
-rw-r--r--lib/libc++/Makefile1
-rw-r--r--lib/libc/Makefile1
-rw-r--r--lib/libc/tests/Makefile4
-rw-r--r--lib/libc/tests/c063/Makefile4
-rw-r--r--lib/libc/tests/db/Makefile4
-rw-r--r--lib/libc/tests/gen/Makefile4
-rw-r--r--lib/libc/tests/gen/execve/Makefile4
-rw-r--r--lib/libc/tests/gen/posix_spawn/Makefile4
-rw-r--r--lib/libc/tests/hash/Makefile4
-rw-r--r--lib/libc/tests/inet/Makefile4
-rw-r--r--lib/libc/tests/locale/Makefile4
-rw-r--r--lib/libc/tests/net/Makefile4
-rw-r--r--lib/libc/tests/nss/Makefile4
-rw-r--r--lib/libc/tests/regex/Makefile4
-rw-r--r--lib/libc/tests/resolv/Makefile4
-rw-r--r--lib/libc/tests/rpc/Makefile4
-rw-r--r--lib/libc/tests/setjmp/Makefile4
-rw-r--r--lib/libc/tests/ssp/Makefile4
-rw-r--r--lib/libc/tests/stdio/Makefile4
-rw-r--r--lib/libc/tests/stdlib/Makefile4
-rw-r--r--lib/libc/tests/string/Makefile4
-rw-r--r--lib/libc/tests/sys/Makefile8
-rw-r--r--lib/libc/tests/termios/Makefile4
-rw-r--r--lib/libc/tests/time/Makefile4
-rw-r--r--lib/libc/tests/tls/Makefile4
-rw-r--r--lib/libc/tests/tls/dso/Makefile4
-rw-r--r--lib/libc/tests/tls_dso/Makefile4
-rw-r--r--lib/libc/tests/ttyio/Makefile4
-rw-r--r--lib/libcalendar/Makefile1
-rw-r--r--lib/libcam/Makefile1
-rw-r--r--lib/libcapsicum/Makefile47
-rw-r--r--lib/libcapsicum/Makefile.depend19
-rw-r--r--lib/libcapsicum/libcapsicum.3300
-rw-r--r--lib/libcapsicum/libcapsicum.c266
-rw-r--r--lib/libcapsicum/libcapsicum.h115
-rw-r--r--lib/libcapsicum/libcapsicum_dns.c365
-rw-r--r--lib/libcapsicum/libcapsicum_dns.h57
-rw-r--r--lib/libcapsicum/libcapsicum_grp.c438
-rw-r--r--lib/libcapsicum/libcapsicum_grp.h57
-rw-r--r--lib/libcapsicum/libcapsicum_impl.h39
-rw-r--r--lib/libcapsicum/libcapsicum_pwd.c391
-rw-r--r--lib/libcapsicum/libcapsicum_pwd.h57
-rw-r--r--lib/libcapsicum/libcapsicum_random.c80
-rw-r--r--lib/libcapsicum/libcapsicum_random.h37
-rw-r--r--lib/libcapsicum/libcapsicum_service.c97
-rw-r--r--lib/libcapsicum/libcapsicum_service.h40
-rw-r--r--lib/libcapsicum/libcapsicum_sysctl.c86
-rw-r--r--lib/libcapsicum/libcapsicum_sysctl.h43
-rw-r--r--lib/libcasper/libcasper/Makefile1
-rw-r--r--lib/libcasper/services/cap_dns/Makefile1
-rw-r--r--lib/libcasper/services/cap_grp/Makefile1
-rw-r--r--lib/libcasper/services/cap_pwd/Makefile1
-rw-r--r--lib/libcasper/services/cap_random/Makefile1
-rw-r--r--lib/libcasper/services/cap_sysctl/Makefile1
-rw-r--r--lib/libcom_err/Makefile1
-rw-r--r--lib/libcompat/Makefile1
-rw-r--r--lib/libcompiler_rt/Makefile1
-rw-r--r--lib/libcrypt/Makefile1
-rw-r--r--lib/libcrypt/tests/Makefile4
-rw-r--r--lib/libcuse/Makefile1
-rw-r--r--lib/libcxxrt/Makefile1
-rw-r--r--lib/libdevctl/Makefile1
-rw-r--r--lib/libdevinfo/Makefile1
-rw-r--r--lib/libdevstat/Makefile1
-rw-r--r--lib/libdpv/Makefile1
-rw-r--r--lib/libdwarf/Makefile1
-rw-r--r--lib/libedit/Makefile1
-rw-r--r--lib/libefi/Makefile1
-rw-r--r--lib/libelf/Makefile1
-rw-r--r--lib/libelftc/Makefile1
-rw-r--r--lib/libevent/Makefile1
-rw-r--r--lib/libexecinfo/Makefile1
-rw-r--r--lib/libexpat/Makefile1
-rw-r--r--lib/libfetch/Makefile1
-rw-r--r--lib/libfigpar/Makefile1
-rw-r--r--lib/libgeom/Makefile1
-rw-r--r--lib/libgpio/Makefile1
-rw-r--r--lib/libgssapi/Makefile1
-rw-r--r--lib/libipsec/Makefile1
-rw-r--r--lib/libjail/Makefile3
-rw-r--r--lib/libkiconv/Makefile1
-rw-r--r--lib/libkvm/Makefile1
-rw-r--r--lib/libldns/Makefile1
-rw-r--r--lib/liblzma/Makefile1
-rw-r--r--lib/libmagic/Makefile1
-rw-r--r--lib/libmd/Makefile1
-rw-r--r--lib/libmemstat/Makefile1
-rw-r--r--lib/libmilter/Makefile1
-rw-r--r--lib/libmp/Makefile1
-rw-r--r--lib/libmp/tests/Makefile4
-rw-r--r--lib/libmt/Makefile1
-rw-r--r--lib/libnandfs/Makefile1
-rw-r--r--lib/libnetbsd/Makefile1
-rw-r--r--lib/libnetgraph/Makefile1
-rw-r--r--lib/libngatm/Makefile1
-rw-r--r--lib/libnv/Makefile1
-rw-r--r--lib/libnv/tests/Makefile4
-rw-r--r--lib/libopenbsd/Makefile1
-rw-r--r--lib/libopie/Makefile1
-rw-r--r--lib/libpam/libpam/Makefile1
-rw-r--r--lib/libpam/libpam/tests/Makefile4
-rw-r--r--lib/libpam/modules/pam_ssh/Makefile1
-rw-r--r--lib/libpcap/Makefile1
-rw-r--r--lib/libpjdlog/Makefile1
-rw-r--r--lib/libpmc/Makefile1
-rw-r--r--lib/libproc/Makefile1
-rw-r--r--lib/libproc/tests/Makefile4
-rw-r--r--lib/libprocstat/Makefile1
-rw-r--r--lib/libradius/Makefile1
-rw-r--r--lib/librpcsec_gss/Makefile1
-rw-r--r--lib/librpcsvc/Makefile1
-rw-r--r--lib/librt/Makefile1
-rw-r--r--lib/librt/tests/Makefile4
-rw-r--r--lib/librtld_db/Makefile1
-rw-r--r--lib/libsbuf/Makefile1
-rw-r--r--lib/libsdp/Makefile1
-rw-r--r--lib/libsm/Makefile1
-rw-r--r--lib/libsmb/Makefile1
-rw-r--r--lib/libsmdb/Makefile1
-rw-r--r--lib/libsmutil/Makefile1
-rw-r--r--lib/libsqlite3/Makefile1
-rw-r--r--lib/libstand/Makefile1
-rw-r--r--lib/libstdbuf/Makefile1
-rw-r--r--lib/libstdthreads/Makefile1
-rw-r--r--lib/libsysdecode/Makefile1
-rw-r--r--lib/libtacplus/Makefile1
-rw-r--r--lib/libtelnet/Makefile1
-rw-r--r--lib/libthr/Makefile1
-rw-r--r--lib/libthr/tests/Makefile3
-rw-r--r--lib/libthr/tests/dlopen/Makefile3
-rw-r--r--lib/libthr/tests/dlopen/dso/Makefile4
-rw-r--r--lib/libthread_db/Makefile1
-rw-r--r--lib/libucl/Makefile1
-rw-r--r--lib/libufs/Makefile1
-rw-r--r--lib/libugidfw/Makefile1
-rw-r--r--lib/libulog/Makefile1
-rw-r--r--lib/libunbound/Makefile2
-rw-r--r--lib/libusb/Makefile1
-rw-r--r--lib/libusbhid/Makefile1
-rw-r--r--lib/libutil/Makefile1
-rw-r--r--lib/libutil/tests/Makefile4
-rw-r--r--lib/libvgl/Makefile1
-rw-r--r--lib/libvmmapi/Makefile1
-rw-r--r--lib/libwrap/Makefile1
-rw-r--r--lib/libxo/Makefile1
-rw-r--r--lib/libxo/tests/Makefile4
-rw-r--r--lib/libxo/tests/encoder/Makefile4
-rw-r--r--lib/liby/Makefile1
-rw-r--r--lib/libypclnt/Makefile1
-rw-r--r--lib/libz/Makefile1
-rw-r--r--lib/msun/Makefile1
-rw-r--r--lib/msun/tests/Makefile3
-rw-r--r--lib/ncurses/ncurses/Makefile1
-rw-r--r--lib/tests/Makefile5
-rw-r--r--libexec/atf/atf-check/tests/Makefile4
-rw-r--r--libexec/atf/atf-sh/tests/Makefile5
-rw-r--r--libexec/atf/tests/Makefile5
-rw-r--r--libexec/atrun/Makefile1
-rw-r--r--libexec/casper/Makefile12
-rw-r--r--libexec/casper/dns/Makefile22
-rw-r--r--libexec/casper/dns/Makefile.depend23
-rw-r--r--libexec/casper/dns/dns.c436
-rw-r--r--libexec/casper/grp/Makefile22
-rw-r--r--libexec/casper/grp/Makefile.depend23
-rw-r--r--libexec/casper/grp/grp.c390
-rw-r--r--libexec/casper/pwd/Makefile22
-rw-r--r--libexec/casper/pwd/Makefile.depend23
-rw-r--r--libexec/casper/pwd/pwd.c430
-rw-r--r--libexec/casper/random/Makefile22
-rw-r--r--libexec/casper/random/Makefile.depend23
-rw-r--r--libexec/casper/random/random.c82
-rw-r--r--libexec/casper/sysctl/Makefile22
-rw-r--r--libexec/casper/sysctl/Makefile.depend23
-rw-r--r--libexec/casper/sysctl/sysctl.c249
-rw-r--r--libexec/dma/Makefile.inc1
-rw-r--r--libexec/mail.local/Makefile1
-rw-r--r--libexec/rlogind/Makefile2
-rw-r--r--libexec/rshd/Makefile3
-rw-r--r--libexec/rtld-elf/Makefile4
-rw-r--r--libexec/rtld-elf/tests/Makefile3
-rw-r--r--libexec/rtld-elf/tests/libpythagoras/Makefile4
-rw-r--r--libexec/rtld-elf/tests/target/Makefile4
-rw-r--r--libexec/smrsh/Makefile1
-rw-r--r--libexec/tests/Makefile5
-rw-r--r--release/packages/Makefile.package73
-rw-r--r--release/packages/acct.ucl24
-rw-r--r--release/packages/acpi.ucl24
-rw-r--r--release/packages/amd.ucl24
-rw-r--r--release/packages/apm.ucl24
-rw-r--r--release/packages/at.ucl24
-rw-r--r--release/packages/autofs.ucl24
-rw-r--r--release/packages/bhyve.ucl24
-rw-r--r--release/packages/binutils.ucl24
-rw-r--r--release/packages/bsdinstall.ucl24
-rw-r--r--release/packages/bsnmp.ucl24
-rw-r--r--release/packages/clang.ucl24
-rw-r--r--release/packages/clibs.ucl17
-rw-r--r--release/packages/dma.ucl24
-rw-r--r--release/packages/docs.ucl17
-rw-r--r--release/packages/ee.ucl24
-rw-r--r--release/packages/gdb.ucl24
-rwxr-xr-xrelease/packages/generate-ucl.sh141
-rw-r--r--release/packages/groff.ucl24
-rw-r--r--release/packages/jail.ucl24
-rw-r--r--release/packages/kernel.ucl22
-rw-r--r--release/packages/rcmds.ucl24
-rw-r--r--release/packages/runtime-debug.ucl24
-rw-r--r--release/packages/runtime-development.ucl24
-rw-r--r--release/packages/runtime-lib32.ucl24
-rw-r--r--release/packages/runtime-manuals.ucl24
-rw-r--r--release/packages/runtime-profile.ucl24
-rw-r--r--release/packages/runtime.ucl29
-rw-r--r--release/packages/ssh.ucl24
-rw-r--r--release/packages/svn.ucl24
-rw-r--r--release/packages/syscons.ucl24
-rw-r--r--release/packages/template.ucl17
-rw-r--r--release/packages/tests.ucl24
-rw-r--r--release/packages/unbound.ucl24
-rw-r--r--release/packages/vi.ucl24
-rwxr-xr-xrelease/scripts/make-pkg-package.sh25
-rw-r--r--release/scripts/mtree-to-plist.awk80
-rw-r--r--rescue/librescue/Makefile1
-rw-r--r--rescue/rescue/Makefile1
-rw-r--r--sbin/adjkerntz/Makefile1
-rw-r--r--sbin/atm/atmconfig/Makefile1
-rw-r--r--sbin/badsect/Makefile1
-rw-r--r--sbin/bsdlabel/Makefile1
-rw-r--r--sbin/camcontrol/Makefile1
-rw-r--r--sbin/casperd/Makefile18
-rw-r--r--sbin/ccdconfig/Makefile1
-rw-r--r--sbin/clri/Makefile1
-rw-r--r--sbin/comcontrol/Makefile1
-rw-r--r--sbin/conscontrol/Makefile1
-rw-r--r--sbin/ddb/Makefile1
-rw-r--r--sbin/devd/Makefile1
-rw-r--r--sbin/devd/tests/Makefile4
-rw-r--r--sbin/devfs/Makefile1
-rw-r--r--sbin/dhclient/Makefile1
-rw-r--r--sbin/dhclient/tests/Makefile4
-rw-r--r--sbin/dmesg/Makefile1
-rw-r--r--sbin/dump/Makefile1
-rw-r--r--sbin/dumpfs/Makefile1
-rw-r--r--sbin/dumpon/Makefile1
-rw-r--r--sbin/etherswitchcfg/Makefile1
-rw-r--r--sbin/fdisk/Makefile1
-rw-r--r--sbin/fdisk_pc98/Makefile1
-rw-r--r--sbin/ffsinfo/Makefile1
-rw-r--r--sbin/fsck/Makefile1
-rw-r--r--sbin/fsck_ffs/Makefile1
-rw-r--r--sbin/fsck_msdosfs/Makefile1
-rw-r--r--sbin/fsdb/Makefile1
-rw-r--r--sbin/fsirand/Makefile1
-rw-r--r--sbin/gbde/Makefile1
-rw-r--r--sbin/geom/Makefile1
-rw-r--r--sbin/geom/class/cache/Makefile1
-rw-r--r--sbin/geom/class/concat/Makefile1
-rw-r--r--sbin/geom/class/eli/Makefile1
-rw-r--r--sbin/geom/class/journal/Makefile1
-rw-r--r--sbin/geom/class/label/Makefile1
-rw-r--r--sbin/geom/class/mirror/Makefile1
-rw-r--r--sbin/geom/class/mountver/Makefile1
-rw-r--r--sbin/geom/class/multipath/Makefile1
-rw-r--r--sbin/geom/class/nop/Makefile1
-rw-r--r--sbin/geom/class/part/Makefile1
-rw-r--r--sbin/geom/class/raid/Makefile1
-rw-r--r--sbin/geom/class/raid3/Makefile1
-rw-r--r--sbin/geom/class/sched/Makefile1
-rw-r--r--sbin/geom/class/shsec/Makefile1
-rw-r--r--sbin/geom/class/stripe/Makefile1
-rw-r--r--sbin/geom/class/virstor/Makefile1
-rw-r--r--sbin/geom/core/Makefile1
-rw-r--r--sbin/growfs/Makefile1
-rw-r--r--sbin/growfs/tests/Makefile4
-rw-r--r--sbin/gvinum/Makefile1
-rw-r--r--sbin/hastctl/Makefile1
-rw-r--r--sbin/hastd/Makefile1
-rw-r--r--sbin/ifconfig/Makefile1
-rw-r--r--sbin/ifconfig/tests/Makefile4
-rw-r--r--sbin/init/Makefile1
-rw-r--r--sbin/ipf/ipf/Makefile1
-rw-r--r--sbin/ipf/ipfs/Makefile1
-rw-r--r--sbin/ipf/ipfstat/Makefile1
-rw-r--r--sbin/ipf/ipftest/Makefile1
-rw-r--r--sbin/ipf/ipmon/Makefile1
-rw-r--r--sbin/ipf/ipnat/Makefile1
-rw-r--r--sbin/ipf/ippool/Makefile1
-rw-r--r--sbin/ipf/ipresend/Makefile1
-rw-r--r--sbin/ipf/libipf/Makefile1
-rw-r--r--sbin/ipfw/Makefile1
-rw-r--r--sbin/iscontrol/Makefile1
-rw-r--r--sbin/kldconfig/Makefile1
-rw-r--r--sbin/kldload/Makefile1
-rw-r--r--sbin/kldstat/Makefile1
-rw-r--r--sbin/kldunload/Makefile1
-rw-r--r--sbin/ldconfig/Makefile1
-rw-r--r--sbin/md5/Makefile1
-rw-r--r--sbin/mdconfig/Makefile1
-rw-r--r--sbin/mdconfig/tests/Makefile4
-rw-r--r--sbin/mdmfs/Makefile1
-rw-r--r--sbin/mknod/Makefile1
-rw-r--r--sbin/mksnap_ffs/Makefile1
-rw-r--r--sbin/mount/Makefile1
-rw-r--r--sbin/mount_cd9660/Makefile1
-rw-r--r--sbin/mount_fusefs/Makefile1
-rw-r--r--sbin/mount_msdosfs/Makefile1
-rw-r--r--sbin/mount_nfs/Makefile1
-rw-r--r--sbin/mount_nullfs/Makefile1
-rw-r--r--sbin/mount_udf/Makefile1
-rw-r--r--sbin/mount_unionfs/Makefile1
-rw-r--r--sbin/nandfs/Makefile1
-rw-r--r--sbin/natd/Makefile1
-rw-r--r--sbin/newfs_msdos/Makefile1
-rw-r--r--sbin/newfs_nandfs/Makefile1
-rw-r--r--sbin/nfsiod/Makefile1
-rw-r--r--sbin/nos-tun/Makefile1
-rw-r--r--sbin/nvmecontrol/Makefile1
-rw-r--r--sbin/pfctl/Makefile1
-rw-r--r--sbin/pflogd/Makefile1
-rw-r--r--sbin/ping/Makefile1
-rw-r--r--sbin/ping6/Makefile1
-rw-r--r--sbin/quotacheck/Makefile1
-rw-r--r--sbin/rcorder/Makefile1
-rw-r--r--sbin/reboot/Makefile1
-rw-r--r--sbin/recoverdisk/Makefile1
-rw-r--r--sbin/resolvconf/Makefile1
-rw-r--r--sbin/restore/Makefile1
-rw-r--r--sbin/route/Makefile1
-rw-r--r--sbin/routed/Makefile1
-rw-r--r--sbin/routed/rtquery/Makefile1
-rw-r--r--sbin/rtsol/Makefile1
-rw-r--r--sbin/savecore/Makefile1
-rw-r--r--sbin/sconfig/Makefile1
-rw-r--r--sbin/setkey/Makefile1
-rw-r--r--sbin/shutdown/Makefile1
-rw-r--r--sbin/swapon/Makefile1
-rw-r--r--sbin/sysctl/Makefile1
-rw-r--r--sbin/tests/Makefile5
-rw-r--r--sbin/tunefs/Makefile1
-rw-r--r--sbin/umount/Makefile1
-rw-r--r--secure/lib/libssh/Makefile1
-rw-r--r--secure/lib/tests/Makefile5
-rw-r--r--secure/libexec/Makefile.inc1
-rw-r--r--secure/libexec/tests/Makefile5
-rw-r--r--secure/tests/Makefile5
-rw-r--r--secure/usr.bin/scp/Makefile1
-rw-r--r--secure/usr.bin/sftp/Makefile1
-rw-r--r--secure/usr.bin/ssh-add/Makefile1
-rw-r--r--secure/usr.bin/ssh-agent/Makefile1
-rw-r--r--secure/usr.bin/ssh-keygen/Makefile1
-rw-r--r--secure/usr.bin/ssh-keyscan/Makefile1
-rw-r--r--secure/usr.bin/ssh/Makefile1
-rw-r--r--secure/usr.bin/tests/Makefile5
-rw-r--r--secure/usr.sbin/sshd/Makefile1
-rw-r--r--secure/usr.sbin/tests/Makefile5
-rw-r--r--share/examples/Makefile3
-rw-r--r--share/examples/tests/Makefile5
-rw-r--r--share/examples/tests/tests/Makefile4
-rw-r--r--share/examples/tests/tests/atf/Makefile5
-rw-r--r--share/examples/tests/tests/plain/Makefile5
-rw-r--r--share/man/man1/Makefile2
-rw-r--r--share/man/man3/Makefile2
-rw-r--r--share/man/man4/Makefile2
-rw-r--r--share/man/man4/man4.arm/Makefile2
-rw-r--r--share/man/man4/man4.i386/Makefile2
-rw-r--r--share/man/man4/man4.powerpc/Makefile2
-rw-r--r--share/man/man4/man4.sparc64/Makefile2
-rw-r--r--share/man/man5/Makefile2
-rw-r--r--share/man/man6/Makefile2
-rw-r--r--share/man/man7/Makefile2
-rw-r--r--share/man/man8/Makefile2
-rw-r--r--share/man/man9/Makefile2
-rw-r--r--share/mk/bsd.doc.mk11
-rw-r--r--share/mk/bsd.files.mk14
-rw-r--r--share/mk/bsd.incs.mk14
-rw-r--r--share/mk/bsd.lib.mk43
-rw-r--r--share/mk/bsd.links.mk13
-rw-r--r--share/mk/bsd.man.mk5
-rw-r--r--share/mk/bsd.prog.mk15
-rw-r--r--share/mk/bsd.test.mk1
-rw-r--r--share/sendmail/Makefile1
-rw-r--r--share/syscons/Makefile.inc3
-rw-r--r--share/tests/Makefile4
-rw-r--r--sys/conf/kmod.mk4
-rw-r--r--sys/modules/tests/callout_test/Makefile4
-rw-r--r--sys/modules/tests/framework/Makefile4
-rw-r--r--tests/Makefile5
-rw-r--r--tests/etc/Makefile5
-rw-r--r--tests/etc/rc.d/Makefile3
-rw-r--r--tests/sys/Makefile3
-rw-r--r--tests/sys/acl/Makefile3
-rw-r--r--tests/sys/aio/Makefile3
-rw-r--r--tests/sys/fifo/Makefile3
-rw-r--r--tests/sys/file/Makefile3
-rw-r--r--tests/sys/geom/Makefile3
-rw-r--r--tests/sys/geom/class/Makefile3
-rw-r--r--tests/sys/geom/class/concat/Makefile4
-rw-r--r--tests/sys/geom/class/eli/Makefile4
-rw-r--r--tests/sys/geom/class/gate/Makefile4
-rw-r--r--tests/sys/geom/class/mirror/Makefile4
-rw-r--r--tests/sys/geom/class/nop/Makefile4
-rw-r--r--tests/sys/geom/class/raid3/Makefile4
-rw-r--r--tests/sys/geom/class/shsec/Makefile4
-rw-r--r--tests/sys/geom/class/stripe/Makefile4
-rw-r--r--tests/sys/geom/class/uzip/Makefile7
-rw-r--r--tests/sys/kern/Makefile3
-rw-r--r--tests/sys/kern/acct/Makefile3
-rw-r--r--tests/sys/kern/execve/Makefile3
-rw-r--r--tests/sys/kern/pipe/Makefile3
-rw-r--r--tests/sys/kqueue/Makefile3
-rw-r--r--tests/sys/mac/Makefile3
-rw-r--r--tests/sys/mac/bsdextended/Makefile3
-rw-r--r--tests/sys/mac/portacl/Makefile3
-rw-r--r--tests/sys/mqueue/Makefile3
-rw-r--r--tests/sys/netinet/Makefile3
-rw-r--r--tests/sys/opencrypto/Makefile3
-rw-r--r--tests/sys/pjdfstest/Makefile3
-rw-r--r--tests/sys/pjdfstest/pjdfstest/Makefile3
-rw-r--r--tests/sys/pjdfstest/tests/Makefile3
-rw-r--r--tests/sys/pjdfstest/tests/chflags/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/chmod/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/chown/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/ftruncate/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/granular/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/link/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/mkdir/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/mkfifo/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/mknod/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/open/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/rename/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/rmdir/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/symlink/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/truncate/Makefile4
-rw-r--r--tests/sys/pjdfstest/tests/unlink/Makefile4
-rw-r--r--tests/sys/posixshm/Makefile3
-rw-r--r--tests/sys/vfs/Makefile3
-rw-r--r--tests/sys/vm/Makefile3
-rw-r--r--usr.bin/apply/tests/Makefile4
-rw-r--r--usr.bin/at/Makefile.inc1
-rw-r--r--usr.bin/basename/tests/Makefile4
-rw-r--r--usr.bin/bmake/tests/Makefile3
-rw-r--r--usr.bin/bmake/tests/archives/Makefile3
-rw-r--r--usr.bin/bmake/tests/archives/fmt_44bsd/Makefile3
-rw-r--r--usr.bin/bmake/tests/archives/fmt_44bsd_mod/Makefile3
-rw-r--r--usr.bin/bmake/tests/archives/fmt_oldbsd/Makefile3
-rw-r--r--usr.bin/bmake/tests/basic/Makefile3
-rw-r--r--usr.bin/bmake/tests/basic/t0/Makefile3
-rw-r--r--usr.bin/bmake/tests/basic/t1/Makefile3
-rw-r--r--usr.bin/bmake/tests/basic/t2/Makefile3
-rw-r--r--usr.bin/bmake/tests/basic/t3/Makefile3
-rw-r--r--usr.bin/bmake/tests/execution/Makefile3
-rw-r--r--usr.bin/bmake/tests/execution/ellipsis/Makefile3
-rw-r--r--usr.bin/bmake/tests/execution/empty/Makefile3
-rw-r--r--usr.bin/bmake/tests/execution/joberr/Makefile3
-rw-r--r--usr.bin/bmake/tests/execution/plus/Makefile3
-rw-r--r--usr.bin/bmake/tests/shell/Makefile3
-rw-r--r--usr.bin/bmake/tests/shell/builtin/Makefile3
-rw-r--r--usr.bin/bmake/tests/shell/meta/Makefile3
-rw-r--r--usr.bin/bmake/tests/shell/path/Makefile3
-rw-r--r--usr.bin/bmake/tests/shell/path_select/Makefile3
-rw-r--r--usr.bin/bmake/tests/shell/replace/Makefile3
-rw-r--r--usr.bin/bmake/tests/shell/select/Makefile3
-rw-r--r--usr.bin/bmake/tests/suffixes/Makefile3
-rw-r--r--usr.bin/bmake/tests/suffixes/basic/Makefile3
-rw-r--r--usr.bin/bmake/tests/suffixes/src_wild1/Makefile3
-rw-r--r--usr.bin/bmake/tests/suffixes/src_wild2/Makefile3
-rw-r--r--usr.bin/bmake/tests/syntax/Makefile3
-rw-r--r--usr.bin/bmake/tests/syntax/directive-t0/Makefile3
-rw-r--r--usr.bin/bmake/tests/syntax/enl/Makefile3
-rw-r--r--usr.bin/bmake/tests/syntax/funny-targets/Makefile3
-rw-r--r--usr.bin/bmake/tests/syntax/semi/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t0/2/1/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t0/2/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t0/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t0/mk/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t1/2/1/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t1/2/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t1/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t1/mk/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t2/2/1/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t2/2/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t2/Makefile3
-rw-r--r--usr.bin/bmake/tests/sysmk/t2/mk/Makefile3
-rw-r--r--usr.bin/bmake/tests/variables/Makefile3
-rw-r--r--usr.bin/bmake/tests/variables/modifier_M/Makefile3
-rw-r--r--usr.bin/bmake/tests/variables/modifier_t/Makefile3
-rw-r--r--usr.bin/bmake/tests/variables/opt_V/Makefile3
-rw-r--r--usr.bin/bmake/tests/variables/t0/Makefile3
-rw-r--r--usr.bin/calendar/tests/Makefile3
-rw-r--r--usr.bin/chpass/Makefile16
-rw-r--r--usr.bin/clang/clang.prog.mk2
-rw-r--r--usr.bin/cmp/tests/Makefile4
-rw-r--r--usr.bin/col/tests/Makefile4
-rw-r--r--usr.bin/comm/tests/Makefile4
-rw-r--r--usr.bin/cpio/tests/Makefile4
-rw-r--r--usr.bin/cut/tests/Makefile4
-rw-r--r--usr.bin/dirname/tests/Makefile4
-rw-r--r--usr.bin/ee/Makefile1
-rw-r--r--usr.bin/file2c/tests/Makefile4
-rw-r--r--usr.bin/grep/tests/Makefile4
-rw-r--r--usr.bin/gzip/tests/Makefile4
-rw-r--r--usr.bin/ident/tests/Makefile4
-rw-r--r--usr.bin/iscsictl/Makefile1
-rw-r--r--usr.bin/join/tests/Makefile4
-rw-r--r--usr.bin/jot/tests/Makefile4
-rw-r--r--usr.bin/lastcomm/Makefile2
-rw-r--r--usr.bin/lastcomm/tests/Makefile4
-rw-r--r--usr.bin/limits/tests/Makefile4
-rw-r--r--usr.bin/m4/tests/Makefile4
-rw-r--r--usr.bin/mkimg/tests/Makefile4
-rw-r--r--usr.bin/ncal/tests/Makefile4
-rw-r--r--usr.bin/passwd/Makefile8
-rw-r--r--usr.bin/printf/tests/Makefile4
-rw-r--r--usr.bin/rlogin/Makefile2
-rw-r--r--usr.bin/rsh/Makefile2
-rw-r--r--usr.bin/ruptime/Makefile2
-rw-r--r--usr.bin/rwho/Makefile2
-rw-r--r--usr.bin/sed/tests/Makefile4
-rw-r--r--usr.bin/sed/tests/regress.multitest.out/Makefile3
-rw-r--r--usr.bin/soelim/tests/Makefile4
-rw-r--r--usr.bin/ssh-copy-id/Makefile1
-rw-r--r--usr.bin/svn/Makefile.inc2
-rw-r--r--usr.bin/tar/tests/Makefile4
-rw-r--r--usr.bin/tests/Makefile5
-rw-r--r--usr.bin/timeout/tests/Makefile3
-rw-r--r--usr.bin/tr/tests/Makefile3
-rw-r--r--usr.bin/truncate/tests/Makefile4
-rw-r--r--usr.bin/units/tests/Makefile4
-rw-r--r--usr.bin/uudecode/tests/Makefile4
-rw-r--r--usr.bin/uuencode/tests/Makefile4
-rw-r--r--usr.bin/vi/Makefile1
-rw-r--r--usr.bin/vi/catalog/Makefile5
-rw-r--r--usr.bin/xargs/tests/Makefile4
-rw-r--r--usr.bin/xo/tests/Makefile4
-rw-r--r--usr.bin/yacc/tests/Makefile10
-rw-r--r--usr.sbin/accton/Makefile2
-rw-r--r--usr.sbin/acpi/Makefile.inc2
-rw-r--r--usr.sbin/amd/Makefile.inc2
-rw-r--r--usr.sbin/apm/Makefile2
-rw-r--r--usr.sbin/apmd/Makefile2
-rw-r--r--usr.sbin/autofs/Makefile1
-rw-r--r--usr.sbin/bhyve/Makefile1
-rw-r--r--usr.sbin/bhyvectl/Makefile1
-rw-r--r--usr.sbin/bhyveload/Makefile1
-rw-r--r--usr.sbin/bsdinstall/Makefile1
-rw-r--r--usr.sbin/bsdinstall/Makefile.inc1
-rw-r--r--usr.sbin/bsnmpd/Makefile.inc1
-rw-r--r--usr.sbin/bsnmpd/modules/Makefile.inc1
-rw-r--r--usr.sbin/bsnmpd/tools/Makefile.inc1
-rw-r--r--usr.sbin/chown/tests/Makefile4
-rw-r--r--usr.sbin/etcupdate/tests/Makefile4
-rw-r--r--usr.sbin/fstyp/tests/Makefile4
-rw-r--r--usr.sbin/iscsid/Makefile1
-rw-r--r--usr.sbin/jail/Makefile2
-rw-r--r--usr.sbin/jexec/Makefile2
-rw-r--r--usr.sbin/jls/Makefile2
-rw-r--r--usr.sbin/makefs/tests/Makefile4
-rw-r--r--usr.sbin/newsyslog/tests/Makefile4
-rw-r--r--usr.sbin/nmtree/tests/Makefile4
-rw-r--r--usr.sbin/pw/tests/Makefile4
-rw-r--r--usr.sbin/rpcbind/tests/Makefile4
-rw-r--r--usr.sbin/rwhod/Makefile2
-rw-r--r--usr.sbin/sa/Makefile2
-rw-r--r--usr.sbin/sa/tests/Makefile4
-rw-r--r--usr.sbin/sendmail/Makefile1
-rw-r--r--usr.sbin/tests/Makefile5
-rw-r--r--usr.sbin/unbound/Makefile.inc1
668 files changed, 7225 insertions, 129 deletions
diff --git a/Makefile b/Makefile
index a80dec9..d18eede 100644
--- a/Makefile
+++ b/Makefile
@@ -126,7 +126,9 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
_build-tools _cross-tools _includes _libraries _depend \
build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
- xdev-links native-xtools installconfig \
+ xdev-links native-xtools stageworld stagekernel stage-packages \
+ create-world-packages create-kernel-packages create-packages \
+ packages installconfig real-packages sign-packages package-pkg
TGTS+= ${SUBDIR_TARGETS}
diff --git a/Makefile.inc1 b/Makefile.inc1
index 85e1a60..40bc9fe 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -188,6 +188,21 @@ VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE
.export VERSION
.endif
+.if !defined(PKG_VERSION)
+REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
+BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
+SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
+ ${SRCDIR}/sys/sys/param.h
+.if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
+TIMENOW= %Y%m%d%H%M%S
+EXTRA_REVISION= .s${TIMENOW:gmtime}
+.endif
+.if ${BRANCH:M*-p*}
+EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
+.endif
+PKG_VERSION= ${REVISION}${EXTRA_REVISION}
+.endif
+
KNOWN_ARCHES?= aarch64/arm64 \
amd64 \
arm \
@@ -256,10 +271,15 @@ TMPPATH= ${STRICTTMPPATH}:${PATH}
# It may not be functional, e.g., due to new ABI
# when in the middle of installing over this system.
#
-.if make(distributeworld) || make(installworld)
+.if make(distributeworld) || make(installworld) || make(stageworld)
INSTALLTMP!= /usr/bin/mktemp -d -u -t install
.endif
+.if make(stagekernel) || make(distributekernel)
+TAGS+= kernel
+PACKAGE= kernel
+.endif
+
#
# Building a world goes through the following stages
#
@@ -542,6 +562,9 @@ IMAKE+= -DNO_ROOT METALOG=${METALOG}
INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
MTREEFLAGS+= -W
.endif
+.if defined(BUILD_PKGS)
+INSTALLFLAGS+= -h sha256
+.endif
.if defined(DB_FROM_SRC) || defined(NO_ROOT)
IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
@@ -933,7 +956,7 @@ DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
MTREE_MAGIC?= mtree 2.0
-distributeworld installworld: _installcheck_world
+distributeworld installworld stageworld: _installcheck_world
mkdir -p ${INSTALLTMP}
progs=$$(for prog in ${ITOOLS}; do \
if progpath=`which $$prog`; then \
@@ -1086,6 +1109,21 @@ reinstall: .MAKE .PHONY
${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
.endif
+restage: .MAKE .PHONY
+ @echo "--------------------------------------------------------------"
+ @echo ">>> Making hierarchy"
+ @echo "--------------------------------------------------------------"
+ ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
+ LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
+ @echo
+ @echo "--------------------------------------------------------------"
+ @echo ">>> Installing everything"
+ @echo "--------------------------------------------------------------"
+ ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
+.if defined(LIB32TMP) && ${MK_LIB32} != "no"
+ ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
+.endif
+
redistribute: .MAKE .PHONY
@echo "--------------------------------------------------------------"
@echo ">>> Distributing everything"
@@ -1259,7 +1297,7 @@ distributekernel distributekernel.debug:
.endif
mkdir -p ${DESTDIR}/${DISTDIR}
.if defined(NO_ROOT)
- echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
+ @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
.endif
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
@@ -1267,14 +1305,14 @@ distributekernel distributekernel.debug:
DESTDIR=${INSTALL_DDIR}/kernel \
${.TARGET:S/distributekernel/install/}
.if defined(NO_ROOT)
- sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
+ @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
${DESTDIR}/${DISTDIR}/kernel.meta
.endif
.endif
.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
.for _kernel in ${BUILDKERNELS:[2..-1]}
.if defined(NO_ROOT)
- echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
+ @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
.endif
cd ${KRNLOBJDIR}/${_kernel}; \
${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
@@ -1283,7 +1321,7 @@ distributekernel distributekernel.debug:
DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
${.TARGET:S/distributekernel/install/}
.if defined(NO_ROOT)
- sed -e 's|^./kernel|.|' \
+ @sed -e "s|^./kernel.${_kernel}|.|" \
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
.endif
@@ -1335,6 +1373,141 @@ packagekernel:
.endif
.endif
+stagekernel:
+ ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
+
+PORTSDIR?= /usr/ports
+WSTAGEDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
+KSTAGEDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
+REPODIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
+PKGSIGNKEY?= # empty
+
+_pkgbootstrap:
+.if !exists(${LOCALBASE}/sbin/pkg)
+ @env ASSUME_ALWAYS_YES=YES pkg bootstrap
+.endif
+
+packages:
+ ${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
+
+package-pkg:
+ rm -rf /tmp/ports.${TARGET} || :
+ env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${REVISION} \
+ PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
+ sh ${.CURDIR}/release/scripts/make-pkg-package.sh
+
+real-packages: stage-packages create-packages sign-packages
+
+stage-packages:
+ @mkdir -p ${WSTAGEDIR} ${KSTAGEDIR}
+ ${_+_}@cd ${.CURDIR}; \
+ ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} -DNO_ROOT -B stageworld ; \
+ ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} -DNO_ROOT -B stagekernel
+
+create-packages: _pkgbootstrap
+ @mkdir -p ${REPODIR}
+ ${_+_}@cd ${.CURDIR}; \
+ ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} \
+ PKG_VERSION=${PKG_VERSION} create-world-packages ; \
+ ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} \
+ PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
+ create-kernel-packages
+
+create-world-packages: _pkgbootstrap
+ @rm -f ${DESTDIR}/*.plist 2>/dev/null || :
+ @cd ${DESTDIR} ; \
+ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
+ ${DESTDIR}/METALOG
+ @for plist in ${DESTDIR}/*.plist; do \
+ plist=$${plist##*/} ; \
+ pkgname=$${plist%.plist} ; \
+ sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
+ -s ${SRCDIR} -u ${DESTDIR}/$${pkgname}.ucl ; \
+ done
+ @for plist in ${DESTDIR}/*.plist; do \
+ plist=$${plist##*/} ; \
+ pkgname=$${plist%.plist} ; \
+ awk -F\" ' \
+ /^name/ { printf("===> Creating %s-", $$2); next } \
+ /^version/ { print $$2; next } \
+ ' ${DESTDIR}/$${pkgname}.ucl ; \
+ pkg -o ABI_FILE=${DESTDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
+ create -M ${DESTDIR}/$${pkgname}.ucl \
+ -p ${DESTDIR}/$${pkgname}.plist \
+ -r ${DESTDIR} \
+ -o ${REPODIR}/$$(pkg -o ABI_FILE=${DESTDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
+ done
+
+create-kernel-packages: _pkgbootstrap
+.if exists(${DESTDIR}/kernel.meta)
+.for flavor in "" -debug
+ @cd ${DESTDIR}/${DISTDIR} ; \
+ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
+ -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
+ ${DESTDIR}/kernel.meta ; \
+ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
+ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
+ sed -e "s/%VERSION%/${PKG_VERSION}/" \
+ -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
+ -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
+ -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
+ -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
+ -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
+ ${SRCDIR}/release/packages/kernel.ucl \
+ > ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
+ awk -F\" ' \
+ /name/ { printf("===> Creating %s-", $$2); next } \
+ /version/ {print $$2; next } ' \
+ ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
+ pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
+ create -M ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
+ -p ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
+ -r ${DESTDIR}/${DISTDIR} \
+ -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
+.endfor
+.endif
+.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
+.for _kernel in ${BUILDKERNELS:[2..-1]}
+.if exists(${DESTDIR}/kernel.${_kernel}.meta)
+.for flavor in "" -debug
+ @cd ${DESTDIR}/kernel.${_kernel} ; \
+ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
+ -v kernel=yes -v _kernconf=${_kernel} \
+ ${DESTDIR}/kernel.${_kernel}.meta ; \
+ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
+ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
+ sed -e "s/%VERSION%/${PKG_VERSION}/" \
+ -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
+ -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
+ -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
+ -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
+ -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
+ ${SRCDIR}/release/packages/kernel.ucl \
+ > ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
+ awk -F\" ' \
+ /name/ { printf("===> Creating %s-", $$2); next } \
+ /version/ {print $$2; next } ' \
+ ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
+ pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
+ create -M ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
+ -p ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
+ -r ${DESTDIR}/kernel.${_kernel} \
+ -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
+.endfor
+.endif
+.endfor
+.endif
+
+sign-packages: _pkgbootstrap
+ @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
+ unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
+ pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
+ -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
+ ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
+ ${PKGSIGNKEY} ; \
+ ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
+ ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
+
#
#
# checkworld
diff --git a/bin/cat/Makefile b/bin/cat/Makefile
index 97e5812..39aaeeb 100644
--- a/bin/cat/Makefile
+++ b/bin/cat/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= cat
.if ${MK_TESTS} != "no"
diff --git a/bin/cat/tests/Makefile b/bin/cat/tests/Makefile
index f68513c..effd839 100644
--- a/bin/cat/tests/Makefile
+++ b/bin/cat/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= cat_test
FILESDIR= ${TESTSDIR}
diff --git a/bin/chflags/Makefile b/bin/chflags/Makefile
index 4457505..db9defd 100644
--- a/bin/chflags/Makefile
+++ b/bin/chflags/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$
+PACKAGE=runtime
PROG= chflags
.include <bsd.prog.mk>
diff --git a/bin/chio/Makefile b/bin/chio/Makefile
index 5157f65..ddb07d9 100644
--- a/bin/chio/Makefile
+++ b/bin/chio/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
# @(#)Makefile 8.1 (Berkeley) 6/6/93
+PACKAGE=runtime
PROG= chio
.include <bsd.prog.mk>
diff --git a/bin/chmod/Makefile b/bin/chmod/Makefile
index 71006d0..58b1afc 100644
--- a/bin/chmod/Makefile
+++ b/bin/chmod/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= chmod
.include <bsd.prog.mk>
diff --git a/bin/cp/Makefile b/bin/cp/Makefile
index 5a5e1a4..d20f60e 100644
--- a/bin/cp/Makefile
+++ b/bin/cp/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= cp
SRCS= cp.c utils.c
CFLAGS+= -DVM_AND_BUFFER_CACHE_SYNCHRONIZED -D_ACL_PRIVATE
diff --git a/bin/csh/Makefile b/bin/csh/Makefile
index deb6347..0c364c1 100644
--- a/bin/csh/Makefile
+++ b/bin/csh/Makefile
@@ -8,6 +8,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
TCSHDIR= ${.CURDIR}/../../contrib/tcsh
.PATH: ${TCSHDIR}
diff --git a/bin/date/Makefile b/bin/date/Makefile
index 56ce33a..fd7e401 100644
--- a/bin/date/Makefile
+++ b/bin/date/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= date
SRCS= date.c netdate.c vary.c
diff --git a/bin/date/tests/Makefile b/bin/date/tests/Makefile
index ecce803..cffb43f 100644
--- a/bin/date/tests/Makefile
+++ b/bin/date/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= format_string_test
.include <bsd.test.mk>
diff --git a/bin/dd/Makefile b/bin/dd/Makefile
index 6b17d29..df877c8 100644
--- a/bin/dd/Makefile
+++ b/bin/dd/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= dd
SRCS= args.c conv.c conv_tab.c dd.c misc.c position.c
diff --git a/bin/dd/tests/Makefile b/bin/dd/tests/Makefile
index dd04af9..ad97671 100644
--- a/bin/dd/tests/Makefile
+++ b/bin/dd/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= dd_test
.include <netbsd-tests.test.mk>
diff --git a/bin/df/Makefile b/bin/df/Makefile
index 5cdae9e..8f9f528 100644
--- a/bin/df/Makefile
+++ b/bin/df/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.3 (Berkeley) 5/8/95
# $FreeBSD$
+PACKAGE=runtime
MOUNT= ${.CURDIR}/../../sbin/mount
.PATH: ${MOUNT}
diff --git a/bin/domainname/Makefile b/bin/domainname/Makefile
index 724bd06..d3bace8 100644
--- a/bin/domainname/Makefile
+++ b/bin/domainname/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= domainname
.include <bsd.prog.mk>
diff --git a/bin/echo/Makefile b/bin/echo/Makefile
index d00d467..5d48e21 100644
--- a/bin/echo/Makefile
+++ b/bin/echo/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= echo
.include <bsd.prog.mk>
diff --git a/bin/ed/Makefile b/bin/ed/Makefile
index bef3ff1..40e0613 100644
--- a/bin/ed/Makefile
+++ b/bin/ed/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= ed
SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c
LINKS= ${BINDIR}/ed ${BINDIR}/red
diff --git a/bin/expr/Makefile b/bin/expr/Makefile
index 1d741b7..471c1c0 100644
--- a/bin/expr/Makefile
+++ b/bin/expr/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= expr
SRCS= expr.y
YFLAGS=
diff --git a/bin/expr/tests/Makefile b/bin/expr/tests/Makefile
index 21b0e99..90331d0 100644
--- a/bin/expr/tests/Makefile
+++ b/bin/expr/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= expr_test
ATF_TESTS_SH_SED_expr_test+= -e 's/eval expr/eval expr --/g'
diff --git a/bin/freebsd-version/Makefile b/bin/freebsd-version/Makefile
index 91945ac..c49f661 100644
--- a/bin/freebsd-version/Makefile
+++ b/bin/freebsd-version/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
SCRIPTS = freebsd-version
MAN = freebsd-version.1
CLEANFILES = freebsd-version freebsd-version.sh
diff --git a/bin/getfacl/Makefile b/bin/getfacl/Makefile
index b7b5e983..7b3f057 100644
--- a/bin/getfacl/Makefile
+++ b/bin/getfacl/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= getfacl
.include <bsd.prog.mk>
diff --git a/bin/hostname/Makefile b/bin/hostname/Makefile
index 3c7997f..9b0ecd7 100644
--- a/bin/hostname/Makefile
+++ b/bin/hostname/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= hostname
.include <bsd.prog.mk>
diff --git a/bin/kenv/Makefile b/bin/kenv/Makefile
index 33a6dfc..9c1924a 100644
--- a/bin/kenv/Makefile
+++ b/bin/kenv/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= kenv
.include <bsd.prog.mk>
diff --git a/bin/kill/Makefile b/bin/kill/Makefile
index 55ef16d..4c9cdda 100644
--- a/bin/kill/Makefile
+++ b/bin/kill/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= kill
.include <bsd.prog.mk>
diff --git a/bin/ln/Makefile b/bin/ln/Makefile
index b541f8b..d7c8b46 100644
--- a/bin/ln/Makefile
+++ b/bin/ln/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.2 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= ln
MAN= ln.1 symlink.7
diff --git a/bin/ls/Makefile b/bin/ls/Makefile
index e57bf35..db3fae7e 100644
--- a/bin/ls/Makefile
+++ b/bin/ls/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= ls
SRCS= cmp.c ls.c print.c util.c
LIBADD= xo util
diff --git a/bin/ls/tests/Makefile b/bin/ls/tests/Makefile
index 89a2e8c..2c3045b 100644
--- a/bin/ls/tests/Makefile
+++ b/bin/ls/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH+= ls_tests
# This seems like overkill, but the idea in mind is that all of the testcases
# should be runnable as !root
diff --git a/bin/mkdir/Makefile b/bin/mkdir/Makefile
index fadc6b2..4587628 100644
--- a/bin/mkdir/Makefile
+++ b/bin/mkdir/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= mkdir
.include <bsd.prog.mk>
diff --git a/bin/mv/Makefile b/bin/mv/Makefile
index 02a5a48..e82466b 100644
--- a/bin/mv/Makefile
+++ b/bin/mv/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= mv
.if ${MK_TESTS} != "no"
diff --git a/bin/mv/tests/Makefile b/bin/mv/tests/Makefile
index 229d96e..62bc207 100644
--- a/bin/mv/tests/Makefile
+++ b/bin/mv/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
.include <bsd.test.mk>
diff --git a/bin/pax/Makefile b/bin/pax/Makefile
index c00d52c..210137b 100644
--- a/bin/pax/Makefile
+++ b/bin/pax/Makefile
@@ -27,6 +27,7 @@
# regex routines and must define NET2_REGEX.
# Pax may not compile if this not (un)defined properly.
+PACKAGE=runtime
PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c \
gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c \
diff --git a/bin/pax/tests/Makefile b/bin/pax/tests/Makefile
index 8334fea..6e22087 100644
--- a/bin/pax/tests/Makefile
+++ b/bin/pax/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_PERL= legacy_test
.include <bsd.test.mk>
diff --git a/bin/pkill/Makefile b/bin/pkill/Makefile
index 2985b37..2eb3ede 100644
--- a/bin/pkill/Makefile
+++ b/bin/pkill/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= pkill
LIBADD= kvm jail
diff --git a/bin/pkill/tests/Makefile b/bin/pkill/tests/Makefile
index be46707..d6edfae 100644
--- a/bin/pkill/tests/Makefile
+++ b/bin/pkill/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= pgrep-F_test
TAP_TESTS_SH+= pgrep-LF_test
TAP_TESTS_SH+= pgrep-P_test
diff --git a/bin/ps/Makefile b/bin/ps/Makefile
index 79e9fc6..596aa57 100644
--- a/bin/ps/Makefile
+++ b/bin/ps/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
# @(#)Makefile 8.1 (Berkeley) 6/2/93
+PACKAGE=runtime
PROG= ps
SRCS= fmt.c keyword.c nlist.c print.c ps.c
diff --git a/bin/pwait/Makefile b/bin/pwait/Makefile
index cdf322e..a282c18 100644
--- a/bin/pwait/Makefile
+++ b/bin/pwait/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= pwait
.include <bsd.prog.mk>
diff --git a/bin/pwd/Makefile b/bin/pwd/Makefile
index 4a8e66a..2a623a1 100644
--- a/bin/pwd/Makefile
+++ b/bin/pwd/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= pwd
.include <bsd.prog.mk>
diff --git a/bin/rcp/Makefile b/bin/rcp/Makefile
index 886ec01..6c1cfb1 100644
--- a/bin/rcp/Makefile
+++ b/bin/rcp/Makefile
@@ -1,10 +1,13 @@
# @(#)Makefile 8.1 (Berkeley) 7/19/93
# $FreeBSD$
+PACKAGE=rcmds
PROG= rcp
SRCS= rcp.c util.c
CFLAGS+=-DBINDIR=${BINDIR}
+PACKAGE=rcmds
+
BINOWN= root
BINMODE=4555
diff --git a/bin/realpath/Makefile b/bin/realpath/Makefile
index acf62c7..71381f3 100644
--- a/bin/realpath/Makefile
+++ b/bin/realpath/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= realpath
.include <bsd.prog.mk>
diff --git a/bin/rm/Makefile b/bin/rm/Makefile
index 7058fa0..e0d2713 100644
--- a/bin/rm/Makefile
+++ b/bin/rm/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= rm
LINKS= ${BINDIR}/rm ${BINDIR}/unlink
diff --git a/bin/rmail/Makefile b/bin/rmail/Makefile
index 421a6ff..53d0ca4 100644
--- a/bin/rmail/Makefile
+++ b/bin/rmail/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=sendmail
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
.PATH: ${SENDMAIL_DIR}/rmail
diff --git a/bin/rmdir/Makefile b/bin/rmdir/Makefile
index c2c7f30..a40686d 100644
--- a/bin/rmdir/Makefile
+++ b/bin/rmdir/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= rmdir
.include <bsd.prog.mk>
diff --git a/bin/setfacl/Makefile b/bin/setfacl/Makefile
index 3f6b78e..3785413 100644
--- a/bin/setfacl/Makefile
+++ b/bin/setfacl/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= setfacl
SRCS= file.c mask.c merge.c remove.c setfacl.c util.c
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index 3f28a12..419ff79 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= sh
INSTALLFLAGS= -S
SHSRCS= alias.c arith_yacc.c arith_yylex.c cd.c echo.c error.c eval.c \
diff --git a/bin/sh/tests/Makefile b/bin/sh/tests/Makefile
index d93e19a..58834a4 100644
--- a/bin/sh/tests/Makefile
+++ b/bin/sh/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TESTS_SUBDIRS+= builtins
TESTS_SUBDIRS+= errors
TESTS_SUBDIRS+= execution
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile
index 8292665..11cea5f 100644
--- a/bin/sh/tests/builtins/Makefile
+++ b/bin/sh/tests/builtins/Makefile
@@ -2,6 +2,9 @@
.include <src.opts.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
.PATH: ${.CURDIR:H}
diff --git a/bin/sh/tests/errors/Makefile b/bin/sh/tests/errors/Makefile
index 51a766f..f7c7e26 100644
--- a/bin/sh/tests/errors/Makefile
+++ b/bin/sh/tests/errors/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
.PATH: ${.CURDIR:H}
diff --git a/bin/sh/tests/execution/Makefile b/bin/sh/tests/execution/Makefile
index 638492b..64d12de 100644
--- a/bin/sh/tests/execution/Makefile
+++ b/bin/sh/tests/execution/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
.PATH: ${.CURDIR:H}
diff --git a/bin/sh/tests/expansion/Makefile b/bin/sh/tests/expansion/Makefile
index fb672da..351babd 100644
--- a/bin/sh/tests/expansion/Makefile
+++ b/bin/sh/tests/expansion/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
.PATH: ${.CURDIR:H}
diff --git a/bin/sh/tests/parameters/Makefile b/bin/sh/tests/parameters/Makefile
index 528697d..d510779 100644
--- a/bin/sh/tests/parameters/Makefile
+++ b/bin/sh/tests/parameters/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
.PATH: ${.CURDIR:H}
diff --git a/bin/sh/tests/parser/Makefile b/bin/sh/tests/parser/Makefile
index dd126ee..4f823b0 100644
--- a/bin/sh/tests/parser/Makefile
+++ b/bin/sh/tests/parser/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
.PATH: ${.CURDIR:H}
diff --git a/bin/sh/tests/set-e/Makefile b/bin/sh/tests/set-e/Makefile
index f733b60..3d7481d 100644
--- a/bin/sh/tests/set-e/Makefile
+++ b/bin/sh/tests/set-e/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
.PATH: ${.CURDIR:H}
diff --git a/bin/sleep/Makefile b/bin/sleep/Makefile
index 0ec3080..9575adf 100644
--- a/bin/sleep/Makefile
+++ b/bin/sleep/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= sleep
.if ${MK_TESTS} != "no"
diff --git a/bin/sleep/tests/Makefile b/bin/sleep/tests/Makefile
index 6fc95f3..615d80a 100644
--- a/bin/sleep/tests/Makefile
+++ b/bin/sleep/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= sleep_test
.include <bsd.test.mk>
diff --git a/bin/stty/Makefile b/bin/stty/Makefile
index 82b15eb..b10b895 100644
--- a/bin/stty/Makefile
+++ b/bin/stty/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= stty
SRCS= cchar.c gfmt.c key.c modes.c print.c stty.c util.c
diff --git a/bin/sync/Makefile b/bin/sync/Makefile
index 72c664f..8b56d6a 100644
--- a/bin/sync/Makefile
+++ b/bin/sync/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+PACKAGE=runtime
PROG= sync
MAN= sync.8
diff --git a/bin/test/Makefile b/bin/test/Makefile
index 8e3121b..5cd91eb 100644
--- a/bin/test/Makefile
+++ b/bin/test/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= test
LINKS= ${BINDIR}/test ${BINDIR}/[
MLINKS= test.1 [.1
diff --git a/bin/test/tests/Makefile b/bin/test/tests/Makefile
index a1a5d4f..aff93d8 100644
--- a/bin/test/tests/Makefile
+++ b/bin/test/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
# Some tests in here are silently not run when the tests are executed as
# root. Explicitly tell Kyua to drop privileges.
diff --git a/bin/tests/Makefile b/bin/tests/Makefile
index a0e63e5..609357e 100644
--- a/bin/tests/Makefile
+++ b/bin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/bin/uuidgen/Makefile b/bin/uuidgen/Makefile
index 0b27d20..8cd1598 100644
--- a/bin/uuidgen/Makefile
+++ b/bin/uuidgen/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= uuidgen
.include <bsd.prog.mk>
diff --git a/cddl/lib/tests/Makefile b/cddl/lib/tests/Makefile
index a0e63e5..609357e 100644
--- a/cddl/lib/tests/Makefile
+++ b/cddl/lib/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/cddl/sbin/tests/Makefile b/cddl/sbin/tests/Makefile
index a0e63e5..609357e 100644
--- a/cddl/sbin/tests/Makefile
+++ b/cddl/sbin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/cddl/tests/Makefile b/cddl/tests/Makefile
index a0e63e5..609357e 100644
--- a/cddl/tests/Makefile
+++ b/cddl/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/cddl/usr.bin/tests/Makefile b/cddl/usr.bin/tests/Makefile
index a0e63e5..609357e 100644
--- a/cddl/usr.bin/tests/Makefile
+++ b/cddl/usr.bin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/cddl/usr.sbin/tests/Makefile b/cddl/usr.sbin/tests/Makefile
index a0e63e5..609357e 100644
--- a/cddl/usr.sbin/tests/Makefile
+++ b/cddl/usr.sbin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/contrib/ntp/ntpd/ntp_control.c b/contrib/ntp/ntpd/ntp_control.c
index e5a567e..3c02218 100644
--- a/contrib/ntp/ntpd/ntp_control.c
+++ b/contrib/ntp/ntpd/ntp_control.c
@@ -3,6 +3,10 @@
* traps. Provides service to ntpq and others.
*/
+/*
+ * $FreeBSD: projects/release-pkg/contrib/ntp/ntpd/ntp_control.c 277386 2015-01-19 16:15:12Z gjb $
+ */
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/etc/Makefile b/etc/Makefile
index 27d1ba4..3de8f97 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -3,6 +3,8 @@
.include <src.opts.mk>
+FILESGROUPS= FILES
+
SUBDIR= \
newsyslog.conf.d
@@ -79,8 +81,13 @@ BIN1+= apmd.conf
.endif
.if ${MK_AUTOFS} != "no"
-BIN1+= auto_master
+FILESGROUPS+= AUTOFS
+AUTOFS+= auto_master
.endif
+AUTOFSDIR= /etc
+AUTOFSMODE= ${BINMODE}
+AUTOFSPACKAGE= autofs
+AUTOFSTAGS= config
.if ${MK_FREEBSD_UPDATE} != "no"
BIN1+= freebsd-update.conf
@@ -132,8 +139,12 @@ BIN1+= pf.os
.endif
.if ${MK_SENDMAIL} != "no"
-BIN1+= rc.sendmail
+FILESGROUPS+= SENDMAILRC
+SENDMAILRC= rc.sendmail
.endif
+SENDMAILRCDIR= /etc
+SENDMAILRCMODE= ${BINMODE}
+SENDMAILRCPACKAGE=sendmail
.if ${MK_TCSH} != "no"
BIN1+= csh.cshrc csh.login csh.logout
diff --git a/etc/devd/Makefile b/etc/devd/Makefile
index a0909af..d031f19 100644
--- a/etc/devd/Makefile
+++ b/etc/devd/Makefile
@@ -2,7 +2,7 @@
.include <src.opts.mk>
-FILES=
+FILEGROUPS= FILES
.if ${MACHINE} == "powerpc"
FILES+= apple.conf
@@ -10,7 +10,12 @@ FILES+= apple.conf
.if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
.if ${MK_ACPI} != "no"
-FILES+= asus.conf
+FILESGROUPS+= ACPI
+ACPI= asus.conf
+ACPIPACKAGE= acpi
+ACPIDIR= /etc/devd
+ACPITAGS= config
+ACPIMODE= 644
.endif
.if ${MK_HYPERV} != "no"
FILES+= hyperv.conf
diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist
index 3a58529..46b8dcd 100644
--- a/etc/mtree/BSD.var.dist
+++ b/etc/mtree/BSD.var.dist
@@ -9,9 +9,9 @@
..
at
/set uname=daemon
- jobs
+ jobs tags=package=at
..
- spool
+ spool tags=package=at
..
/set uname=root
..
@@ -99,8 +99,8 @@
vi.recover mode=01777
..
..
- unbound uname=unbound gname=unbound mode=0755
- conf.d uname=unbound gname=unbound mode=0755
+ unbound uname=unbound gname=unbound mode=0755 tags=package=unbound
+ conf.d uname=unbound gname=unbound mode=0755 tags=package=unbound
..
..
yp
diff --git a/etc/pam.d/Makefile b/etc/pam.d/Makefile
index ac7db6c..a9aea19 100644
--- a/etc/pam.d/Makefile
+++ b/etc/pam.d/Makefile
@@ -4,6 +4,8 @@
NO_OBJ=
+FILESGROUPS= FILES
+
FILES= README \
cron \
ftpd \
@@ -11,13 +13,24 @@ FILES= README \
login \
other \
passwd pop3 \
- rsh \
sshd su system \
telnetd \
xdm
.if ${MK_AT} != "no"
-FILES+= atrun
+FILESGROUPS+= AT
+AT+= atrun
+ATPACKAGE+= at
+ATDIR= /etc/pam.d
+ATMODE= 644
+.endif
+
+.if ${MK_RCMDS} != "no"
+FILESGROUPS+= RCMDS
+RCMDS+= rsh
+RCMDSPACKAGE+= rcmds
+RCMDSDIR= /etc/pam.d
+RCMDSMODE= 644
.endif
FILESDIR= /etc/pam.d
diff --git a/etc/periodic/daily/Makefile b/etc/periodic/daily/Makefile
index de0f8f2..d2052f2 100644
--- a/etc/periodic/daily/Makefile
+++ b/etc/periodic/daily/Makefile
@@ -2,6 +2,8 @@
.include <src.opts.mk>
+FILESGROUPS=FILES
+
FILES= 100.clean-disks \
110.clean-tmps \
120.clean-preserve \
@@ -23,8 +25,12 @@ FILES= 100.clean-disks \
# NB: keep these sorted by MK_* knobs
.if ${MK_ACCT} != "no"
-FILES+= 310.accounting
+FILESGROUPS+= ACCT
+ACCT+= 310.accounting
.endif
+ACCTDIR= /etc/periodic/daily
+ACCTMODE= ${BINMODE}
+ACCTPACKAGE= acct
.if ${MK_CALENDAR} != "no"
FILES+= 300.calendar
@@ -40,8 +46,12 @@ FILES+= 480.status-ntpd \
.endif
.if ${MK_RCMDS} != "no"
-FILES+= 140.clean-rwho
+FILESGROUPS+= RCMDS
+RCMDS+= 140.clean-rwho
.endif
+RCMDSDIR= /etc/periodic/daily
+RCMDSMODE= ${BINMODE}
+RCMDSPACKAGE= rcmds
.if ${MK_SENDMAIL} != "no"
FILES+= 150.clean-hoststat \
diff --git a/etc/periodic/monthly/Makefile b/etc/periodic/monthly/Makefile
index ea2bd9f..6464219 100644
--- a/etc/periodic/monthly/Makefile
+++ b/etc/periodic/monthly/Makefile
@@ -2,13 +2,19 @@
.include <src.opts.mk>
+FILESGROUPS=FILES
+
FILES= 450.status-security \
999.local
# NB: keep these sorted by MK_* knobs
.if ${MK_UTMPX} != "no"
-FILES+= 200.accounting
+FILESGROUPS+= ACCT
+ACCT+= 200.accounting
.endif
+ACCTDIR= /etc/periodic/monthly
+ACCTMODE= ${BINMODE}
+ACCTPACKAGE= acct
.include <bsd.prog.mk>
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
index 6cc860b..cd9405f 100644
--- a/etc/rc.d/Makefile
+++ b/etc/rc.d/Makefile
@@ -2,13 +2,16 @@
.include <src.opts.mk>
+FILESGROUPS= FILES
+FILESDIR= /etc/rc.d
+FILESMODE= ${BINMODE}
+
FILES= DAEMON \
FILESYSTEMS \
LOGIN \
NETWORKING \
SERVERS \
abi \
- accounting \
addswap \
adjkerntz \
archdep \
@@ -108,7 +111,6 @@ FILES= DAEMON \
securelevel \
serial \
sppp \
- ${_sshd} \
statd \
static_arp \
static_ndp \
@@ -120,7 +122,6 @@ FILES= DAEMON \
tmp \
${_ubthidhci} \
ugidfw \
- ${_unbound} \
${_utx} \
var \
watchdogd \
@@ -134,25 +135,41 @@ FILES= DAEMON \
zvol
.if ${MK_ACCT} != "no"
-FILES+= accounting
+FILESGROUPS+= ACCT
+ACCT+= accounting
.endif
+ACCTDIR= /etc/rc.d
+ACCTMODE= ${BINMODE}
+ACCTPACKAGE= acct
.if ${MK_ACPI} != "no"
-FILES+= power_profile
+FILESGROUPS+= ACPI
+ACPI= power_profile
.endif
+ACPIDIR= /etc/rc.d
+ACPIMODE= ${BINMODE}
+ACPIPACKAGE= acpi
.if ${MK_ACPI} != "no" || ${MK_APM} != "no"
FILES+= powerd
.endif
.if ${MK_AMD} != "no"
-FILES+= amd
+FILESGROUPS+= AMD
+AMD+= amd
.endif
+AMDDIR= /etc/rc.d
+AMDMODE= ${BINMODE}
+AMDPACKAGE= amd
.if ${MK_APM} != "no"
-FILES+= apm
-FILES+= apmd
+FILESGROUPS+= APM
+APM+= apm
+APM+= apmd
.endif
+APMDIR= /etc/rc.d
+APMMODE= ${BINMODE}
+APMPACKAGE= apm
.if ${MK_AUTOFS} != "no"
FILES+= automount
@@ -172,8 +189,12 @@ FILES+= bootparams
.endif
.if ${MK_BSNMP} != "no"
-FILES+= bsnmpd
+FILESGROUPS+= BSNMP
+BSNMP+= bsnmpd
.endif
+BSNMPDIR= /etc/rc.d
+BSNMPMODE= ${BINMODE}
+BSNMPPACKAGE= bsnmp
.if ${MK_CCD} != "no"
FILES+= ccd
@@ -184,8 +205,12 @@ FILES+= ftpd
.endif
.if ${MK_HAST} != "no"
-FILES+= hastd
+FILESGROUPS+= HAST
+HAST= hastd
.endif
+HASTDIR= /etc/rc.d
+HASTMODE= ${BINMODE}
+HASTPACKAGE= hast
.if ${MK_INETD} != "no"
FILES+= inetd
@@ -197,8 +222,12 @@ FILES+= iscsid
.endif
.if ${MK_JAIL} != "no"
-FILES+= jail
+FILESGROUPS+= JAIL
+JAIL+= jail
.endif
+JAILDIR= /etc/rc.d
+JAILMODE= ${BINMODE}
+JAILPACKAGE= jail
.if ${MK_LEGACY_CONSOLE} != "no"
FILES+= moused
@@ -239,47 +268,64 @@ FILES+= keyserv
.endif
.if ${MK_OPENSSH} != "no"
-_sshd= sshd
+FILESGROUPS+= SSH
+SSH= sshd
.endif
+SSHDIR= /etc/rc.d
+SSHMODE= ${BINMODE}
+SSHPACKAGE= ssh
.if ${MK_PF} != "no"
FILES+= ftp-proxy
.endif
.if ${MK_RCMDS} != "no"
-FILES+= rwho
+FILESGROUPS+= RCMDS
+RCMDS+= rwho
.endif
+RCMDSDIR= /etc/rc.d
+RCMDSMODE= ${BINMODE}
+RCMDSPACKAGE= rcmds
.if ${MK_ROUTED} != "no"
FILES+= routed
.endif
.if ${MK_SENDMAIL} != "no"
-FILES+= sendmail
+FILESGROUPS+= SMRCD
+SMRCD= sendmail
.endif
+SMRCDDIR= /etc/rc.d
+SMRCDDIRMODE= ${BINMODE}
+SMRCDPACKAGE= sendmail
.if ${MK_TIMED} != "no"
FILES+= timed
.endif
.if ${MK_UNBOUND} != "no"
-_unbound= local_unbound
+FILESGROUPS+= UNBOUND
+UNBOUND+= local_unbound
.endif
+UNBOUNDDIR= /etc/rc.d
+UNBOUNDMODE= ${BINMODE}
+UNBOUNDPACKAGE= unbound
.if ${MK_UTMPX} != "no"
_utx= utx
.endif
.if ${MK_VI} != "no"
-FILES+= virecover
+FILESGROUPS+= VI
+VI+= virecover
.endif
+VIDIR= /etc/rc.d
+VIMODE= ${BINMODE}
+VIPACKAGE= vi
.if ${MK_WIRELESS} != "no"
FILES+= hostapd
FILES+= wpa_supplicant
.endif
-FILESDIR= /etc/rc.d
-FILESMODE= ${BINMODE}
-
.include <bsd.prog.mk>
diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile
index f824bbc..4944acf 100644
--- a/gnu/lib/libgcc/Makefile
+++ b/gnu/lib/libgcc/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= clibs
GCCDIR= ${.CURDIR}/../../../contrib/gcc
GCCLIB= ${.CURDIR}/../../../contrib/gcclibs
COMPILERRTDIR= ${.CURDIR}/../../../contrib/compiler-rt
diff --git a/gnu/lib/tests/Makefile b/gnu/lib/tests/Makefile
index a0e63e5..609357e 100644
--- a/gnu/lib/tests/Makefile
+++ b/gnu/lib/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/gnu/tests/Makefile b/gnu/tests/Makefile
index a0e63e5..609357e 100644
--- a/gnu/tests/Makefile
+++ b/gnu/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/gnu/usr.bin/binutils/Makefile.inc b/gnu/usr.bin/binutils/Makefile.inc
index 1e2665f..aba3cc7 100644
--- a/gnu/usr.bin/binutils/Makefile.inc
+++ b/gnu/usr.bin/binutils/Makefile.inc
@@ -1,5 +1,6 @@
# $FreeBSD$
WARNS?= 3
+PACKAGE= binutils
.include "../Makefile.inc"
diff --git a/gnu/usr.bin/diff/tests/Makefile b/gnu/usr.bin/diff/tests/Makefile
index 16439b3..0b4ca2e 100644
--- a/gnu/usr.bin/diff/tests/Makefile
+++ b/gnu/usr.bin/diff/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/usr.bin/diff
NETBSD_ATF_TESTS_SH= diff_test
diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc
index 40ea69b..a27051c 100644
--- a/gnu/usr.bin/gdb/Makefile.inc
+++ b/gnu/usr.bin/gdb/Makefile.inc
@@ -3,6 +3,8 @@
VERSION= "6.1.1 [FreeBSD]"
VENDOR= marcel
+PACKAGE= gdb
+
BMAKE_GDB= ${.CURDIR}/..
BMAKE_ROOT= ${BMAKE_GDB}/..
BMAKE_BU= ${BMAKE_ROOT}/binutils
diff --git a/gnu/usr.bin/groff/Makefile.inc b/gnu/usr.bin/groff/Makefile.inc
index 67b61a8..24bcd98 100644
--- a/gnu/usr.bin/groff/Makefile.inc
+++ b/gnu/usr.bin/groff/Makefile.inc
@@ -2,6 +2,7 @@
BINDIR?= /usr/bin
SHELL= /bin/sh
+PACKAGE= groff
# Define `page' to be letter if your PostScript printer uses 8.5x11
# paper (USA) and define it to be A4, if it uses A4 paper (rest of the
diff --git a/gnu/usr.bin/tests/Makefile b/gnu/usr.bin/tests/Makefile
index a0e63e5..609357e 100644
--- a/gnu/usr.bin/tests/Makefile
+++ b/gnu/usr.bin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/include/Makefile b/include/Makefile
index 8033de1..d8213ef 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -5,6 +5,8 @@
.include <src.opts.mk>
+PACKAGE=runtime
+TAGS+= development
CLEANFILES= osreldate.h version
SUBDIR= arpa protocols rpcsvc rpc xlocale
SUBDIR_PARALLEL=
@@ -181,78 +183,78 @@ copies:
.endfor
.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS}
cd ${.CURDIR}/../sys; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
${DESTDIR}${INCLUDEDIR}/$i
.endfor
cd ${.CURDIR}/../sys/dev/acpica; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \
${DESTDIR}${INCLUDEDIR}/dev/acpica; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpi_hpet.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 acpi_hpet.h \
${DESTDIR}${INCLUDEDIR}/dev/acpica
cd ${.CURDIR}/../sys/dev/agp; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 agpreg.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 agpreg.h \
${DESTDIR}${INCLUDEDIR}/dev/agp
cd ${.CURDIR}/../sys/dev/bktr; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \
${DESTDIR}${INCLUDEDIR}/dev/bktr
.if ${MK_NAND} != "no"
cd ${.CURDIR}/../sys/dev/nand; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nandsim.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 nandsim.h \
${DESTDIR}${INCLUDEDIR}/dev/nand; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \
${DESTDIR}${INCLUDEDIR}/dev/nand
.endif
cd ${.CURDIR}/../sys/dev/pci; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \
${DESTDIR}${INCLUDEDIR}/dev/pci
cd ${.CURDIR}/../sys/fs/cd9660/; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/isofs/cd9660
.if ${MK_IPFILTER} != "no"
cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/netinet
.endif
.if ${MK_PF} != "no"
cd ${.CURDIR}/../sys/netpfil/pf; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/netpfil/pf
.endif
cd ${.CURDIR}/../sys/crypto; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 rijndael/rijndael.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 rijndael/rijndael.h \
${DESTDIR}${INCLUDEDIR}/crypto
cd ${.CURDIR}/../sys/opencrypto; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/crypto
cd ${.CURDIR}/../sys/${MACHINE}/include; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/machine
.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/machine/pc
.endif
.for _MARCH in ${_MARCHS}
.if exists(${.CURDIR}/../sys/${_MARCH}/include)
- ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
cd ${.CURDIR}/../sys/${_MARCH}/include; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/${_MARCH}
.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
- ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc
.endif
.endif
.endfor
cd ${.CURDIR}/../sys/rpc; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 types.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 types.h \
${DESTDIR}${INCLUDEDIR}/rpc
cd ${.CURDIR}/../sys/teken; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 teken.h \
+ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 teken.h \
${DESTDIR}${INCLUDEDIR}/teken
.if ${MK_DIRDEPS_BUILD} == "yes"
@touch ${.OBJDIR}/${.TARGET}
@@ -263,99 +265,99 @@ symlinks:
.for i in ${LDIRS}
cd ${.CURDIR}/../sys/$i; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
done
.endfor
.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci}
cd ${.CURDIR}/../sys/$i; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
done
.endfor
cd ${.CURDIR}/../sys/dev/acpica; \
for h in acpiio.h acpi_hpet.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/dev/acpica/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/acpica/$$h \
${DESTDIR}${INCLUDEDIR}/dev/acpica; \
done
cd ${.CURDIR}/../sys/dev/agp; \
for h in agpreg.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/dev/agp/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/agp/$$h \
${DESTDIR}${INCLUDEDIR}/dev/agp; \
done
cd ${.CURDIR}/../sys/dev/bktr; \
for h in ioctl_*.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/dev/bktr/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/bktr/$$h \
${DESTDIR}${INCLUDEDIR}/dev/bktr; \
done
.if ${MK_NAND} != "no"
cd ${.CURDIR}/../sys/dev/nand; \
for h in nandsim.h nand_dev.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/dev/nand/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/nand/$$h \
${DESTDIR}${INCLUDEDIR}/dev/nand; \
done
.endif
cd ${.CURDIR}/../sys/dev/pci; \
for h in pcireg.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/dev/pci/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/pci/$$h \
${DESTDIR}${INCLUDEDIR}/dev/pci; \
done
.for i in ${LSUBSUBDIRS}
cd ${.CURDIR}/../sys/$i; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
done
.endfor
.if ${MK_IPFILTER} != "no"
cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../sys/contrib/ipfilter/netinet/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/contrib/ipfilter/netinet/$$h \
${DESTDIR}${INCLUDEDIR}/netinet; \
done
.endif
.if ${MK_PF} != "no"
cd ${.CURDIR}/../sys/netpfil/pf; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/netpfil/pf/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/netpfil/pf/$$h \
${DESTDIR}${INCLUDEDIR}/netpfil/pf; \
done
.endif
cd ${.CURDIR}/../sys/crypto; \
for h in rijndael/rijndael.h; do \
- ${INSTALL_SYMLINK} ../../../sys/crypto/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/crypto/$$h \
${DESTDIR}${INCLUDEDIR}/crypto; \
done
cd ${.CURDIR}/../sys/opencrypto; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../sys/opencrypto/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/opencrypto/$$h \
${DESTDIR}${INCLUDEDIR}/crypto; \
done
cd ${.CURDIR}/../sys/${MACHINE}/include; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../sys/${MACHINE}/include/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/${MACHINE}/include/$$h \
${DESTDIR}${INCLUDEDIR}/machine; \
done
.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/${MACHINE}/include/pc/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/${MACHINE}/include/pc/$$h \
${DESTDIR}${INCLUDEDIR}/machine/pc; \
done
.endif
.for _MARCH in ${_MARCHS}
.if exists(${.CURDIR}/../sys/${_MARCH}/include)
- ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
cd ${.CURDIR}/../sys/${_MARCH}/include; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../sys/${_MARCH}/include/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/${_MARCH}/include/$$h \
${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
done
.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
- ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/${_MARCH}/include/pc/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/${_MARCH}/include/pc/$$h \
${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
done
.endif
@@ -363,12 +365,12 @@ symlinks:
.endfor
cd ${.CURDIR}/../sys/fs/cd9660; \
for h in *.h; do \
- ${INSTALL_SYMLINK} ../../../../sys/fs/cd9660/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/fs/cd9660/$$h \
${DESTDIR}${INCLUDEDIR}/isofs/cd9660; \
done
cd ${.CURDIR}/../sys/rpc; \
for h in types.h; do \
- ${INSTALL_SYMLINK} ../../../sys/rpc/$$h \
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/rpc/$$h \
${DESTDIR}${INCLUDEDIR}/rpc; \
done
.if ${MK_DIRDEPS_BUILD} == "yes"
diff --git a/lib/Makefile b/lib/Makefile
index cfa0ea9..cdcce90 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -148,6 +148,7 @@ SUBDIR_DEPEND_libpjdlog= libutil
SUBDIR_DEPEND_libprocstat= libkvm libutil
SUBDIR_DEPEND_libradius= libmd
SUBDIR_DEPEND_libsmb= libkiconv
+SUBDIR_DEPEND_libstdc++:= msun
SUBDIR_DEPEND_libtacplus= libmd
SUBDIR_DEPEND_libulog= libmd
SUBDIR_DEPEND_libunbound= ${_libldns}
diff --git a/lib/atf/libatf-c++/tests/Makefile b/lib/atf/libatf-c++/tests/Makefile
index a069bb1..bebc7ef 100644
--- a/lib/atf/libatf-c++/tests/Makefile
+++ b/lib/atf/libatf-c++/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.init.mk>
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TESTS_SUBDIRS= detail
ATF= ${SRCTOP}/contrib/atf
diff --git a/lib/atf/libatf-c++/tests/detail/Makefile b/lib/atf/libatf-c++/tests/detail/Makefile
index f7d672e..f194abf 100644
--- a/lib/atf/libatf-c++/tests/detail/Makefile
+++ b/lib/atf/libatf-c++/tests/detail/Makefile
@@ -2,6 +2,9 @@
.include <bsd.init.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c++/detail
ATF= ${SRCTOP}/contrib/atf
diff --git a/lib/atf/libatf-c/tests/Makefile b/lib/atf/libatf-c/tests/Makefile
index e864c2e..82d6db4 100644
--- a/lib/atf/libatf-c/tests/Makefile
+++ b/lib/atf/libatf-c/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.init.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TESTS_SUBDIRS= detail
ATF= ${SRCTOP}/contrib/atf
diff --git a/lib/atf/libatf-c/tests/detail/Makefile b/lib/atf/libatf-c/tests/detail/Makefile
index e47fd56..296d2dd 100644
--- a/lib/atf/libatf-c/tests/detail/Makefile
+++ b/lib/atf/libatf-c/tests/detail/Makefile
@@ -2,6 +2,11 @@
.include <bsd.init.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c/detail
ATF= ${SRCTOP}/contrib/atf
diff --git a/lib/atf/tests/Makefile b/lib/atf/tests/Makefile
index dc79bb3..ee99804 100644
--- a/lib/atf/tests/Makefile
+++ b/lib/atf/tests/Makefile
@@ -2,7 +2,12 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/lib/atf
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/lib/atf/tests/test-programs/Makefile b/lib/atf/tests/test-programs/Makefile
index aa30826..24f7b79 100644
--- a/lib/atf/tests/test-programs/Makefile
+++ b/lib/atf/tests/test-programs/Makefile
@@ -2,7 +2,11 @@
.include <bsd.init.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/lib/atf/test-programs
+TESTS+= Kyuafile
KYUAFILE= yes
ATF= ${SRCTOP}/contrib/atf
diff --git a/lib/lib80211/Makefile b/lib/lib80211/Makefile
index e00017e..fe103ce 100644
--- a/lib/lib80211/Makefile
+++ b/lib/lib80211/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= 80211
SHLIBDIR?= /lib
SHLIB_MAJOR= 1
diff --git a/lib/libalias/libalias/Makefile b/lib/libalias/libalias/Makefile
index 00b4ed8..feed9a8 100644
--- a/lib/libalias/libalias/Makefile
+++ b/lib/libalias/libalias/Makefile
@@ -2,6 +2,7 @@
.PATH: ${.CURDIR}/../../../sys/netinet/libalias
+PACKAGE=lib${LIB}
LIB= alias
SHLIBDIR?= /lib
SHLIB_MAJOR= 7
diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile
index 93749b9..6f0ccd1 100644
--- a/lib/libarchive/Makefile
+++ b/lib/libarchive/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
.include <src.opts.mk>
+PACKAGE=lib${LIB}
_LIBARCHIVEDIR= ${.CURDIR}/../../contrib/libarchive
LIB= archive
diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile
index 73ded3d..160ebb4 100644
--- a/lib/libarchive/tests/Makefile
+++ b/lib/libarchive/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
ATF_TESTS_SH+= functional_test
diff --git a/lib/libauditd/Makefile b/lib/libauditd/Makefile
index 10039e9..f8ed80a 100644
--- a/lib/libauditd/Makefile
+++ b/lib/libauditd/Makefile
@@ -2,6 +2,7 @@
# $FreeBSD$
#
+PACKAGE=lib${LIB}
OPENBSMDIR= ${.CURDIR}/../../contrib/openbsm
_LIBAUDITDDIR= ${OPENBSMDIR}/libauditd
_LIBBSMDIR= ${OPENBSMDIR}/libbsm
diff --git a/lib/libbegemot/Makefile b/lib/libbegemot/Makefile
index 27baf56..d278385 100644
--- a/lib/libbegemot/Makefile
+++ b/lib/libbegemot/Makefile
@@ -2,6 +2,7 @@
LIBBEGEMOT_DIR=${.CURDIR}/../../contrib/libbegemot
+PACKAGE=lib${LIB}
.PATH: ${LIBBEGEMOT_DIR}
LIB= begemot
diff --git a/lib/libblocksruntime/Makefile b/lib/libblocksruntime/Makefile
index f9539331..5933fb5 100644
--- a/lib/libblocksruntime/Makefile
+++ b/lib/libblocksruntime/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB:tl}
LIB= BlocksRuntime
SHLIB_MAJOR=0
CFLAGS+=-I${.CURDIR}
diff --git a/lib/libbluetooth/Makefile b/lib/libbluetooth/Makefile
index 7e21892..a8573ec 100644
--- a/lib/libbluetooth/Makefile
+++ b/lib/libbluetooth/Makefile
@@ -1,6 +1,7 @@
# $Id: Makefile,v 1.5 2003/07/22 18:38:04 max Exp $
# $FreeBSD$
+PACKAGE= lib${LIB}
LIB= bluetooth
MAN= bluetooth.3
diff --git a/lib/libbsdstat/Makefile b/lib/libbsdstat/Makefile
index aef0ec2..dea45f5 100644
--- a/lib/libbsdstat/Makefile
+++ b/lib/libbsdstat/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= lib${LIB}
LIB= bsdstat
SHLIB_MAJOR= 1
PRIVATELIB=
diff --git a/lib/libbsm/Makefile b/lib/libbsm/Makefile
index 037def7..4416227 100644
--- a/lib/libbsm/Makefile
+++ b/lib/libbsm/Makefile
@@ -2,6 +2,7 @@
# $FreeBSD$
#
+PACKAGE= lib${LIB}
OPENBSMDIR= ${.CURDIR}/../../contrib/openbsm
_LIBBSMDIR= ${OPENBSMDIR}/libbsm
diff --git a/lib/libbsnmp/Makefile.inc b/lib/libbsnmp/Makefile.inc
index 82f48ac..5c3fdad 100644
--- a/lib/libbsnmp/Makefile.inc
+++ b/lib/libbsnmp/Makefile.inc
@@ -2,5 +2,6 @@
NO_WERROR=
INCSDIR= ${INCLUDEDIR}/bsnmp
+PACKAGE= bsnmp
.include "../Makefile.inc"
diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile
index b505927..93c724e 100644
--- a/lib/libbz2/Makefile
+++ b/lib/libbz2/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= lib${LIB}
BZ2DIR= ${.CURDIR}/../../contrib/bzip2
.PATH: ${BZ2DIR}
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index 94e91b9..7794928 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE= clibs
_LIBCXXRTDIR= ${.CURDIR}/../../contrib/libcxxrt
HDRDIR= ${.CURDIR}/../../contrib/libc++/include
SRCDIR= ${.CURDIR}/../../contrib/libc++/src
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index 707fc1a..17b9720 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.2 (Berkeley) 2/3/94
# $FreeBSD$
+PACKAGE= clibs
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile
index ff1af55..8276422 100644
--- a/lib/libc/tests/Makefile
+++ b/lib/libc/tests/Makefile
@@ -2,6 +2,10 @@
.include <src.opts.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
SUBDIR= tls_dso
TESTS_SUBDIRS= c063
diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile
index 05da6ea..7790628 100644
--- a/lib/libc/tests/c063/Makefile
+++ b/lib/libc/tests/c063/Makefile
@@ -2,6 +2,10 @@
#TODO: t_o_search
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_C= faccessat_test
NETBSD_ATF_TESTS_C+= fchmodat_test
NETBSD_ATF_TESTS_C+= fchownat_test
diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile
index eb0ce39..ffe90d0 100644
--- a/lib/libc/tests/db/Makefile
+++ b/lib/libc/tests/db/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
BINDIR= ${TESTSDIR}
PROGS= h_db
diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile
index 0830977..b4e14d9 100644
--- a/lib/libc/tests/gen/Makefile
+++ b/lib/libc/tests/gen/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= arc4random_test
ATF_TESTS_C+= fmtcheck2_test
ATF_TESTS_C+= fmtmsg_test
diff --git a/lib/libc/tests/gen/execve/Makefile b/lib/libc/tests/gen/execve/Makefile
index 5e8bc6f..a9800db 100644
--- a/lib/libc/tests/gen/execve/Makefile
+++ b/lib/libc/tests/gen/execve/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_C= execve_test
.include "../../Makefile.netbsd-tests"
diff --git a/lib/libc/tests/gen/posix_spawn/Makefile b/lib/libc/tests/gen/posix_spawn/Makefile
index 9b687c6..659f73b 100644
--- a/lib/libc/tests/gen/posix_spawn/Makefile
+++ b/lib/libc/tests/gen/posix_spawn/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
BINDIR= ${TESTSDIR}
NETBSD_ATF_TESTS_C= fileactions_test
diff --git a/lib/libc/tests/hash/Makefile b/lib/libc/tests/hash/Makefile
index 6facb5a..188ba7f 100644
--- a/lib/libc/tests/hash/Makefile
+++ b/lib/libc/tests/hash/Makefile
@@ -2,6 +2,10 @@
.include <src.opts.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_C=
.if ${MK_OPENSSL} != "no"
diff --git a/lib/libc/tests/inet/Makefile b/lib/libc/tests/inet/Makefile
index ee6f98e..f061508 100644
--- a/lib/libc/tests/inet/Makefile
+++ b/lib/libc/tests/inet/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_C= inet_network_test
.include "../Makefile.netbsd-tests"
diff --git a/lib/libc/tests/locale/Makefile b/lib/libc/tests/locale/Makefile
index e05cbae..5a5954a 100644
--- a/lib/libc/tests/locale/Makefile
+++ b/lib/libc/tests/locale/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= btowc_test
ATF_TESTS_C+= c16rtomb_test
ATF_TESTS_C+= iswctype_test
diff --git a/lib/libc/tests/net/Makefile b/lib/libc/tests/net/Makefile
index e126848..56710c1 100644
--- a/lib/libc/tests/net/Makefile
+++ b/lib/libc/tests/net/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= ether_test
ATF_TESTS_C+= eui64_aton_test
ATF_TESTS_C+= eui64_ntoa_test
diff --git a/lib/libc/tests/nss/Makefile b/lib/libc/tests/nss/Makefile
index 1b777c2..da676a7 100644
--- a/lib/libc/tests/nss/Makefile
+++ b/lib/libc/tests/nss/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/lib/libc/nss
+
BINDIR= ${TESTSDIR}
.PATH: ${.CURDIR:H}/resolv
diff --git a/lib/libc/tests/regex/Makefile b/lib/libc/tests/regex/Makefile
index 946bc44..f60d512 100644
--- a/lib/libc/tests/regex/Makefile
+++ b/lib/libc/tests/regex/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
BINDIR= ${TESTSDIR}
IMPLEMENTATION?= -DREGEX_SPENCER
diff --git a/lib/libc/tests/resolv/Makefile b/lib/libc/tests/resolv/Makefile
index 4fb43d8..cc17ef5 100644
--- a/lib/libc/tests/resolv/Makefile
+++ b/lib/libc/tests/resolv/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/lib/libc/resolv
+
BINDIR= ${TESTSDIR}
FILES+= mach
diff --git a/lib/libc/tests/rpc/Makefile b/lib/libc/tests/rpc/Makefile
index d7780ef..6a6ae7b 100644
--- a/lib/libc/tests/rpc/Makefile
+++ b/lib/libc/tests/rpc/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
SRCS.xdr_test= ${RPCSRC:.x=_xdr.c} t_xdr.c ${RPCSRC:.x=.h} \
h_testbits.h
diff --git a/lib/libc/tests/setjmp/Makefile b/lib/libc/tests/setjmp/Makefile
index 39b0a96..b645b4d 100644
--- a/lib/libc/tests/setjmp/Makefile
+++ b/lib/libc/tests/setjmp/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_C= setjmp_test
NETBSD_ATF_TESTS_C+= threadjmp_test
diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile
index 61caced..09adf97 100644
--- a/lib/libc/tests/ssp/Makefile
+++ b/lib/libc/tests/ssp/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NO_WERROR=
WARNS?= 2
diff --git a/lib/libc/tests/stdio/Makefile b/lib/libc/tests/stdio/Makefile
index 72685e0..50484fd 100644
--- a/lib/libc/tests/stdio/Makefile
+++ b/lib/libc/tests/stdio/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= fdopen_test
ATF_TESTS_C+= fmemopen2_test
ATF_TESTS_C+= fopen2_test
diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile
index 87e84c5..08f34b0 100644
--- a/lib/libc/tests/stdlib/Makefile
+++ b/lib/libc/tests/stdlib/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= heapsort_test
ATF_TESTS_C+= mergesort_test
ATF_TESTS_C+= qsort_test
diff --git a/lib/libc/tests/string/Makefile b/lib/libc/tests/string/Makefile
index ea2dfcf..a8db9c3 100644
--- a/lib/libc/tests/string/Makefile
+++ b/lib/libc/tests/string/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= memcmp_test
ATF_TESTS_C+= stpncpy_test
ATF_TESTS_C+= strerror2_test
diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile
index c7b0053..e79204a 100644
--- a/lib/libc/tests/sys/Makefile
+++ b/lib/libc/tests/sys/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= queue_test
# TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg,
@@ -68,13 +72,15 @@ WARNS?= 3
WARNS?= 4
.endif
-FILESGROUPS= FILES truncate_test_FILES
+FILESGROUPS+= FILES truncate_test_FILES
truncate_test_FILES= truncate_test.root_owned
truncate_test_FILESDIR= ${TESTSDIR}
truncate_test_FILESMODE= 0600
truncate_test_FILESOWNER= root
truncate_test_FILESGRP= wheel
+truncate_test_FILESPACKAGE= ${PACKAGE}
+FILESPACKAGE= ${PACKAGE}
CLEANFILES= truncate_test.root_owned
truncate_test.root_owned:
diff --git a/lib/libc/tests/termios/Makefile b/lib/libc/tests/termios/Makefile
index 0495d68..81b0ff1 100644
--- a/lib/libc/tests/termios/Makefile
+++ b/lib/libc/tests/termios/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_C= tcsetpgrp_test
.include "../Makefile.netbsd-tests"
diff --git a/lib/libc/tests/time/Makefile b/lib/libc/tests/time/Makefile
index feb543d..49745e2 100644
--- a/lib/libc/tests/time/Makefile
+++ b/lib/libc/tests/time/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_C= mktime_test
NETBSD_ATF_TESTS_C+= strptime_test
diff --git a/lib/libc/tests/tls/Makefile b/lib/libc/tests/tls/Makefile
index cbf441d..0e98fed 100644
--- a/lib/libc/tests/tls/Makefile
+++ b/lib/libc/tests/tls/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
.if !defined(NO_PIC)
SUBDIR+= dso
.endif
diff --git a/lib/libc/tests/tls/dso/Makefile b/lib/libc/tests/tls/dso/Makefile
index 9b698cd..74f826a 100644
--- a/lib/libc/tests/tls/dso/Makefile
+++ b/lib/libc/tests/tls/dso/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
OBJTOP= ${.OBJDIR:H:H:H:H:H}
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/tls/${.CURDIR:T}
diff --git a/lib/libc/tests/tls_dso/Makefile b/lib/libc/tests/tls_dso/Makefile
index 5449799..79b05f8 100644
--- a/lib/libc/tests/tls_dso/Makefile
+++ b/lib/libc/tests/tls_dso/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
LIB= h_tls_dynamic
SRCS= h_tls_dynamic.c
diff --git a/lib/libc/tests/ttyio/Makefile b/lib/libc/tests/ttyio/Makefile
index d5b8f01..c9520fb 100644
--- a/lib/libc/tests/ttyio/Makefile
+++ b/lib/libc/tests/ttyio/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
# TODO: ptm_test
NETBSD_ATF_TESTS_C= ttyio_test
diff --git a/lib/libcalendar/Makefile b/lib/libcalendar/Makefile
index b0ae002..d217a10 100644
--- a/lib/libcalendar/Makefile
+++ b/lib/libcalendar/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= lib${LIB}
LIB= calendar
SRCS= calendar.c easter.c
diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile
index c448369..a4cae7a 100644
--- a/lib/libcam/Makefile
+++ b/lib/libcam/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= lib${LIB}
LIB= cam
SHLIBDIR?= /lib
SRCS= camlib.c scsi_cmdparse.c scsi_all.c scsi_da.c scsi_sa.c cam.c \
diff --git a/lib/libcapsicum/Makefile b/lib/libcapsicum/Makefile
new file mode 100644
index 0000000..bf34f6f
--- /dev/null
+++ b/lib/libcapsicum/Makefile
@@ -0,0 +1,47 @@
+# $FreeBSD$
+
+PACKAGE= lib${LIB}
+LIB= capsicum
+
+SHLIB_MAJOR= 0
+SHLIBDIR?= /lib
+
+SRCS= libcapsicum.c
+SRCS+= libcapsicum_dns.c
+SRCS+= libcapsicum_grp.c
+SRCS+= libcapsicum_pwd.c
+SRCS+= libcapsicum_random.c
+SRCS+= libcapsicum_service.c
+SRCS+= libcapsicum_sysctl.c
+
+INCS= libcapsicum.h
+INCS+= libcapsicum_dns.h
+INCS+= libcapsicum_grp.h
+INCS+= libcapsicum_pwd.h
+INCS+= libcapsicum_random.h
+INCS+= libcapsicum_service.h
+INCS+= libcapsicum_sysctl.h
+
+LIBADD= nv
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../libnv
+
+WARNS?= 6
+
+MAN+= libcapsicum.3
+
+MLINKS+=libcapsicum.3 cap_init.3
+MLINKS+=libcapsicum.3 cap_wrap.3
+MLINKS+=libcapsicum.3 cap_unwrap.3
+MLINKS+=libcapsicum.3 cap_sock.3
+MLINKS+=libcapsicum.3 cap_clone.3
+MLINKS+=libcapsicum.3 cap_close.3
+MLINKS+=libcapsicum.3 cap_limit_get.3
+MLINKS+=libcapsicum.3 cap_limit_set.3
+MLINKS+=libcapsicum.3 cap_send_nvlist.3
+MLINKS+=libcapsicum.3 cap_recv_nvlist.3
+MLINKS+=libcapsicum.3 cap_xfer_nvlist.3
+MLINKS+=libcapsicum.3 cap_service_open.3
+
+.include <bsd.lib.mk>
diff --git a/lib/libcapsicum/Makefile.depend b/lib/libcapsicum/Makefile.depend
new file mode 100644
index 0000000..4f7989b
--- /dev/null
+++ b/lib/libcapsicum/Makefile.depend
@@ -0,0 +1,19 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libnv \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libcapsicum/libcapsicum.3 b/lib/libcapsicum/libcapsicum.3
new file mode 100644
index 0000000..cbfd214
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum.3
@@ -0,0 +1,300 @@
+.\" Copyright (c) 2013 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This documentation was written by Pawel Jakub Dawidek under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 2, 2015
+.Dt LIBCAPSICUM 3
+.Os
+.Sh NAME
+.Nm cap_init ,
+.Nm cap_wrap ,
+.Nm cap_unwrap ,
+.Nm cap_sock ,
+.Nm cap_clone ,
+.Nm cap_close ,
+.Nm cap_limit_get ,
+.Nm cap_limit_set ,
+.Nm cap_send_nvlist ,
+.Nm cap_recv_nvlist ,
+.Nm cap_xfer_nvlist ,
+.Nm cap_service_open
+.Nd "library for handling application capabilities"
+.Sh LIBRARY
+.Lb libcapsicum
+.Sh SYNOPSIS
+.In libcapsicum.h
+.In nv.h
+.Ft "cap_channel_t *"
+.Fn cap_init "void"
+.Ft "cap_channel_t *"
+.Fn cap_wrap "int sock"
+.Ft "int"
+.Fn cap_unwrap "cap_channel_t *chan"
+.Ft "int"
+.Fn cap_sock "const cap_channel_t *chan"
+.Ft "cap_channel_t *"
+.Fn cap_clone "const cap_channel_t *chan"
+.Ft "void"
+.Fn cap_close "cap_channel_t *chan"
+.Ft "int"
+.Fn cap_limit_get "const cap_channel_t *chan" "nvlist_t **limitsp"
+.Ft "int"
+.Fn cap_limit_set "const cap_channel_t *chan" "nvlist_t *limits"
+.Ft "int"
+.Fn cap_send_nvlist "const cap_channel_t *chan" "const nvlist_t *nvl"
+.Ft "nvlist_t *"
+.Fn cap_recv_nvlist "const cap_channel_t *chan" "int flags"
+.Ft "nvlist_t *"
+.Fn cap_xfer_nvlist "const cap_channel_t *chan" "nvlist_t *nvl" "int flags"
+.In libcapsicum_service.h
+.Ft "cap_channel_t *"
+.Fn cap_service_open "const cap_channel_t *chan" "const char *name"
+.Sh DESCRIPTION
+The
+.Nm libcapsicum
+library allows to manage application capabilities through the
+.Xr casperd 8
+daemon.
+.Pp
+The application capability (represented by the
+.Vt cap_channel_t
+type) is a communication channel between the caller and the
+.Xr casperd 8
+daemon or an instance of one of its services.
+A capability to the
+.Xr casperd 8
+daemon obtained with the
+.Fn cap_init
+function allows to create capabilities to casper's services via the
+.Fn cap_service_open
+function.
+.Pp
+The
+.Fn cap_init
+function opens capability to the
+.Xr casperd 8
+daemon.
+.Pp
+The
+.Fn cap_wrap
+function creates
+.Vt cap_channel_t
+based on the given socket.
+The function is used when capability is inherited through
+.Xr execve 2
+or send over
+.Xr unix 4
+domain socket as a regular file descriptor and has to be represented as
+.Vt cap_channel_t
+again.
+.Pp
+The
+.Fn cap_unwrap
+function is the opposite of the
+.Fn cap_wrap
+function.
+It frees the
+.Vt cap_channel_t
+structure and returns
+.Xr unix 4
+domain socket associated with it.
+.Pp
+The
+.Fn cap_clone
+function clones the given capability.
+.Pp
+The
+.Fn cap_close
+function closes the given capability.
+.Pp
+The
+.Fn cap_sock
+function returns
+.Xr unix 4
+domain socket descriptor associated with the given capability for use with
+system calls like
+.Xr kevent 2 ,
+.Xr poll 2
+and
+.Xr select 2 .
+.Pp
+The
+.Fn cap_limit_get
+function stores current limits of the given capability in the
+.Fa limitsp
+argument.
+If the function return
+.Va 0
+and
+.Dv NULL
+is stored in
+.Fa limitsp
+it means there are no limits set.
+.Pp
+The
+.Fn cap_limit_set
+function sets limits for the given capability.
+The limits are provided as nvlist.
+The exact format depends on the service the capability represents.
+.Pp
+The
+.Fn cap_send_nvlist
+function sends the given nvlist over the given capability.
+This is low level interface to communicate with casper services.
+Most services should provide higher level API.
+.Pp
+The
+.Fn cap_recv_nvlist
+function receives the given nvlist over the given capability.
+The
+.Fa flags
+argument defines what type the top nvlist is expected to be.
+If the nvlist flags do not match the flags passed to
+.Fn cap_recv_nvlist ,
+the nvlist will not be returned.
+.Pp
+The
+.Fn cap_xfer_nvlist
+function sends the given nvlist, destroys it and receives new nvlist in
+response over the given capability.
+The
+.Fa flags
+argument defines what type the top nvlist is expected to be.
+If the nvlist flags do not match the flags passed to
+.Fn cap_xfer_nvlist ,
+the nvlist will not be returned.
+It does not matter if the function succeeds or fails, the nvlist given
+for sending will always be destroyed once the function returns.
+.Pp
+The
+.Fn cap_service_open
+function opens casper service of the given name through casper capability
+obtained via the
+.Fn cap_init
+function.
+The function returns capability that provides access to opened service.
+.Sh RETURN VALUES
+The
+.Fn cap_clone ,
+.Fn cap_init ,
+.Fn cap_recv_nvlist ,
+.Fn cap_service_open ,
+.Fn cap_wrap
+and
+.Fn cap_xfer_nvlist
+functions return
+.Dv NULL
+and set the
+.Va errno
+variable on failure.
+.Pp
+The
+.Fn cap_limit_get ,
+.Fn cap_limit_set
+and
+.Fn cap_send_nvlist
+functions return
+.Dv -1
+and set the
+.Va errno
+variable on failure.
+.Pp
+The
+.Fn cap_close ,
+.Fn cap_sock
+and
+.Fn cap_unwrap
+functions always succeed.
+.Sh EXAMPLES
+The following example first opens capability to the
+.Xr casperd 8
+daemon, then using this capability creates new capability to the
+.Nm system.dns
+casper service and uses the latter capability to resolve IP address.
+.Bd -literal
+cap_channel_t *capcas, *capdns;
+nvlist_t *limits;
+const char *ipstr = "127.0.0.1";
+struct in_addr ip;
+struct hostent *hp;
+
+/* Open capability to the Casper daemon. */
+capcas = cap_init();
+if (capcas == NULL)
+ err(1, "Unable to contact Casper daemon");
+
+/* Enter capability mode sandbox. */
+if (cap_enter() < 0 && errno != ENOSYS)
+ err(1, "Unable to enter capability mode");
+
+/* Use Casper capability to create capability to the system.dns service. */
+capdns = cap_service_open(capcas, "system.dns");
+if (capdns == NULL)
+ err(1, "Unable to open system.dns service");
+
+/* Close Casper capability, we don't need it anymore. */
+cap_close(capcas);
+
+/* Limit system.dns to reverse DNS lookups and IPv4 addresses. */
+limits = nvlist_create(0);
+nvlist_add_string(limits, "type", "ADDR");
+nvlist_add_number(limits, "family", (uint64_t)AF_INET);
+if (cap_limit_set(capdns, limits) < 0)
+ err(1, "Unable to limit access to the system.dns service");
+
+/* Convert IP address in C-string to in_addr. */
+if (!inet_aton(ipstr, &ip))
+ errx(1, "Unable to parse IP address %s.", ipstr);
+
+/* Find hostname for the given IP address. */
+hp = cap_gethostbyaddr(capdns, (const void *)&ip, sizeof(ip), AF_INET);
+if (hp == NULL)
+ errx(1, "No name associated with %s.", ipstr);
+
+printf("Name associated with %s is %s.\\n", ipstr, hp->h_name);
+.Ed
+.Sh SEE ALSO
+.Xr cap_enter 2 ,
+.Xr execve 2 ,
+.Xr kevent 2 ,
+.Xr poll 2 ,
+.Xr select 2 ,
+.Xr cap_gethostbyaddr 3 ,
+.Xr err 3 ,
+.Xr gethostbyaddr 3 ,
+.Xr inet_aton 3 ,
+.Xr nv 3 ,
+.Xr capsicum 4 ,
+.Xr unix 4 ,
+.Xr casperd 8
+.Sh AUTHORS
+The
+.Nm libcapsicum
+library was implemented by
+.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net
+under sponsorship from the FreeBSD Foundation.
diff --git a/lib/libcapsicum/libcapsicum.c b/lib/libcapsicum/libcapsicum.c
new file mode 100644
index 0000000..8c4d04d
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum.c
@@ -0,0 +1,266 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/nv.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "libcapsicum.h"
+#include "libcapsicum_impl.h"
+
+/*
+ * Structure describing communication channel between two separated processes.
+ */
+#define CAP_CHANNEL_MAGIC 0xcac8a31
+struct cap_channel {
+ /*
+ * Magic value helps to ensure that a pointer to the right structure is
+ * passed to our functions.
+ */
+ int cch_magic;
+ /* Socket descriptor for IPC. */
+ int cch_sock;
+};
+
+bool
+fd_is_valid(int fd)
+{
+
+ return (fcntl(fd, F_GETFL) != -1 || errno != EBADF);
+}
+
+cap_channel_t *
+cap_init(void)
+{
+ cap_channel_t *chan;
+ struct sockaddr_un sun;
+ int serrno, sock;
+
+ bzero(&sun, sizeof(sun));
+ sun.sun_family = AF_UNIX;
+ strlcpy(sun.sun_path, CASPER_SOCKPATH, sizeof(sun.sun_path));
+ sun.sun_len = SUN_LEN(&sun);
+
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sock == -1)
+ return (NULL);
+ if (connect(sock, (struct sockaddr *)&sun, sizeof(sun)) < 0) {
+ serrno = errno;
+ close(sock);
+ errno = serrno;
+ return (NULL);
+ }
+ chan = cap_wrap(sock);
+ if (chan == NULL) {
+ serrno = errno;
+ close(sock);
+ errno = serrno;
+ return (NULL);
+ }
+ return (chan);
+}
+
+cap_channel_t *
+cap_wrap(int sock)
+{
+ cap_channel_t *chan;
+
+ if (!fd_is_valid(sock))
+ return (NULL);
+
+ chan = malloc(sizeof(*chan));
+ if (chan != NULL) {
+ chan->cch_sock = sock;
+ chan->cch_magic = CAP_CHANNEL_MAGIC;
+ }
+
+ return (chan);
+}
+
+int
+cap_unwrap(cap_channel_t *chan)
+{
+ int sock;
+
+ assert(chan != NULL);
+ assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
+
+ sock = chan->cch_sock;
+ chan->cch_magic = 0;
+ free(chan);
+
+ return (sock);
+}
+
+cap_channel_t *
+cap_clone(const cap_channel_t *chan)
+{
+ cap_channel_t *newchan;
+ nvlist_t *nvl;
+ int newsock;
+
+ assert(chan != NULL);
+ assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "clone");
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (NULL);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ errno = (int)nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (NULL);
+ }
+ newsock = nvlist_take_descriptor(nvl, "sock");
+ nvlist_destroy(nvl);
+ newchan = cap_wrap(newsock);
+ if (newchan == NULL) {
+ int serrno;
+
+ serrno = errno;
+ close(newsock);
+ errno = serrno;
+ }
+
+ return (newchan);
+}
+
+void
+cap_close(cap_channel_t *chan)
+{
+
+ assert(chan != NULL);
+ assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
+
+ chan->cch_magic = 0;
+ close(chan->cch_sock);
+ free(chan);
+}
+
+int
+cap_sock(const cap_channel_t *chan)
+{
+
+ assert(chan != NULL);
+ assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
+
+ return (chan->cch_sock);
+}
+
+int
+cap_limit_set(const cap_channel_t *chan, nvlist_t *limits)
+{
+ nvlist_t *nvlmsg;
+ int error;
+
+ nvlmsg = nvlist_create(0);
+ nvlist_add_string(nvlmsg, "cmd", "limit_set");
+ nvlist_add_nvlist(nvlmsg, "limits", limits);
+ nvlmsg = cap_xfer_nvlist(chan, nvlmsg, 0);
+ if (nvlmsg == NULL) {
+ nvlist_destroy(limits);
+ return (-1);
+ }
+ error = (int)nvlist_get_number(nvlmsg, "error");
+ nvlist_destroy(nvlmsg);
+ nvlist_destroy(limits);
+ if (error != 0) {
+ errno = error;
+ return (-1);
+ }
+ return (0);
+}
+
+int
+cap_limit_get(const cap_channel_t *chan, nvlist_t **limitsp)
+{
+ nvlist_t *nvlmsg;
+ int error;
+
+ nvlmsg = nvlist_create(0);
+ nvlist_add_string(nvlmsg, "cmd", "limit_get");
+ nvlmsg = cap_xfer_nvlist(chan, nvlmsg, 0);
+ if (nvlmsg == NULL)
+ return (-1);
+ error = (int)nvlist_get_number(nvlmsg, "error");
+ if (error != 0) {
+ nvlist_destroy(nvlmsg);
+ errno = error;
+ return (-1);
+ }
+ if (nvlist_exists_null(nvlmsg, "limits"))
+ *limitsp = NULL;
+ else
+ *limitsp = nvlist_take_nvlist(nvlmsg, "limits");
+ nvlist_destroy(nvlmsg);
+ return (0);
+}
+
+int
+cap_send_nvlist(const cap_channel_t *chan, const nvlist_t *nvl)
+{
+
+ assert(chan != NULL);
+ assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
+
+ return (nvlist_send(chan->cch_sock, nvl));
+}
+
+nvlist_t *
+cap_recv_nvlist(const cap_channel_t *chan, int flags)
+{
+
+ assert(chan != NULL);
+ assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
+
+ return (nvlist_recv(chan->cch_sock, flags));
+}
+
+nvlist_t *
+cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl, int flags)
+{
+
+ assert(chan != NULL);
+ assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
+
+ return (nvlist_xfer(chan->cch_sock, nvl, flags));
+}
diff --git a/lib/libcapsicum/libcapsicum.h b/lib/libcapsicum/libcapsicum.h
new file mode 100644
index 0000000..c7110d8
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum.h
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_H_
+#define _LIBCAPSICUM_H_
+
+#ifndef _NVLIST_T_DECLARED
+#define _NVLIST_T_DECLARED
+struct nvlist;
+
+typedef struct nvlist nvlist_t;
+#endif
+
+#ifndef _CAP_CHANNEL_T_DECLARED
+#define _CAP_CHANNEL_T_DECLARED
+struct cap_channel;
+
+typedef struct cap_channel cap_channel_t;
+#endif
+
+/*
+ * The function opens unrestricted communication channel to Casper.
+ */
+cap_channel_t *cap_init(void);
+
+/*
+ * The function creates cap_channel_t based on the given socket.
+ */
+cap_channel_t *cap_wrap(int sock);
+
+/*
+ * The function returns communication socket and frees cap_channel_t.
+ */
+int cap_unwrap(cap_channel_t *chan);
+
+/*
+ * The function clones the given capability.
+ */
+cap_channel_t *cap_clone(const cap_channel_t *chan);
+
+/*
+ * The function closes the given capability.
+ */
+void cap_close(cap_channel_t *chan);
+
+/*
+ * The function returns socket descriptor associated with the given
+ * cap_channel_t for use with select(2)/kqueue(2)/etc.
+ */
+int cap_sock(const cap_channel_t *chan);
+
+/*
+ * The function limits the given capability.
+ * It always destroys 'limits' on return.
+ */
+int cap_limit_set(const cap_channel_t *chan, nvlist_t *limits);
+
+/*
+ * The function returns current limits of the given capability.
+ */
+int cap_limit_get(const cap_channel_t *chan, nvlist_t **limitsp);
+
+#ifdef TODO
+/*
+ * The function registers a service within provided Casper's capability.
+ * It will run with the same privileges the process has at the time of
+ * calling this function.
+ */
+int cap_service_register(cap_channel_t *chan, const char *name,
+ cap_func_t *func);
+#endif
+
+/*
+ * Function sends nvlist over the given capability.
+ */
+int cap_send_nvlist(const cap_channel_t *chan, const nvlist_t *nvl);
+/*
+ * Function receives nvlist over the given capability.
+ */
+nvlist_t *cap_recv_nvlist(const cap_channel_t *chan, int flags);
+/*
+ * Function sends the given nvlist, destroys it and receives new nvlist in
+ * response over the given capability.
+ */
+nvlist_t *cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl, int flags);
+
+#endif /* !_LIBCAPSICUM_H_ */
diff --git a/lib/libcapsicum/libcapsicum_dns.c b/lib/libcapsicum/libcapsicum_dns.c
new file mode 100644
index 0000000..5f54283
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_dns.c
@@ -0,0 +1,365 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+
+#include <assert.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "libcapsicum.h"
+#include "libcapsicum_dns.h"
+
+static struct hostent hent;
+
+static void
+hostent_free(struct hostent *hp)
+{
+ unsigned int ii;
+
+ free(hp->h_name);
+ hp->h_name = NULL;
+ if (hp->h_aliases != NULL) {
+ for (ii = 0; hp->h_aliases[ii] != NULL; ii++)
+ free(hp->h_aliases[ii]);
+ free(hp->h_aliases);
+ hp->h_aliases = NULL;
+ }
+ if (hp->h_addr_list != NULL) {
+ for (ii = 0; hp->h_addr_list[ii] != NULL; ii++)
+ free(hp->h_addr_list[ii]);
+ free(hp->h_addr_list);
+ hp->h_addr_list = NULL;
+ }
+}
+
+static struct hostent *
+hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
+{
+ unsigned int ii, nitems;
+ char nvlname[64];
+ int n;
+
+ hostent_free(hp);
+
+ hp->h_name = strdup(nvlist_get_string(nvl, "name"));
+ if (hp->h_name == NULL)
+ goto fail;
+ hp->h_addrtype = (int)nvlist_get_number(nvl, "addrtype");
+ hp->h_length = (int)nvlist_get_number(nvl, "length");
+
+ nitems = (unsigned int)nvlist_get_number(nvl, "naliases");
+ hp->h_aliases = calloc(sizeof(hp->h_aliases[0]), nitems + 1);
+ if (hp->h_aliases == NULL)
+ goto fail;
+ for (ii = 0; ii < nitems; ii++) {
+ n = snprintf(nvlname, sizeof(nvlname), "alias%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ hp->h_aliases[ii] =
+ strdup(nvlist_get_string(nvl, nvlname));
+ if (hp->h_aliases[ii] == NULL)
+ goto fail;
+ }
+ hp->h_aliases[ii] = NULL;
+
+ nitems = (unsigned int)nvlist_get_number(nvl, "naddrs");
+ hp->h_addr_list = calloc(sizeof(hp->h_addr_list[0]), nitems + 1);
+ if (hp->h_addr_list == NULL)
+ goto fail;
+ for (ii = 0; ii < nitems; ii++) {
+ hp->h_addr_list[ii] = malloc(hp->h_length);
+ if (hp->h_addr_list[ii] == NULL)
+ goto fail;
+ n = snprintf(nvlname, sizeof(nvlname), "addr%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ bcopy(nvlist_get_binary(nvl, nvlname, NULL),
+ hp->h_addr_list[ii], hp->h_length);
+ }
+ hp->h_addr_list[ii] = NULL;
+
+ return (hp);
+fail:
+ hostent_free(hp);
+ h_errno = NO_RECOVERY;
+ return (NULL);
+}
+
+struct hostent *
+cap_gethostbyname(cap_channel_t *chan, const char *name)
+{
+
+ return (cap_gethostbyname2(chan, name, AF_INET));
+}
+
+struct hostent *
+cap_gethostbyname2(cap_channel_t *chan, const char *name, int type)
+{
+ struct hostent *hp;
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "gethostbyname");
+ nvlist_add_number(nvl, "family", (uint64_t)type);
+ nvlist_add_string(nvl, "name", name);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL) {
+ h_errno = NO_RECOVERY;
+ return (NULL);
+ }
+ if (nvlist_get_number(nvl, "error") != 0) {
+ h_errno = (int)nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (NULL);
+ }
+
+ hp = hostent_unpack(nvl, &hent);
+ nvlist_destroy(nvl);
+ return (hp);
+}
+
+struct hostent *
+cap_gethostbyaddr(cap_channel_t *chan, const void *addr, socklen_t len,
+ int type)
+{
+ struct hostent *hp;
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "gethostbyaddr");
+ nvlist_add_binary(nvl, "addr", addr, (size_t)len);
+ nvlist_add_number(nvl, "family", (uint64_t)type);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL) {
+ h_errno = NO_RECOVERY;
+ return (NULL);
+ }
+ if (nvlist_get_number(nvl, "error") != 0) {
+ h_errno = (int)nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (NULL);
+ }
+ hp = hostent_unpack(nvl, &hent);
+ nvlist_destroy(nvl);
+ return (hp);
+}
+
+static struct addrinfo *
+addrinfo_unpack(const nvlist_t *nvl)
+{
+ struct addrinfo *ai;
+ const void *addr;
+ size_t addrlen;
+ const char *canonname;
+
+ addr = nvlist_get_binary(nvl, "ai_addr", &addrlen);
+ ai = malloc(sizeof(*ai) + addrlen);
+ if (ai == NULL)
+ return (NULL);
+ ai->ai_flags = (int)nvlist_get_number(nvl, "ai_flags");
+ ai->ai_family = (int)nvlist_get_number(nvl, "ai_family");
+ ai->ai_socktype = (int)nvlist_get_number(nvl, "ai_socktype");
+ ai->ai_protocol = (int)nvlist_get_number(nvl, "ai_protocol");
+ ai->ai_addrlen = (socklen_t)addrlen;
+ canonname = nvlist_get_string(nvl, "ai_canonname");
+ if (canonname != NULL) {
+ ai->ai_canonname = strdup(canonname);
+ if (ai->ai_canonname == NULL) {
+ free(ai);
+ return (NULL);
+ }
+ } else {
+ ai->ai_canonname = NULL;
+ }
+ ai->ai_addr = (void *)(ai + 1);
+ bcopy(addr, ai->ai_addr, addrlen);
+ ai->ai_next = NULL;
+
+ return (ai);
+}
+
+int
+cap_getaddrinfo(cap_channel_t *chan, const char *hostname, const char *servname,
+ const struct addrinfo *hints, struct addrinfo **res)
+{
+ struct addrinfo *firstai, *prevai, *curai;
+ unsigned int ii;
+ const nvlist_t *nvlai;
+ char nvlname[64];
+ nvlist_t *nvl;
+ int error, n;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "getaddrinfo");
+ nvlist_add_string(nvl, "hostname", hostname);
+ nvlist_add_string(nvl, "servname", servname);
+ if (hints != NULL) {
+ nvlist_add_number(nvl, "hints.ai_flags",
+ (uint64_t)hints->ai_flags);
+ nvlist_add_number(nvl, "hints.ai_family",
+ (uint64_t)hints->ai_family);
+ nvlist_add_number(nvl, "hints.ai_socktype",
+ (uint64_t)hints->ai_socktype);
+ nvlist_add_number(nvl, "hints.ai_protocol",
+ (uint64_t)hints->ai_protocol);
+ }
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (EAI_MEMORY);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ error = (int)nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (error);
+ }
+
+ nvlai = NULL;
+ firstai = prevai = curai = NULL;
+ for (ii = 0; ; ii++) {
+ n = snprintf(nvlname, sizeof(nvlname), "res%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ if (!nvlist_exists_nvlist(nvl, nvlname))
+ break;
+ nvlai = nvlist_get_nvlist(nvl, nvlname);
+ curai = addrinfo_unpack(nvlai);
+ if (curai == NULL)
+ break;
+ if (prevai != NULL)
+ prevai->ai_next = curai;
+ else if (firstai == NULL)
+ firstai = curai;
+ prevai = curai;
+ }
+ nvlist_destroy(nvl);
+ if (curai == NULL && nvlai != NULL) {
+ if (firstai == NULL)
+ freeaddrinfo(firstai);
+ return (EAI_MEMORY);
+ }
+
+ *res = firstai;
+ return (0);
+}
+
+int
+cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa, socklen_t salen,
+ char *host, size_t hostlen, char *serv, size_t servlen, int flags)
+{
+ nvlist_t *nvl;
+ int error;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "getnameinfo");
+ nvlist_add_number(nvl, "hostlen", (uint64_t)hostlen);
+ nvlist_add_number(nvl, "servlen", (uint64_t)servlen);
+ nvlist_add_binary(nvl, "sa", sa, (size_t)salen);
+ nvlist_add_number(nvl, "flags", (uint64_t)flags);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (EAI_MEMORY);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ error = (int)nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (error);
+ }
+
+ if (host != NULL)
+ strlcpy(host, nvlist_get_string(nvl, "host"), hostlen + 1);
+ if (serv != NULL)
+ strlcpy(serv, nvlist_get_string(nvl, "serv"), servlen + 1);
+ nvlist_destroy(nvl);
+ return (0);
+}
+
+static void
+limit_remove(nvlist_t *limits, const char *prefix)
+{
+ const char *name;
+ size_t prefixlen;
+ void *cookie;
+
+ prefixlen = strlen(prefix);
+again:
+ cookie = NULL;
+ while ((name = nvlist_next(limits, NULL, &cookie)) != NULL) {
+ if (strncmp(name, prefix, prefixlen) == 0) {
+ nvlist_free(limits, name);
+ goto again;
+ }
+ }
+}
+
+int
+cap_dns_type_limit(cap_channel_t *chan, const char * const *types,
+ size_t ntypes)
+{
+ nvlist_t *limits;
+ unsigned int i;
+ char nvlname[64];
+ int n;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL)
+ limits = nvlist_create(0);
+ else
+ limit_remove(limits, "type");
+ for (i = 0; i < ntypes; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "type%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(limits, nvlname, types[i]);
+ }
+ return (cap_limit_set(chan, limits));
+}
+
+int
+cap_dns_family_limit(cap_channel_t *chan, const int *families,
+ size_t nfamilies)
+{
+ nvlist_t *limits;
+ unsigned int i;
+ char nvlname[64];
+ int n;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL)
+ limits = nvlist_create(0);
+ else
+ limit_remove(limits, "family");
+ for (i = 0; i < nfamilies; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "family%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_number(limits, nvlname, (uint64_t)families[i]);
+ }
+ return (cap_limit_set(chan, limits));
+}
diff --git a/lib/libcapsicum/libcapsicum_dns.h b/lib/libcapsicum/libcapsicum_dns.h
new file mode 100644
index 0000000..0223510
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_dns.h
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2012 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_DNS_H_
+#define _LIBCAPSICUM_DNS_H_
+
+#include <sys/socket.h> /* socklen_t */
+
+struct addrinfo;
+struct hostent;
+
+struct hostent *cap_gethostbyname(cap_channel_t *chan, const char *name);
+struct hostent *cap_gethostbyname2(cap_channel_t *chan, const char *name,
+ int type);
+struct hostent *cap_gethostbyaddr(cap_channel_t *chan, const void *addr,
+ socklen_t len, int type);
+
+int cap_getaddrinfo(cap_channel_t *chan, const char *hostname,
+ const char *servname, const struct addrinfo *hints, struct addrinfo **res);
+int cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa,
+ socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen,
+ int flags);
+
+int cap_dns_type_limit(cap_channel_t *chan, const char * const *types,
+ size_t ntypes);
+int cap_dns_family_limit(cap_channel_t *chan, const int *families,
+ size_t nfamilies);
+
+#endif /* !_LIBCAPSICUM_DNS_H_ */
diff --git a/lib/libcapsicum/libcapsicum_grp.c b/lib/libcapsicum/libcapsicum_grp.c
new file mode 100644
index 0000000..44d573e
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_grp.c
@@ -0,0 +1,438 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/dnv.h>
+#include <sys/nv.h>
+#include <sys/param.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <grp.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "libcapsicum.h"
+#include "libcapsicum_grp.h"
+
+static struct group ggrp;
+static char *gbuffer;
+static size_t gbufsize;
+
+static int
+group_resize(void)
+{
+ char *buf;
+
+ if (gbufsize == 0)
+ gbufsize = 1024;
+ else
+ gbufsize *= 2;
+
+ buf = gbuffer;
+ gbuffer = realloc(buf, gbufsize);
+ if (gbuffer == NULL) {
+ free(buf);
+ gbufsize = 0;
+ return (ENOMEM);
+ }
+ memset(gbuffer, 0, gbufsize);
+
+ return (0);
+}
+
+static int
+group_unpack_string(const nvlist_t *nvl, const char *fieldname, char **fieldp,
+ char **bufferp, size_t *bufsizep)
+{
+ const char *str;
+ size_t len;
+
+ str = nvlist_get_string(nvl, fieldname);
+ len = strlcpy(*bufferp, str, *bufsizep);
+ if (len >= *bufsizep)
+ return (ERANGE);
+ *fieldp = *bufferp;
+ *bufferp += len + 1;
+ *bufsizep -= len + 1;
+
+ return (0);
+}
+
+static int
+group_unpack_members(const nvlist_t *nvl, char ***fieldp, char **bufferp,
+ size_t *bufsizep)
+{
+ const char *mem;
+ char **outstrs, *str, nvlname[64];
+ size_t nmem, datasize, strsize;
+ unsigned int ii;
+ int n;
+
+ if (!nvlist_exists_number(nvl, "gr_nmem")) {
+ datasize = _ALIGNBYTES + sizeof(char *);
+ if (datasize >= *bufsizep)
+ return (ERANGE);
+ outstrs = (char **)_ALIGN(*bufferp);
+ outstrs[0] = NULL;
+ *fieldp = outstrs;
+ *bufferp += datasize;
+ *bufsizep -= datasize;
+ return (0);
+ }
+
+ nmem = (size_t)nvlist_get_number(nvl, "gr_nmem");
+ datasize = _ALIGNBYTES + sizeof(char *) * (nmem + 1);
+ for (ii = 0; ii < nmem; ii++) {
+ n = snprintf(nvlname, sizeof(nvlname), "gr_mem[%u]", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ mem = dnvlist_get_string(nvl, nvlname, NULL);
+ if (mem == NULL)
+ return (EINVAL);
+ datasize += strlen(mem) + 1;
+ }
+
+ if (datasize >= *bufsizep)
+ return (ERANGE);
+
+ outstrs = (char **)_ALIGN(*bufferp);
+ str = (char *)outstrs + sizeof(char *) * (nmem + 1);
+ for (ii = 0; ii < nmem; ii++) {
+ n = snprintf(nvlname, sizeof(nvlname), "gr_mem[%u]", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ mem = nvlist_get_string(nvl, nvlname);
+ strsize = strlen(mem) + 1;
+ memcpy(str, mem, strsize);
+ outstrs[ii] = str;
+ str += strsize;
+ }
+ assert(ii == nmem);
+ outstrs[ii] = NULL;
+
+ *fieldp = outstrs;
+ *bufferp += datasize;
+ *bufsizep -= datasize;
+
+ return (0);
+}
+
+static int
+group_unpack(const nvlist_t *nvl, struct group *grp, char *buffer,
+ size_t bufsize)
+{
+ int error;
+
+ if (!nvlist_exists_string(nvl, "gr_name"))
+ return (EINVAL);
+
+ memset(grp, 0, sizeof(*grp));
+
+ error = group_unpack_string(nvl, "gr_name", &grp->gr_name, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ error = group_unpack_string(nvl, "gr_passwd", &grp->gr_passwd, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ grp->gr_gid = (gid_t)nvlist_get_number(nvl, "gr_gid");
+ error = group_unpack_members(nvl, &grp->gr_mem, &buffer, &bufsize);
+ if (error != 0)
+ return (error);
+
+ return (0);
+}
+
+static int
+cap_getgrcommon_r(cap_channel_t *chan, const char *cmd, const char *name,
+ gid_t gid, struct group *grp, char *buffer, size_t bufsize,
+ struct group **result)
+{
+ nvlist_t *nvl;
+ bool getgr_r;
+ int error;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", cmd);
+ if (strcmp(cmd, "getgrent") == 0 || strcmp(cmd, "getgrent_r") == 0) {
+ /* Add nothing. */
+ } else if (strcmp(cmd, "getgrnam") == 0 ||
+ strcmp(cmd, "getgrnam_r") == 0) {
+ nvlist_add_string(nvl, "name", name);
+ } else if (strcmp(cmd, "getgrgid") == 0 ||
+ strcmp(cmd, "getgrgid_r") == 0) {
+ nvlist_add_number(nvl, "gid", (uint64_t)gid);
+ } else {
+ abort();
+ }
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL) {
+ assert(errno != 0);
+ *result = NULL;
+ return (errno);
+ }
+ error = (int)nvlist_get_number(nvl, "error");
+ if (error != 0) {
+ nvlist_destroy(nvl);
+ *result = NULL;
+ return (error);
+ }
+
+ if (!nvlist_exists_string(nvl, "gr_name")) {
+ /* Not found. */
+ nvlist_destroy(nvl);
+ *result = NULL;
+ return (0);
+ }
+
+ getgr_r = (strcmp(cmd, "getgrent_r") == 0 ||
+ strcmp(cmd, "getgrnam_r") == 0 || strcmp(cmd, "getgrgid_r") == 0);
+
+ for (;;) {
+ error = group_unpack(nvl, grp, buffer, bufsize);
+ if (getgr_r || error != ERANGE)
+ break;
+ assert(buffer == gbuffer);
+ assert(bufsize == gbufsize);
+ error = group_resize();
+ if (error != 0)
+ break;
+ /* Update pointers after resize. */
+ buffer = gbuffer;
+ bufsize = gbufsize;
+ }
+
+ nvlist_destroy(nvl);
+
+ if (error == 0)
+ *result = grp;
+ else
+ *result = NULL;
+
+ return (error);
+}
+
+static struct group *
+cap_getgrcommon(cap_channel_t *chan, const char *cmd, const char *name,
+ gid_t gid)
+{
+ struct group *result;
+ int error, serrno;
+
+ serrno = errno;
+
+ error = cap_getgrcommon_r(chan, cmd, name, gid, &ggrp, gbuffer,
+ gbufsize, &result);
+ if (error != 0) {
+ errno = error;
+ return (NULL);
+ }
+
+ errno = serrno;
+
+ return (result);
+}
+
+struct group *
+cap_getgrent(cap_channel_t *chan)
+{
+
+ return (cap_getgrcommon(chan, "getgrent", NULL, 0));
+}
+
+struct group *
+cap_getgrnam(cap_channel_t *chan, const char *name)
+{
+
+ return (cap_getgrcommon(chan, "getgrnam", name, 0));
+}
+
+struct group *
+cap_getgrgid(cap_channel_t *chan, gid_t gid)
+{
+
+ return (cap_getgrcommon(chan, "getgrgid", NULL, gid));
+}
+
+int
+cap_getgrent_r(cap_channel_t *chan, struct group *grp, char *buffer,
+ size_t bufsize, struct group **result)
+{
+
+ return (cap_getgrcommon_r(chan, "getgrent_r", NULL, 0, grp, buffer,
+ bufsize, result));
+}
+
+int
+cap_getgrnam_r(cap_channel_t *chan, const char *name, struct group *grp,
+ char *buffer, size_t bufsize, struct group **result)
+{
+
+ return (cap_getgrcommon_r(chan, "getgrnam_r", name, 0, grp, buffer,
+ bufsize, result));
+}
+
+int
+cap_getgrgid_r(cap_channel_t *chan, gid_t gid, struct group *grp, char *buffer,
+ size_t bufsize, struct group **result)
+{
+
+ return (cap_getgrcommon_r(chan, "getgrgid_r", NULL, gid, grp, buffer,
+ bufsize, result));
+}
+
+int
+cap_setgroupent(cap_channel_t *chan, int stayopen)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "setgroupent");
+ nvlist_add_bool(nvl, "stayopen", stayopen != 0);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (0);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ errno = nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (0);
+ }
+ nvlist_destroy(nvl);
+
+ return (1);
+}
+
+int
+cap_setgrent(cap_channel_t *chan)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "setgrent");
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (0);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ errno = nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (0);
+ }
+ nvlist_destroy(nvl);
+
+ return (1);
+}
+
+void
+cap_endgrent(cap_channel_t *chan)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "endgrent");
+ /* Ignore any errors, we have no way to report them. */
+ nvlist_destroy(cap_xfer_nvlist(chan, nvl, 0));
+}
+
+int
+cap_grp_limit_cmds(cap_channel_t *chan, const char * const *cmds, size_t ncmds)
+{
+ nvlist_t *limits, *nvl;
+ unsigned int i;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL) {
+ limits = nvlist_create(0);
+ } else {
+ if (nvlist_exists_nvlist(limits, "cmds"))
+ nvlist_free_nvlist(limits, "cmds");
+ }
+ nvl = nvlist_create(0);
+ for (i = 0; i < ncmds; i++)
+ nvlist_add_null(nvl, cmds[i]);
+ nvlist_move_nvlist(limits, "cmds", nvl);
+ return (cap_limit_set(chan, limits));
+}
+
+int
+cap_grp_limit_fields(cap_channel_t *chan, const char * const *fields,
+ size_t nfields)
+{
+ nvlist_t *limits, *nvl;
+ unsigned int i;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL) {
+ limits = nvlist_create(0);
+ } else {
+ if (nvlist_exists_nvlist(limits, "fields"))
+ nvlist_free_nvlist(limits, "fields");
+ }
+ nvl = nvlist_create(0);
+ for (i = 0; i < nfields; i++)
+ nvlist_add_null(nvl, fields[i]);
+ nvlist_move_nvlist(limits, "fields", nvl);
+ return (cap_limit_set(chan, limits));
+}
+
+int
+cap_grp_limit_groups(cap_channel_t *chan, const char * const *names,
+ size_t nnames, gid_t *gids, size_t ngids)
+{
+ nvlist_t *limits, *groups;
+ unsigned int i;
+ char nvlname[64];
+ int n;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL) {
+ limits = nvlist_create(0);
+ } else {
+ if (nvlist_exists_nvlist(limits, "groups"))
+ nvlist_free_nvlist(limits, "groups");
+ }
+ groups = nvlist_create(0);
+ for (i = 0; i < ngids; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "gid%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_number(groups, nvlname, (uint64_t)gids[i]);
+ }
+ for (i = 0; i < nnames; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "gid%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(groups, nvlname, names[i]);
+ }
+ nvlist_move_nvlist(limits, "groups", groups);
+ return (cap_limit_set(chan, limits));
+}
diff --git a/lib/libcapsicum/libcapsicum_grp.h b/lib/libcapsicum/libcapsicum_grp.h
new file mode 100644
index 0000000..e0b44f0
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_grp.h
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_GRP_H_
+#define _LIBCAPSICUM_GRP_H_
+
+struct group *cap_getgrent(cap_channel_t *chan);
+struct group *cap_getgrnam(cap_channel_t *chan, const char *name);
+struct group *cap_getgrgid(cap_channel_t *chan, gid_t gid);
+
+int cap_getgrent_r(cap_channel_t *chan, struct group *grp, char *buffer,
+ size_t bufsize, struct group **result);
+int cap_getgrnam_r(cap_channel_t *chan, const char *name, struct group *grp,
+ char *buffer, size_t bufsize, struct group **result);
+int cap_getgrgid_r(cap_channel_t *chan, gid_t gid, struct group *grp,
+ char *buffer, size_t bufsize, struct group **result);
+
+int cap_setgroupent(cap_channel_t *chan, int stayopen);
+int cap_setgrent(cap_channel_t *chan);
+void cap_endgrent(cap_channel_t *chan);
+
+int cap_grp_limit_cmds(cap_channel_t *chan, const char * const *cmds,
+ size_t ncmds);
+int cap_grp_limit_fields(cap_channel_t *chan, const char * const *fields,
+ size_t nfields);
+int cap_grp_limit_groups(cap_channel_t *chan, const char * const *names,
+ size_t nnames, gid_t *gids, size_t ngids);
+
+#endif /* !_LIBCAPSICUM_GRP_H_ */
diff --git a/lib/libcapsicum/libcapsicum_impl.h b/lib/libcapsicum/libcapsicum_impl.h
new file mode 100644
index 0000000..ce6f49f
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_impl.h
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_IMPL_H_
+#define _LIBCAPSICUM_IMPL_H_
+
+#define CASPER_SOCKPATH "/var/run/casper"
+
+bool fd_is_valid(int fd);
+
+#endif /* !_LIBCAPSICUM_IMPL_H_ */
diff --git a/lib/libcapsicum/libcapsicum_pwd.c b/lib/libcapsicum/libcapsicum_pwd.c
new file mode 100644
index 0000000..5b44c34
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_pwd.c
@@ -0,0 +1,391 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/nv.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "libcapsicum.h"
+#include "libcapsicum_pwd.h"
+
+static struct passwd gpwd;
+static char *gbuffer;
+static size_t gbufsize;
+
+static int
+passwd_resize(void)
+{
+ char *buf;
+
+ if (gbufsize == 0)
+ gbufsize = 1024;
+ else
+ gbufsize *= 2;
+
+ buf = gbuffer;
+ gbuffer = realloc(buf, gbufsize);
+ if (gbuffer == NULL) {
+ free(buf);
+ gbufsize = 0;
+ return (ENOMEM);
+ }
+ memset(gbuffer, 0, gbufsize);
+
+ return (0);
+}
+
+static int
+passwd_unpack_string(const nvlist_t *nvl, const char *fieldname, char **fieldp,
+ char **bufferp, size_t *bufsizep)
+{
+ const char *str;
+ size_t len;
+
+ str = nvlist_get_string(nvl, fieldname);
+ len = strlcpy(*bufferp, str, *bufsizep);
+ if (len >= *bufsizep)
+ return (ERANGE);
+ *fieldp = *bufferp;
+ *bufferp += len + 1;
+ *bufsizep -= len + 1;
+
+ return (0);
+}
+
+static int
+passwd_unpack(const nvlist_t *nvl, struct passwd *pwd, char *buffer,
+ size_t bufsize)
+{
+ int error;
+
+ if (!nvlist_exists_string(nvl, "pw_name"))
+ return (EINVAL);
+
+ memset(pwd, 0, sizeof(*pwd));
+
+ error = passwd_unpack_string(nvl, "pw_name", &pwd->pw_name, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ pwd->pw_uid = (uid_t)nvlist_get_number(nvl, "pw_uid");
+ pwd->pw_gid = (gid_t)nvlist_get_number(nvl, "pw_gid");
+ pwd->pw_change = (time_t)nvlist_get_number(nvl, "pw_change");
+ error = passwd_unpack_string(nvl, "pw_passwd", &pwd->pw_passwd, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ error = passwd_unpack_string(nvl, "pw_class", &pwd->pw_class, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ error = passwd_unpack_string(nvl, "pw_gecos", &pwd->pw_gecos, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ error = passwd_unpack_string(nvl, "pw_dir", &pwd->pw_dir, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ error = passwd_unpack_string(nvl, "pw_shell", &pwd->pw_shell, &buffer,
+ &bufsize);
+ if (error != 0)
+ return (error);
+ pwd->pw_expire = (time_t)nvlist_get_number(nvl, "pw_expire");
+ pwd->pw_fields = (int)nvlist_get_number(nvl, "pw_fields");
+
+ return (0);
+}
+
+static int
+cap_getpwcommon_r(cap_channel_t *chan, const char *cmd, const char *login,
+ uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize,
+ struct passwd **result)
+{
+ nvlist_t *nvl;
+ bool getpw_r;
+ int error;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", cmd);
+ if (strcmp(cmd, "getpwent") == 0 || strcmp(cmd, "getpwent_r") == 0) {
+ /* Add nothing. */
+ } else if (strcmp(cmd, "getpwnam") == 0 ||
+ strcmp(cmd, "getpwnam_r") == 0) {
+ nvlist_add_string(nvl, "name", login);
+ } else if (strcmp(cmd, "getpwuid") == 0 ||
+ strcmp(cmd, "getpwuid_r") == 0) {
+ nvlist_add_number(nvl, "uid", (uint64_t)uid);
+ } else {
+ abort();
+ }
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL) {
+ assert(errno != 0);
+ *result = NULL;
+ return (errno);
+ }
+ error = (int)nvlist_get_number(nvl, "error");
+ if (error != 0) {
+ nvlist_destroy(nvl);
+ *result = NULL;
+ return (error);
+ }
+
+ if (!nvlist_exists_string(nvl, "pw_name")) {
+ /* Not found. */
+ nvlist_destroy(nvl);
+ *result = NULL;
+ return (0);
+ }
+
+ getpw_r = (strcmp(cmd, "getpwent_r") == 0 ||
+ strcmp(cmd, "getpwnam_r") == 0 || strcmp(cmd, "getpwuid_r") == 0);
+
+ for (;;) {
+ error = passwd_unpack(nvl, pwd, buffer, bufsize);
+ if (getpw_r || error != ERANGE)
+ break;
+ assert(buffer == gbuffer);
+ assert(bufsize == gbufsize);
+ error = passwd_resize();
+ if (error != 0)
+ break;
+ /* Update pointers after resize. */
+ buffer = gbuffer;
+ bufsize = gbufsize;
+ }
+
+ nvlist_destroy(nvl);
+
+ if (error == 0)
+ *result = pwd;
+ else
+ *result = NULL;
+
+ return (error);
+}
+
+static struct passwd *
+cap_getpwcommon(cap_channel_t *chan, const char *cmd, const char *login,
+ uid_t uid)
+{
+ struct passwd *result;
+ int error, serrno;
+
+ serrno = errno;
+
+ error = cap_getpwcommon_r(chan, cmd, login, uid, &gpwd, gbuffer,
+ gbufsize, &result);
+ if (error != 0) {
+ errno = error;
+ return (NULL);
+ }
+
+ errno = serrno;
+
+ return (result);
+}
+
+struct passwd *
+cap_getpwent(cap_channel_t *chan)
+{
+
+ return (cap_getpwcommon(chan, "getpwent", NULL, 0));
+}
+
+struct passwd *
+cap_getpwnam(cap_channel_t *chan, const char *login)
+{
+
+ return (cap_getpwcommon(chan, "getpwnam", login, 0));
+}
+
+struct passwd *
+cap_getpwuid(cap_channel_t *chan, uid_t uid)
+{
+
+ return (cap_getpwcommon(chan, "getpwuid", NULL, uid));
+}
+
+int
+cap_getpwent_r(cap_channel_t *chan, struct passwd *pwd, char *buffer,
+ size_t bufsize, struct passwd **result)
+{
+
+ return (cap_getpwcommon_r(chan, "getpwent_r", NULL, 0, pwd, buffer,
+ bufsize, result));
+}
+
+int
+cap_getpwnam_r(cap_channel_t *chan, const char *name, struct passwd *pwd,
+ char *buffer, size_t bufsize, struct passwd **result)
+{
+
+ return (cap_getpwcommon_r(chan, "getpwnam_r", name, 0, pwd, buffer,
+ bufsize, result));
+}
+
+int
+cap_getpwuid_r(cap_channel_t *chan, uid_t uid, struct passwd *pwd, char *buffer,
+ size_t bufsize, struct passwd **result)
+{
+
+ return (cap_getpwcommon_r(chan, "getpwuid_r", NULL, uid, pwd, buffer,
+ bufsize, result));
+}
+
+int
+cap_setpassent(cap_channel_t *chan, int stayopen)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "setpassent");
+ nvlist_add_bool(nvl, "stayopen", stayopen != 0);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (0);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ errno = nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (0);
+ }
+ nvlist_destroy(nvl);
+
+ return (1);
+}
+
+static void
+cap_set_end_pwent(cap_channel_t *chan, const char *cmd)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", cmd);
+ /* Ignore any errors, we have no way to report them. */
+ nvlist_destroy(cap_xfer_nvlist(chan, nvl, 0));
+}
+
+void
+cap_setpwent(cap_channel_t *chan)
+{
+
+ cap_set_end_pwent(chan, "setpwent");
+}
+
+void
+cap_endpwent(cap_channel_t *chan)
+{
+
+ cap_set_end_pwent(chan, "endpwent");
+}
+
+int
+cap_pwd_limit_cmds(cap_channel_t *chan, const char * const *cmds, size_t ncmds)
+{
+ nvlist_t *limits, *nvl;
+ unsigned int i;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL) {
+ limits = nvlist_create(0);
+ } else {
+ if (nvlist_exists_nvlist(limits, "cmds"))
+ nvlist_free_nvlist(limits, "cmds");
+ }
+ nvl = nvlist_create(0);
+ for (i = 0; i < ncmds; i++)
+ nvlist_add_null(nvl, cmds[i]);
+ nvlist_move_nvlist(limits, "cmds", nvl);
+ return (cap_limit_set(chan, limits));
+}
+
+int
+cap_pwd_limit_fields(cap_channel_t *chan, const char * const *fields,
+ size_t nfields)
+{
+ nvlist_t *limits, *nvl;
+ unsigned int i;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL) {
+ limits = nvlist_create(0);
+ } else {
+ if (nvlist_exists_nvlist(limits, "fields"))
+ nvlist_free_nvlist(limits, "fields");
+ }
+ nvl = nvlist_create(0);
+ for (i = 0; i < nfields; i++)
+ nvlist_add_null(nvl, fields[i]);
+ nvlist_move_nvlist(limits, "fields", nvl);
+ return (cap_limit_set(chan, limits));
+}
+
+int
+cap_pwd_limit_users(cap_channel_t *chan, const char * const *names,
+ size_t nnames, uid_t *uids, size_t nuids)
+{
+ nvlist_t *limits, *users;
+ char nvlname[64];
+ unsigned int i;
+ int n;
+
+ if (cap_limit_get(chan, &limits) < 0)
+ return (-1);
+ if (limits == NULL) {
+ limits = nvlist_create(0);
+ } else {
+ if (nvlist_exists_nvlist(limits, "users"))
+ nvlist_free_nvlist(limits, "users");
+ }
+ users = nvlist_create(0);
+ for (i = 0; i < nuids; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "uid%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_number(users, nvlname, (uint64_t)uids[i]);
+ }
+ for (i = 0; i < nnames; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "name%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(users, nvlname, names[i]);
+ }
+ nvlist_move_nvlist(limits, "users", users);
+ return (cap_limit_set(chan, limits));
+}
diff --git a/lib/libcapsicum/libcapsicum_pwd.h b/lib/libcapsicum/libcapsicum_pwd.h
new file mode 100644
index 0000000..960a490
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_pwd.h
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_PWD_H_
+#define _LIBCAPSICUM_PWD_H_
+
+struct passwd *cap_getpwent(cap_channel_t *chan);
+struct passwd *cap_getpwnam(cap_channel_t *chan, const char *login);
+struct passwd *cap_getpwuid(cap_channel_t *chan, uid_t uid);
+
+int cap_getpwent_r(cap_channel_t *chan, struct passwd *pwd, char *buffer,
+ size_t bufsize, struct passwd **result);
+int cap_getpwnam_r(cap_channel_t *chan, const char *name, struct passwd *pwd,
+ char *buffer, size_t bufsize, struct passwd **result);
+int cap_getpwuid_r(cap_channel_t *chan, uid_t uid, struct passwd *pwd,
+ char *buffer, size_t bufsize, struct passwd **result);
+
+int cap_setpassent(cap_channel_t *chan, int stayopen);
+void cap_setpwent(cap_channel_t *chan);
+void cap_endpwent(cap_channel_t *chan);
+
+int cap_pwd_limit_cmds(cap_channel_t *chan, const char * const *cmds,
+ size_t ncmds);
+int cap_pwd_limit_fields(cap_channel_t *chan, const char * const *fields,
+ size_t nfields);
+int cap_pwd_limit_users(cap_channel_t *chan, const char * const *names,
+ size_t nnames, uid_t *uids, size_t nuids);
+
+#endif /* !_LIBCAPSICUM_PWD_H_ */
diff --git a/lib/libcapsicum/libcapsicum_random.c b/lib/libcapsicum/libcapsicum_random.c
new file mode 100644
index 0000000..2a7b109
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_random.c
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include "libcapsicum.h"
+#include "libcapsicum_random.h"
+
+#define MAXSIZE (1024 * 1024)
+
+int
+cap_random_buf(cap_channel_t *chan, void *buf, size_t nbytes)
+{
+ nvlist_t *nvl;
+ const void *randbuf;
+ uint8_t *ptr;
+ size_t left, randbufsize;
+
+ left = nbytes;
+ ptr = buf;
+
+ while (left > 0) {
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "generate");
+ nvlist_add_number(nvl, "size",
+ (uint64_t)(left > MAXSIZE ? MAXSIZE : left));
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (-1);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ errno = (int)nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (-1);
+ }
+
+ randbuf = nvlist_get_binary(nvl, "data", &randbufsize);
+ memcpy(ptr, randbuf, randbufsize);
+
+ nvlist_destroy(nvl);
+
+ ptr += randbufsize;
+ assert(left >= randbufsize);
+ left -= randbufsize;
+ }
+
+ return (0);
+}
diff --git a/lib/libcapsicum/libcapsicum_random.h b/lib/libcapsicum/libcapsicum_random.h
new file mode 100644
index 0000000..672afa0
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_random.h
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_RANDOM_H_
+#define _LIBCAPSICUM_RANDOM_H_
+
+int cap_random_buf(cap_channel_t *chan, void *buf, size_t nbytes);
+
+#endif /* !_LIBCAPSICUM_RANDOM_H_ */
diff --git a/lib/libcapsicum/libcapsicum_service.c b/lib/libcapsicum/libcapsicum_service.c
new file mode 100644
index 0000000..6b6ceea
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_service.c
@@ -0,0 +1,97 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "msgio.h"
+
+#include "libcapsicum.h"
+#include "libcapsicum_impl.h"
+#include "libcapsicum_service.h"
+
+cap_channel_t *
+cap_service_open(const cap_channel_t *chan, const char *name)
+{
+ cap_channel_t *newchan;
+ nvlist_t *nvl;
+ int sock, error;
+
+ sock = -1;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "open");
+ nvlist_add_string(nvl, "service", name);
+ if (fd_is_valid(STDERR_FILENO))
+ nvlist_add_descriptor(nvl, "stderrfd", STDERR_FILENO);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (NULL);
+ error = (int)nvlist_get_number(nvl, "error");
+ if (error != 0) {
+ nvlist_destroy(nvl);
+ errno = error;
+ return (NULL);
+ }
+ sock = nvlist_take_descriptor(nvl, "chanfd");
+ assert(sock >= 0);
+ nvlist_destroy(nvl);
+ nvl = NULL;
+ if (cred_send(sock) == -1)
+ goto fail;
+ newchan = cap_wrap(sock);
+ if (newchan == NULL)
+ goto fail;
+ return (newchan);
+fail:
+ error = errno;
+ close(sock);
+ errno = error;
+ return (NULL);
+}
+
+int
+cap_service_limit(const cap_channel_t *chan, const char * const *names,
+ size_t nnames)
+{
+ nvlist_t *limits;
+ unsigned int i;
+
+ limits = nvlist_create(0);
+ for (i = 0; i < nnames; i++)
+ nvlist_add_null(limits, names[i]);
+ return (cap_limit_set(chan, limits));
+}
diff --git a/lib/libcapsicum/libcapsicum_service.h b/lib/libcapsicum/libcapsicum_service.h
new file mode 100644
index 0000000..05c654f
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_service.h
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_SERVICE_H_
+#define _LIBCAPSICUM_SERVICE_H_
+
+cap_channel_t *cap_service_open(const cap_channel_t *chan, const char *name);
+
+int cap_service_limit(const cap_channel_t *chan, const char * const *names,
+ size_t nnames);
+
+#endif /* !_LIBCAPSICUM_SERVICE_H_ */
diff --git a/lib/libcapsicum/libcapsicum_sysctl.c b/lib/libcapsicum/libcapsicum_sysctl.c
new file mode 100644
index 0000000..3f1ccd9
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_sysctl.c
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include "libcapsicum.h"
+#include "libcapsicum_sysctl.h"
+
+int
+cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp,
+ size_t *oldlenp, const void *newp, size_t newlen)
+{
+ nvlist_t *nvl;
+ const uint8_t *retoldp;
+ uint8_t operation;
+ size_t oldlen;
+
+ operation = 0;
+ if (oldp != NULL)
+ operation |= CAP_SYSCTL_READ;
+ if (newp != NULL)
+ operation |= CAP_SYSCTL_WRITE;
+
+ nvl = nvlist_create(0);
+ nvlist_add_string(nvl, "cmd", "sysctl");
+ nvlist_add_string(nvl, "name", name);
+ nvlist_add_number(nvl, "operation", (uint64_t)operation);
+ if (oldp == NULL && oldlenp != NULL)
+ nvlist_add_null(nvl, "justsize");
+ else if (oldlenp != NULL)
+ nvlist_add_number(nvl, "oldlen", (uint64_t)*oldlenp);
+ if (newp != NULL)
+ nvlist_add_binary(nvl, "newp", newp, newlen);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
+ if (nvl == NULL)
+ return (-1);
+ if (nvlist_get_number(nvl, "error") != 0) {
+ errno = (int)nvlist_get_number(nvl, "error");
+ nvlist_destroy(nvl);
+ return (-1);
+ }
+
+ if (oldp == NULL && oldlenp != NULL) {
+ *oldlenp = (size_t)nvlist_get_number(nvl, "oldlen");
+ } else if (oldp != NULL) {
+ retoldp = nvlist_get_binary(nvl, "oldp", &oldlen);
+ memcpy(oldp, retoldp, oldlen);
+ if (oldlenp != NULL)
+ *oldlenp = oldlen;
+ }
+ nvlist_destroy(nvl);
+
+ return (0);
+}
diff --git a/lib/libcapsicum/libcapsicum_sysctl.h b/lib/libcapsicum/libcapsicum_sysctl.h
new file mode 100644
index 0000000..d0df143
--- /dev/null
+++ b/lib/libcapsicum/libcapsicum_sysctl.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBCAPSICUM_SYSCTL_H_
+#define _LIBCAPSICUM_SYSCTL_H_
+
+#define CAP_SYSCTL_READ 0x01
+#define CAP_SYSCTL_WRITE 0x02
+#define CAP_SYSCTL_RDWR (CAP_SYSCTL_READ | CAP_SYSCTL_WRITE)
+#define CAP_SYSCTL_RECURSIVE 0x04
+
+int cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp,
+ size_t *oldlenp, const void *newp, size_t newlen);
+
+#endif /* !_LIBCAPSICUM_SYSCTL_H_ */
diff --git a/lib/libcasper/libcasper/Makefile b/lib/libcasper/libcasper/Makefile
index 6fbdffb..c8eface 100644
--- a/lib/libcasper/libcasper/Makefile
+++ b/lib/libcasper/libcasper/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=${LIB}
LIB= casper
SHLIB_MAJOR= 0
diff --git a/lib/libcasper/services/cap_dns/Makefile b/lib/libcasper/services/cap_dns/Makefile
index c52f6bf..2582fe8 100644
--- a/lib/libcasper/services/cap_dns/Makefile
+++ b/lib/libcasper/services/cap_dns/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=libcasper
LIB= cap_dns
SHLIB_MAJOR= 0
diff --git a/lib/libcasper/services/cap_grp/Makefile b/lib/libcasper/services/cap_grp/Makefile
index 8a552d2..195b08d 100644
--- a/lib/libcasper/services/cap_grp/Makefile
+++ b/lib/libcasper/services/cap_grp/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=libcasper
LIB= cap_grp
SHLIB_MAJOR= 0
diff --git a/lib/libcasper/services/cap_pwd/Makefile b/lib/libcasper/services/cap_pwd/Makefile
index 294ce7e..3e604bd 100644
--- a/lib/libcasper/services/cap_pwd/Makefile
+++ b/lib/libcasper/services/cap_pwd/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=libcasper
LIB= cap_pwd
SHLIB_MAJOR= 0
diff --git a/lib/libcasper/services/cap_random/Makefile b/lib/libcasper/services/cap_random/Makefile
index 61dcc6c..97a27be 100644
--- a/lib/libcasper/services/cap_random/Makefile
+++ b/lib/libcasper/services/cap_random/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=libcasper
LIB= cap_random
SHLIB_MAJOR= 0
diff --git a/lib/libcasper/services/cap_sysctl/Makefile b/lib/libcasper/services/cap_sysctl/Makefile
index ba3a4b3..7501f37 100644
--- a/lib/libcasper/services/cap_sysctl/Makefile
+++ b/lib/libcasper/services/cap_sysctl/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=libcasper
LIB= cap_sysctl
SHLIB_MAJOR= 0
diff --git a/lib/libcom_err/Makefile b/lib/libcom_err/Makefile
index 72260fe..b6f389f 100644
--- a/lib/libcom_err/Makefile
+++ b/lib/libcom_err/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= com_err
SRCS= com_err.c error.c
INCS= ${COM_ERRDIR}/com_err.h ${COM_ERRDIR}/com_right.h
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile
index fca86c7..0bd47df 100644
--- a/lib/libcompat/Makefile
+++ b/lib/libcompat/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= compat
CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS -I${.CURDIR}/../libc/locale
NO_PIC=
diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile
index 3c7896d..8959225 100644
--- a/lib/libcompiler_rt/Makefile
+++ b/lib/libcompiler_rt/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= compiler_rt
NO_PIC=
WARNS?= 2
diff --git a/lib/libcrypt/Makefile b/lib/libcrypt/Makefile
index d5d0347..c1f8542 100644
--- a/lib/libcrypt/Makefile
+++ b/lib/libcrypt/Makefile
@@ -2,6 +2,7 @@
# $FreeBSD$
#
+PACKAGE=lib${LIB}
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libcrypt/tests/Makefile b/lib/libcrypt/tests/Makefile
index 15798b2..0c831ad 100644
--- a/lib/libcrypt/tests/Makefile
+++ b/lib/libcrypt/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= crypt_tests
NETBSD_ATF_TESTS_C+= crypt_test
diff --git a/lib/libcuse/Makefile b/lib/libcuse/Makefile
index a232fa2..607d36b 100644
--- a/lib/libcuse/Makefile
+++ b/lib/libcuse/Makefile
@@ -24,6 +24,7 @@
# SUCH DAMAGE.
#
+PACKAGE=lib${LIB}
LIB= cuse
SHLIB_MAJOR= 1
SHLIB_MINOR= 0
diff --git a/lib/libcxxrt/Makefile b/lib/libcxxrt/Makefile
index d197361..8f3d9c5 100644
--- a/lib/libcxxrt/Makefile
+++ b/lib/libcxxrt/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= clibs
SRCDIR= ${.CURDIR}/../../contrib/libcxxrt
SHLIB_MAJOR= 1
diff --git a/lib/libdevctl/Makefile b/lib/libdevctl/Makefile
index 74687ec..ed56b25 100644
--- a/lib/libdevctl/Makefile
+++ b/lib/libdevctl/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= devctl
SRCS= devctl.c
INCS= devctl.h
diff --git a/lib/libdevinfo/Makefile b/lib/libdevinfo/Makefile
index 9e755d7..6c0927e 100644
--- a/lib/libdevinfo/Makefile
+++ b/lib/libdevinfo/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= devinfo
SRCS= devinfo.c
INCS= devinfo.h
diff --git a/lib/libdevstat/Makefile b/lib/libdevstat/Makefile
index dcda3c2..df5d44e 100644
--- a/lib/libdevstat/Makefile
+++ b/lib/libdevstat/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= devstat
SHLIBDIR?= /lib
# Bump DEVSTAT_USER_API_VER in devstat.h every time this is incremented.
diff --git a/lib/libdpv/Makefile b/lib/libdpv/Makefile
index 3a9921c..d9bef05 100644
--- a/lib/libdpv/Makefile
+++ b/lib/libdpv/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= dpv
SHLIB_MAJOR= 1
INCS= dpv.h
diff --git a/lib/libdwarf/Makefile b/lib/libdwarf/Makefile
index bd98d8f..1e2506d 100644
--- a/lib/libdwarf/Makefile
+++ b/lib/libdwarf/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
+PACKAGE=lib${LIB}
TOP= ${.CURDIR}/../../contrib/elftoolchain
SRCDIR= ${TOP}/libdwarf
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile
index 8a97ce0..14c9cbb 100644
--- a/lib/libedit/Makefile
+++ b/lib/libedit/Makefile
@@ -2,6 +2,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$
+PACKAGE=clibs
LIB= edit
SHLIB_MAJOR= 7
SHLIBDIR?= /lib
diff --git a/lib/libefi/Makefile b/lib/libefi/Makefile
index 16aa3e7..d9862f0 100644
--- a/lib/libefi/Makefile
+++ b/lib/libefi/Makefile
@@ -2,6 +2,7 @@
.include <bsd.own.mk>
+PACKAGE=lib${LIB}
LIB= efi
SHLIB_MAJOR= 1
diff --git a/lib/libelf/Makefile b/lib/libelf/Makefile
index f622921..70d9e9b 100644
--- a/lib/libelf/Makefile
+++ b/lib/libelf/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
SHLIBDIR?= /lib
.include <bsd.own.mk>
diff --git a/lib/libelftc/Makefile b/lib/libelftc/Makefile
index ed5c02a..e2269b4 100644
--- a/lib/libelftc/Makefile
+++ b/lib/libelftc/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
+PACKAGE=lib${LIB}
INTERNALLIB=
ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain
diff --git a/lib/libevent/Makefile b/lib/libevent/Makefile
index 1d20bcd..d8cc572 100644
--- a/lib/libevent/Makefile
+++ b/lib/libevent/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
.PATH: ${.CURDIR}/../../contrib/pf/libevent
.include <src.opts.mk>
diff --git a/lib/libexecinfo/Makefile b/lib/libexecinfo/Makefile
index 5f9aac5..c444f7f 100644
--- a/lib/libexecinfo/Makefile
+++ b/lib/libexecinfo/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIBEXECINFO= ${.CURDIR}/../../contrib/libexecinfo
LIB= execinfo
diff --git a/lib/libexpat/Makefile b/lib/libexpat/Makefile
index 0d4bef5..d0de3e0 100644
--- a/lib/libexpat/Makefile
+++ b/lib/libexpat/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
EXPAT= ${.CURDIR}/../../contrib/expat
LIB= bsdxml
diff --git a/lib/libfetch/Makefile b/lib/libfetch/Makefile
index 4f56552..abd5f8d 100644
--- a/lib/libfetch/Makefile
+++ b/lib/libfetch/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= fetch
CFLAGS+= -I.
SRCS= fetch.c common.c ftp.c http.c file.c \
diff --git a/lib/libfigpar/Makefile b/lib/libfigpar/Makefile
index bb24da3..6d49546 100644
--- a/lib/libfigpar/Makefile
+++ b/lib/libfigpar/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= figpar
SHLIB_MAJOR= 0
INCS= figpar.h string_m.h
diff --git a/lib/libgeom/Makefile b/lib/libgeom/Makefile
index 20b7a4c..ea1f6c8 100644
--- a/lib/libgeom/Makefile
+++ b/lib/libgeom/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= geom
SHLIBDIR?= /lib
SRCS+= geom_getxml.c
diff --git a/lib/libgpio/Makefile b/lib/libgpio/Makefile
index 94118d6..fc163e9 100644
--- a/lib/libgpio/Makefile
+++ b/lib/libgpio/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= gpio
SHLIB_MAJOR= 0
diff --git a/lib/libgssapi/Makefile b/lib/libgssapi/Makefile
index 3f016b4..a486101 100644
--- a/lib/libgssapi/Makefile
+++ b/lib/libgssapi/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= gssapi
SHLIB_MAJOR= 10
VERSION_DEF= ${.CURDIR}/../libc/Versions.def
diff --git a/lib/libipsec/Makefile b/lib/libipsec/Makefile
index 7d3e94a..460a5d7 100644
--- a/lib/libipsec/Makefile
+++ b/lib/libipsec/Makefile
@@ -27,6 +27,7 @@
#
# $FreeBSD$
+PACKAGE=lib${LIB}
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libjail/Makefile b/lib/libjail/Makefile
index 442274a..74eb8e1 100644
--- a/lib/libjail/Makefile
+++ b/lib/libjail/Makefile
@@ -1,11 +1,14 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= jail
SHLIBDIR?= /lib
SHLIB_MAJOR= 1
SRCS= jail.c jail_getid.c
INCS= jail.h
+PACKAGE=jail
+
MAN= jail.3
MLINKS+=jail.3 jail_getid.3
diff --git a/lib/libkiconv/Makefile b/lib/libkiconv/Makefile
index c7b2179..5ada7db 100644
--- a/lib/libkiconv/Makefile
+++ b/lib/libkiconv/Makefile
@@ -4,6 +4,7 @@ SHLIBDIR?= /lib
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= kiconv
SRCS= kiconv_sysctl.c xlat16_iconv.c xlat16_sysctl.c
SRCS+= quirks.c
diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile
index 33f8e5b..0fdeec9 100644
--- a/lib/libkvm/Makefile
+++ b/lib/libkvm/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= kvm
SHLIBDIR?= /lib
diff --git a/lib/libldns/Makefile b/lib/libldns/Makefile
index 9a436cd..14dc9f9 100644
--- a/lib/libldns/Makefile
+++ b/lib/libldns/Makefile
@@ -3,6 +3,7 @@
# Vendor sources and generated files
LDNSDIR = ${.CURDIR}/../../contrib/ldns
+PACKAGE=lib${LIB}
.PATH: ${LDNSDIR} ${LDNSDIR}/compat
LIB= ldns
diff --git a/lib/liblzma/Makefile b/lib/liblzma/Makefile
index 8a6c23d..62c2994 100644
--- a/lib/liblzma/Makefile
+++ b/lib/liblzma/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= lzma
LZMADIR= ${.CURDIR}/../../contrib/xz/src/liblzma
diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index 2add1d3..d77de6c4 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
# Copyright (c) David E. O'Brien, 2000-2004, 2006, 2009
+PACKAGE=lib${LIB}
CONTRDIR= ${.CURDIR}/../../contrib/file
.PATH: ${CONTRDIR}/src
.PATH: ${CONTRDIR}/doc
diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile
index 43b8a5a..bde4fb5 100644
--- a/lib/libmd/Makefile
+++ b/lib/libmd/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= md
SHLIB_MAJOR= 6
SHLIBDIR?= /lib
diff --git a/lib/libmemstat/Makefile b/lib/libmemstat/Makefile
index 597dc6d..8554eb0 100644
--- a/lib/libmemstat/Makefile
+++ b/lib/libmemstat/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
WARNS?= 3
LIB= memstat
SHLIB_MAJOR= 3
diff --git a/lib/libmilter/Makefile b/lib/libmilter/Makefile
index 81172ec..88a80b7 100644
--- a/lib/libmilter/Makefile
+++ b/lib/libmilter/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=sendmail
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libmilter ${SENDMAIL_DIR}/libsm
diff --git a/lib/libmp/Makefile b/lib/libmp/Makefile
index 6a73658..8d8c527 100644
--- a/lib/libmp/Makefile
+++ b/lib/libmp/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= mp
SHLIB_MAJOR= 7
LIBADD= crypto
diff --git a/lib/libmp/tests/Makefile b/lib/libmp/tests/Makefile
index 42749d0..86f0985 100644
--- a/lib/libmp/tests/Makefile
+++ b/lib/libmp/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_C+= legacy_test
LIBADD+= mp
diff --git a/lib/libmt/Makefile b/lib/libmt/Makefile
index 6fe5920..c67130e 100644
--- a/lib/libmt/Makefile
+++ b/lib/libmt/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= mt
SHLIBDIR?= /lib
SRCS= mtlib.c
diff --git a/lib/libnandfs/Makefile b/lib/libnandfs/Makefile
index d87573e..e900c3c 100644
--- a/lib/libnandfs/Makefile
+++ b/lib/libnandfs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= nandfs
SRCS+= nandfs.c
INCS= libnandfs.h
diff --git a/lib/libnetbsd/Makefile b/lib/libnetbsd/Makefile
index 09c6985..92ad745 100644
--- a/lib/libnetbsd/Makefile
+++ b/lib/libnetbsd/Makefile
@@ -2,6 +2,7 @@
.include <bsd.own.mk>
+PACKAGE=lib${LIB}
LIB= netbsd
CFLAGS+= -I${.CURDIR}
diff --git a/lib/libnetgraph/Makefile b/lib/libnetgraph/Makefile
index d0c444e..d3c7c3f 100644
--- a/lib/libnetgraph/Makefile
+++ b/lib/libnetgraph/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
# $Whistle: Makefile,v 1.4 1999/01/17 03:41:02 julian Exp $
+PACKAGE=lib${LIB}
LIB= netgraph
WARNS?= 3
MAN= netgraph.3
diff --git a/lib/libngatm/Makefile b/lib/libngatm/Makefile
index 85294b0..71f21d5 100644
--- a/lib/libngatm/Makefile
+++ b/lib/libngatm/Makefile
@@ -2,6 +2,7 @@
#
# Author: Harti Brandt <harti@freebsd.org>
#
+PACKAGE=lib${LIB}
LIB= ngatm
SHLIB_MAJOR= 4
MAN= libngatm.3 uniaddr.3 unifunc.3 unimsg.3 unisap.3 unistruct.3
diff --git a/lib/libnv/Makefile b/lib/libnv/Makefile
index f0ed8c4..4b2125b 100644
--- a/lib/libnv/Makefile
+++ b/lib/libnv/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libnv/tests/Makefile b/lib/libnv/tests/Makefile
index cce0b5e..d815af4 100644
--- a/lib/libnv/tests/Makefile
+++ b/lib/libnv/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_CXX= \
dnv_tests \
nv_array_tests \
diff --git a/lib/libopenbsd/Makefile b/lib/libopenbsd/Makefile
index 3eb6b74..afb41b3 100644
--- a/lib/libopenbsd/Makefile
+++ b/lib/libopenbsd/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= openbsd
SRCS= getdtablecount.c \
imsg-buffer.c \
diff --git a/lib/libopie/Makefile b/lib/libopie/Makefile
index e66e67a..367bbc6 100644
--- a/lib/libopie/Makefile
+++ b/lib/libopie/Makefile
@@ -2,6 +2,7 @@
#
# $FreeBSD$
#
+PACKAGE=lib${LIB}
OPIE_DIST?= ${.CURDIR}/../../contrib/opie
DIST_DIR= ${OPIE_DIST}/${.CURDIR:T}
SHLIB_MAJOR= 8
diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile
index 1dc977f..c7122c7 100644
--- a/lib/libpam/libpam/Makefile
+++ b/lib/libpam/libpam/Makefile
@@ -35,6 +35,7 @@
#
# $FreeBSD$
+PACKAGE=lib${LIB}
OPENPAM= ${.CURDIR}/../../../contrib/openpam
.PATH: ${OPENPAM}/include ${OPENPAM}/lib/libpam ${OPENPAM}/doc/man
diff --git a/lib/libpam/libpam/tests/Makefile b/lib/libpam/libpam/tests/Makefile
index e40936a..ec32229 100644
--- a/lib/libpam/libpam/tests/Makefile
+++ b/lib/libpam/libpam/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
OPENPAM= ${SRCTOP}/contrib/openpam
.PATH: ${OPENPAM}/t
diff --git a/lib/libpam/modules/pam_ssh/Makefile b/lib/libpam/modules/pam_ssh/Makefile
index 21991dc..8965018 100644
--- a/lib/libpam/modules/pam_ssh/Makefile
+++ b/lib/libpam/modules/pam_ssh/Makefile
@@ -6,6 +6,7 @@ SSHDIR= ${.CURDIR}/../../../../crypto/openssh
LIB= pam_ssh
MAN= pam_ssh.8
SRCS= pam_ssh.c
+PACKAGE= ssh
# required when linking with a dynamic libssh
SRCS+= roaming_dummy.c
diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile
index cdc0228..e7512e6 100644
--- a/lib/libpcap/Makefile
+++ b/lib/libpcap/Makefile
@@ -5,6 +5,7 @@ SHLIBDIR?= /lib
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= pcap
SRCS= grammar.y tokdefs.h version.h pcap-bpf.c \
pcap-netmap.c \
diff --git a/lib/libpjdlog/Makefile b/lib/libpjdlog/Makefile
index ead5619..4fcfe02 100644
--- a/lib/libpjdlog/Makefile
+++ b/lib/libpjdlog/Makefile
@@ -2,6 +2,7 @@
# $FreeBSD$
#
+PACKAGE=lib${LIB}
SHLIBDIR?= /lib
.include <bsd.own.mk>
diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile
index b240070..30510f6 100644
--- a/lib/libpmc/Makefile
+++ b/lib/libpmc/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= pmc
SRCS= libpmc.c pmclog.c
diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
index 8c4f484..0372377 100644
--- a/lib/libproc/Makefile
+++ b/lib/libproc/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= proc
SRCS= proc_bkpt.c \
diff --git a/lib/libproc/tests/Makefile b/lib/libproc/tests/Makefile
index d48250e..768078e 100644
--- a/lib/libproc/tests/Makefile
+++ b/lib/libproc/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C+= proc_test
PROGS= target_prog
diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile
index fc71dbc..240718d 100644
--- a/lib/libprocstat/Makefile
+++ b/lib/libprocstat/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= procstat
SRCS= cd9660.c \
diff --git a/lib/libradius/Makefile b/lib/libradius/Makefile
index 42f5def..3ce1435 100644
--- a/lib/libradius/Makefile
+++ b/lib/libradius/Makefile
@@ -26,6 +26,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= radius
SRCS= radlib.c
INCS= radlib.h radlib_vs.h
diff --git a/lib/librpcsec_gss/Makefile b/lib/librpcsec_gss/Makefile
index c3e76844..e59f1e5 100644
--- a/lib/librpcsec_gss/Makefile
+++ b/lib/librpcsec_gss/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= rpcsec_gss
SHLIB_MAJOR= 1
SRCS+= rpcsec_gss.c rpcsec_gss_prot.c rpcsec_gss_conf.c rpcsec_gss_misc.c \
diff --git a/lib/librpcsvc/Makefile b/lib/librpcsvc/Makefile
index ba972ac..1deda17 100644
--- a/lib/librpcsvc/Makefile
+++ b/lib/librpcsvc/Makefile
@@ -5,6 +5,7 @@
.PATH: ${.CURDIR}/../../include/rpcsvc
+PACKAGE=lib${LIB}
LIB= rpcsvc
RPCSRCS= klm_prot.x mount.x nfs_prot.x nlm_prot.x rex.x rnusers.x \
diff --git a/lib/librt/Makefile b/lib/librt/Makefile
index 3c16976..560f2af 100644
--- a/lib/librt/Makefile
+++ b/lib/librt/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB=rt
SHLIB_MAJOR= 1
CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}
diff --git a/lib/librt/tests/Makefile b/lib/librt/tests/Makefile
index c4817ec..7f788ae 100644
--- a/lib/librt/tests/Makefile
+++ b/lib/librt/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
LIBADD= rt
NETBSD_ATF_TESTS_C= sched_test
diff --git a/lib/librtld_db/Makefile b/lib/librtld_db/Makefile
index 9f9b603..eec7970 100644
--- a/lib/librtld_db/Makefile
+++ b/lib/librtld_db/Makefile
@@ -2,6 +2,7 @@
.include <bsd.own.mk>
+PACKAGE=lib${LIB}
LIB= rtld_db
SHLIB_MAJOR= 2
MAN= librtld_db.3
diff --git a/lib/libsbuf/Makefile b/lib/libsbuf/Makefile
index 98ceeb6..ebf4a8d 100644
--- a/lib/libsbuf/Makefile
+++ b/lib/libsbuf/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= sbuf
SHLIBDIR?= /lib
SRCS= subr_prf.c subr_sbuf.c
diff --git a/lib/libsdp/Makefile b/lib/libsdp/Makefile
index fcedb50..0037252 100644
--- a/lib/libsdp/Makefile
+++ b/lib/libsdp/Makefile
@@ -1,6 +1,7 @@
# $Id: Makefile,v 1.2 2003/09/07 20:34:19 max Exp $
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= sdp
MAN= sdp.3
diff --git a/lib/libsm/Makefile b/lib/libsm/Makefile
index 1ec2dc1..9840092 100644
--- a/lib/libsm/Makefile
+++ b/lib/libsm/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=sendmail
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libsm
diff --git a/lib/libsmb/Makefile b/lib/libsmb/Makefile
index b63754b..6236a2e 100644
--- a/lib/libsmb/Makefile
+++ b/lib/libsmb/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
CONTRIBDIR= ${.CURDIR}/../../contrib/smbfs
.PATH: ${CONTRIBDIR}/lib/smb
diff --git a/lib/libsmdb/Makefile b/lib/libsmdb/Makefile
index f1f5199..3fbd116 100644
--- a/lib/libsmdb/Makefile
+++ b/lib/libsmdb/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libsmdb
diff --git a/lib/libsmutil/Makefile b/lib/libsmutil/Makefile
index e7919ea..e1d908e 100644
--- a/lib/libsmutil/Makefile
+++ b/lib/libsmutil/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libsmutil
diff --git a/lib/libsqlite3/Makefile b/lib/libsqlite3/Makefile
index d446151..37a3a6e 100644
--- a/lib/libsqlite3/Makefile
+++ b/lib/libsqlite3/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
PRIVATELIB= yes
LIB= sqlite3
SHLIB_MAJOR?= 0
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile
index 82e65f2..835b535 100644
--- a/lib/libstand/Makefile
+++ b/lib/libstand/Makefile
@@ -6,6 +6,7 @@
# quite large.
#
+PACKAGE=lib${LIB}
MK_PROFILE= no
MK_SSP= no
diff --git a/lib/libstdbuf/Makefile b/lib/libstdbuf/Makefile
index ea233a8..7d8c3ca 100644
--- a/lib/libstdbuf/Makefile
+++ b/lib/libstdbuf/Makefile
@@ -2,6 +2,7 @@
.include <bsd.own.mk>
+PACKAGE=lib${LIB}
LIB= stdbuf
SRCS= stdbuf.c
SHLIB_MAJOR= 1
diff --git a/lib/libstdthreads/Makefile b/lib/libstdthreads/Makefile
index 8daee58..3200d4e 100644
--- a/lib/libstdthreads/Makefile
+++ b/lib/libstdthreads/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= stdthreads
SHLIB_MAJOR= 0
diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
index 405cab8..742c513 100644
--- a/lib/libsysdecode/Makefile
+++ b/lib/libsysdecode/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= sysdecode
SRCS= errno.c ioctl.c syscallnames.c utrace.c
diff --git a/lib/libtacplus/Makefile b/lib/libtacplus/Makefile
index 01345e1..73d8e76 100644
--- a/lib/libtacplus/Makefile
+++ b/lib/libtacplus/Makefile
@@ -24,6 +24,7 @@
#
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= tacplus
SRCS= taclib.c
INCS= taclib.h
diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile
index 7f73733..b5bba12 100644
--- a/lib/libtelnet/Makefile
+++ b/lib/libtelnet/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
TELNETDIR= ${.CURDIR}/../../contrib/telnet
.PATH: ${TELNETDIR}/libtelnet
diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile
index 1717672..7a080e0 100644
--- a/lib/libthr/Makefile
+++ b/lib/libthr/Makefile
@@ -8,6 +8,7 @@
# (for system call stubs) to CFLAGS below. -DSYSLIBC_SCCS affects just the
# system call stubs.
+PACKAGE= clibs
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile
index aeb1ef8..6c2139a 100644
--- a/lib/libthr/tests/Makefile
+++ b/lib/libthr/tests/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread
# TODO: t_name (missing pthread_getname_np support in FreeBSD)
diff --git a/lib/libthr/tests/dlopen/Makefile b/lib/libthr/tests/dlopen/Makefile
index bea70ec..1f587a5 100644
--- a/lib/libthr/tests/dlopen/Makefile
+++ b/lib/libthr/tests/dlopen/Makefile
@@ -4,6 +4,9 @@ TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/lib/libthr/dlopen
CFLAGS+= -DTESTDIR=\"${TESTSDIR:Q}/\"
diff --git a/lib/libthr/tests/dlopen/dso/Makefile b/lib/libthr/tests/dlopen/dso/Makefile
index 23d4cd6..a7f685f 100644
--- a/lib/libthr/tests/dlopen/dso/Makefile
+++ b/lib/libthr/tests/dlopen/dso/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
OBJTOP= ${.OBJDIR:H:H:H:H:H}
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen/dso
diff --git a/lib/libthread_db/Makefile b/lib/libthread_db/Makefile
index b612f4f..dfd4516 100644
--- a/lib/libthread_db/Makefile
+++ b/lib/libthread_db/Makefile
@@ -2,6 +2,7 @@
.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}
+PACKAGE=lib${LIB}
LIB= thread_db
SHLIB_MAJOR= 3
SRCS= thread_db.c
diff --git a/lib/libucl/Makefile b/lib/libucl/Makefile
index 09a0bf2..802048f 100644
--- a/lib/libucl/Makefile
+++ b/lib/libucl/Makefile
@@ -2,6 +2,7 @@
LIBUCL= ${.CURDIR}/../../contrib/libucl
+PACKAGE=lib${LIB}
LIB= ucl
PRIVATELIB= true
SHLIB_MAJOR= 1
diff --git a/lib/libufs/Makefile b/lib/libufs/Makefile
index 24efd0c..86fa4c9 100644
--- a/lib/libufs/Makefile
+++ b/lib/libufs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= ufs
SHLIBDIR?= /lib
SHLIB_MAJOR= 6
diff --git a/lib/libugidfw/Makefile b/lib/libugidfw/Makefile
index f11200d..2df6a24 100644
--- a/lib/libugidfw/Makefile
+++ b/lib/libugidfw/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= ugidfw
SHLIB_MAJOR= 5
SRCS= ugidfw.c
diff --git a/lib/libulog/Makefile b/lib/libulog/Makefile
index fedd114..434f3f6 100644
--- a/lib/libulog/Makefile
+++ b/lib/libulog/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
SHLIBDIR?=/lib
.include <src.opts.mk>
diff --git a/lib/libunbound/Makefile b/lib/libunbound/Makefile
index e348c66..f168244 100644
--- a/lib/libunbound/Makefile
+++ b/lib/libunbound/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
# Vendor sources and generated files
LDNSDIR= ${.CURDIR}/../../contrib/ldns
UNBOUNDDIR= ${.CURDIR}/../../contrib/unbound
@@ -9,6 +10,7 @@ UNBOUNDDIR= ${.CURDIR}/../../contrib/unbound
LIB= unbound
PRIVATELIB=
+PACKAGE= unbound
CFLAGS= -I${UNBOUNDDIR} -I${LDNSDIR} -I${.OBJDIR}
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index be55aa6..fe54d2a 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -4,6 +4,7 @@
# Makefile for the FreeBSD specific LibUSB 2.0
#
+PACKAGE=lib${LIB}
LIB= usb
SHLIB_MAJOR= 3
SHLIB_MINOR= 0
diff --git a/lib/libusbhid/Makefile b/lib/libusbhid/Makefile
index 7dba7ff..6efe9cc 100644
--- a/lib/libusbhid/Makefile
+++ b/lib/libusbhid/Makefile
@@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.5 1999/07/23 09:44:38 mrg Exp $
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= usbhid
MAN= usbhid.3
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 35d146a..07412e0 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$
+PACKAGE=lib${LIB}
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libutil/tests/Makefile b/lib/libutil/tests/Makefile
index 81b2a49..2f46850 100644
--- a/lib/libutil/tests/Makefile
+++ b/lib/libutil/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_C+= flopen_test
TAP_TESTS_C+= grp_test
TAP_TESTS_C+= humanize_number_test
diff --git a/lib/libvgl/Makefile b/lib/libvgl/Makefile
index dfc4e81..5505d37 100644
--- a/lib/libvgl/Makefile
+++ b/lib/libvgl/Makefile
@@ -1,4 +1,5 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= vgl
SHLIB_MAJOR= 6
CFLAGS+=-Wall -I${.CURDIR}
diff --git a/lib/libvmmapi/Makefile b/lib/libvmmapi/Makefile
index 26cf86f..bf17566 100644
--- a/lib/libvmmapi/Makefile
+++ b/lib/libvmmapi/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= vmmapi
SRCS= vmmapi.c vmmapi_freebsd.c
INCS= vmmapi.h
diff --git a/lib/libwrap/Makefile b/lib/libwrap/Makefile
index 0acb0c4..b2253d8 100644
--- a/lib/libwrap/Makefile
+++ b/lib/libwrap/Makefile
@@ -4,6 +4,7 @@
.include <src.opts.mk>
+PACKAGE=lib${LIB}
LIB= wrap
SHLIB_MAJOR= 6
INCS= tcpd.h
diff --git a/lib/libxo/Makefile b/lib/libxo/Makefile
index f8453f4..2f3f167 100644
--- a/lib/libxo/Makefile
+++ b/lib/libxo/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libxo/tests/Makefile b/lib/libxo/tests/Makefile
index 1a0f7c6..43f2e9d 100644
--- a/lib/libxo/tests/Makefile
+++ b/lib/libxo/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
LIBXOSRC= ${SRCTOP}/contrib/libxo
# Override the default suffix transformation rules for .c/.o -> .out
diff --git a/lib/libxo/tests/encoder/Makefile b/lib/libxo/tests/encoder/Makefile
index 2fe4245..491af0c 100644
--- a/lib/libxo/tests/encoder/Makefile
+++ b/lib/libxo/tests/encoder/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
LIBXOSRC= ${SRCTOP}/contrib/libxo
.PATH: ${LIBXOSRC}/encoder/test
diff --git a/lib/liby/Makefile b/lib/liby/Makefile
index 3493945..2f357f3 100644
--- a/lib/liby/Makefile
+++ b/lib/liby/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= y
SRCS= main.c yyerror.c
NO_PIC=
diff --git a/lib/libypclnt/Makefile b/lib/libypclnt/Makefile
index 2e302f1..113a3cc 100644
--- a/lib/libypclnt/Makefile
+++ b/lib/libypclnt/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=lib${LIB}
LIB= ypclnt
SHLIB_MAJOR= 4
SRCS= ypclnt_connect.c \
diff --git a/lib/libz/Makefile b/lib/libz/Makefile
index 7a80fcb..6a372bb 100644
--- a/lib/libz/Makefile
+++ b/lib/libz/Makefile
@@ -2,6 +2,7 @@
# $FreeBSD$
#
+PACKAGE=lib${LIB}
LIB= z
SHLIBDIR?= /lib
SHLIB_MAJOR= 6
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index e731a98..820855c 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -12,6 +12,7 @@
#
#
+PACKAGE= clibs
.if ${MACHINE_CPUARCH} == "i386"
ARCH_SUBDIR= i387
.else
diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
index 8b114fd..92ebc0b 100644
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE=tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libm
# All architectures on FreeBSD have fenv.h
diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile
index 94fb03a..cf9053c 100644
--- a/lib/ncurses/ncurses/Makefile
+++ b/lib/ncurses/ncurses/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= clibs
SHLIBDIR?= /lib
.if !defined(ENABLE_WIDEC)
diff --git a/lib/tests/Makefile b/lib/tests/Makefile
index a0e63e5..609357e 100644
--- a/lib/tests/Makefile
+++ b/lib/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/libexec/atf/atf-check/tests/Makefile b/libexec/atf/atf-check/tests/Makefile
index 87b26cb..d17f8b4 100644
--- a/libexec/atf/atf-check/tests/Makefile
+++ b/libexec/atf/atf-check/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.init.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF= ${SRCTOP}/contrib/atf
.PATH: ${ATF}/atf-sh
diff --git a/libexec/atf/atf-sh/tests/Makefile b/libexec/atf/atf-sh/tests/Makefile
index 9ccd6a7..db2200b 100644
--- a/libexec/atf/atf-sh/tests/Makefile
+++ b/libexec/atf/atf-sh/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.init.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
ATF= ${SRCTOP}/contrib/atf
.PATH: ${ATF}/atf-sh
diff --git a/libexec/atf/tests/Makefile b/libexec/atf/tests/Makefile
index a0e63e5..609357e 100644
--- a/libexec/atf/tests/Makefile
+++ b/libexec/atf/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/libexec/atrun/Makefile b/libexec/atrun/Makefile
index 39952fc..b11e2e9 100644
--- a/libexec/atrun/Makefile
+++ b/libexec/atrun/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=at
MAINSRC=${.CURDIR}/../../usr.bin/at
.include "${MAINSRC}/Makefile.inc"
diff --git a/libexec/casper/Makefile b/libexec/casper/Makefile
new file mode 100644
index 0000000..c66edd6
--- /dev/null
+++ b/libexec/casper/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+PACKAGE=casper
+SUBDIR= dns
+SUBDIR+=grp
+SUBDIR+=pwd
+SUBDIR+=random
+SUBDIR+=sysctl
+
+.include <bsd.subdir.mk>
diff --git a/libexec/casper/dns/Makefile b/libexec/casper/dns/Makefile
new file mode 100644
index 0000000..065977f
--- /dev/null
+++ b/libexec/casper/dns/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PACKAGE=casper
+PROG= dns
+
+SRCS= dns.c
+
+LIBADD= casper nv
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/dns/Makefile.depend b/libexec/casper/dns/Makefile.depend
new file mode 100644
index 0000000..aa79c09
--- /dev/null
+++ b/libexec/casper/dns/Makefile.depend
@@ -0,0 +1,23 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcapsicum \
+ lib/libcasper \
+ lib/libcompiler_rt \
+ lib/libnv \
+ lib/libpjdlog \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/casper/dns/dns.c b/libexec/casper/dns/dns.c
new file mode 100644
index 0000000..dbdb2a2
--- /dev/null
+++ b/libexec/casper/dns/dns.c
@@ -0,0 +1,436 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+#include <netinet/in.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcapsicum_dns.h>
+#include <libcasper.h>
+#include <pjdlog.h>
+
+static bool
+dns_allowed_type(const nvlist_t *limits, const char *type)
+{
+ const char *name;
+ bool notypes;
+ void *cookie;
+
+ if (limits == NULL)
+ return (true);
+
+ notypes = true;
+ cookie = NULL;
+ while ((name = nvlist_next(limits, NULL, &cookie)) != NULL) {
+ if (strncmp(name, "type", sizeof("type") - 1) != 0)
+ continue;
+ notypes = false;
+ if (strcmp(nvlist_get_string(limits, name), type) == 0)
+ return (true);
+ }
+
+ /* If there are no types at all, allow any type. */
+ if (notypes)
+ return (true);
+
+ return (false);
+}
+
+static bool
+dns_allowed_family(const nvlist_t *limits, int family)
+{
+ const char *name;
+ bool nofamilies;
+ void *cookie;
+
+ if (limits == NULL)
+ return (true);
+
+ nofamilies = true;
+ cookie = NULL;
+ while ((name = nvlist_next(limits, NULL, &cookie)) != NULL) {
+ if (strncmp(name, "family", sizeof("family") - 1) != 0)
+ continue;
+ nofamilies = false;
+ if (family == AF_UNSPEC)
+ continue;
+ if (nvlist_get_number(limits, name) == (uint64_t)family)
+ return (true);
+ }
+
+ /* If there are no families at all, allow any family. */
+ if (nofamilies)
+ return (true);
+
+ return (false);
+}
+
+static void
+hostent_pack(const struct hostent *hp, nvlist_t *nvl)
+{
+ unsigned int ii;
+ char nvlname[64];
+ int n;
+
+ nvlist_add_string(nvl, "name", hp->h_name);
+ nvlist_add_number(nvl, "addrtype", (uint64_t)hp->h_addrtype);
+ nvlist_add_number(nvl, "length", (uint64_t)hp->h_length);
+
+ if (hp->h_aliases == NULL) {
+ nvlist_add_number(nvl, "naliases", 0);
+ } else {
+ for (ii = 0; hp->h_aliases[ii] != NULL; ii++) {
+ n = snprintf(nvlname, sizeof(nvlname), "alias%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(nvl, nvlname, hp->h_aliases[ii]);
+ }
+ nvlist_add_number(nvl, "naliases", (uint64_t)ii);
+ }
+
+ if (hp->h_addr_list == NULL) {
+ nvlist_add_number(nvl, "naddrs", 0);
+ } else {
+ for (ii = 0; hp->h_addr_list[ii] != NULL; ii++) {
+ n = snprintf(nvlname, sizeof(nvlname), "addr%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_binary(nvl, nvlname, hp->h_addr_list[ii],
+ (size_t)hp->h_length);
+ }
+ nvlist_add_number(nvl, "naddrs", (uint64_t)ii);
+ }
+}
+
+static int
+dns_gethostbyname(const nvlist_t *limits, const nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ struct hostent *hp;
+ int family;
+
+ if (!dns_allowed_type(limits, "NAME"))
+ return (NO_RECOVERY);
+
+ family = (int)nvlist_get_number(nvlin, "family");
+
+ if (!dns_allowed_family(limits, family))
+ return (NO_RECOVERY);
+
+ hp = gethostbyname2(nvlist_get_string(nvlin, "name"), family);
+ if (hp == NULL)
+ return (h_errno);
+ hostent_pack(hp, nvlout);
+ return (0);
+}
+
+static int
+dns_gethostbyaddr(const nvlist_t *limits, const nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ struct hostent *hp;
+ const void *addr;
+ size_t addrsize;
+ int family;
+
+ if (!dns_allowed_type(limits, "ADDR"))
+ return (NO_RECOVERY);
+
+ family = (int)nvlist_get_number(nvlin, "family");
+
+ if (!dns_allowed_family(limits, family))
+ return (NO_RECOVERY);
+
+ addr = nvlist_get_binary(nvlin, "addr", &addrsize);
+ hp = gethostbyaddr(addr, (socklen_t)addrsize, family);
+ if (hp == NULL)
+ return (h_errno);
+ hostent_pack(hp, nvlout);
+ return (0);
+}
+
+static int
+dns_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct sockaddr_storage sast;
+ const void *sabin;
+ char *host, *serv;
+ size_t sabinsize, hostlen, servlen;
+ socklen_t salen;
+ int error, flags;
+
+ if (!dns_allowed_type(limits, "NAME"))
+ return (NO_RECOVERY);
+
+ error = 0;
+ host = serv = NULL;
+ memset(&sast, 0, sizeof(sast));
+
+ hostlen = (size_t)nvlist_get_number(nvlin, "hostlen");
+ servlen = (size_t)nvlist_get_number(nvlin, "servlen");
+
+ if (hostlen > 0) {
+ host = calloc(1, hostlen + 1);
+ if (host == NULL) {
+ error = EAI_MEMORY;
+ goto out;
+ }
+ }
+ if (servlen > 0) {
+ serv = calloc(1, servlen + 1);
+ if (serv == NULL) {
+ error = EAI_MEMORY;
+ goto out;
+ }
+ }
+
+ sabin = nvlist_get_binary(nvlin, "sa", &sabinsize);
+ if (sabinsize > sizeof(sast)) {
+ error = EAI_FAIL;
+ goto out;
+ }
+
+ memcpy(&sast, sabin, sabinsize);
+ salen = (socklen_t)sabinsize;
+
+ if ((sast.ss_family != AF_INET ||
+ salen != sizeof(struct sockaddr_in)) &&
+ (sast.ss_family != AF_INET6 ||
+ salen != sizeof(struct sockaddr_in6))) {
+ error = EAI_FAIL;
+ goto out;
+ }
+
+ if (!dns_allowed_family(limits, (int)sast.ss_family)) {
+ error = NO_RECOVERY;
+ goto out;
+ }
+
+ flags = (int)nvlist_get_number(nvlin, "flags");
+
+ error = getnameinfo((struct sockaddr *)&sast, salen, host, hostlen,
+ serv, servlen, flags);
+ if (error != 0)
+ goto out;
+
+ nvlist_move_string(nvlout, "host", host);
+ nvlist_move_string(nvlout, "serv", serv);
+out:
+ if (error != 0) {
+ free(host);
+ free(serv);
+ }
+ return (error);
+}
+
+static nvlist_t *
+addrinfo_pack(const struct addrinfo *ai)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_number(nvl, "ai_flags", (uint64_t)ai->ai_flags);
+ nvlist_add_number(nvl, "ai_family", (uint64_t)ai->ai_family);
+ nvlist_add_number(nvl, "ai_socktype", (uint64_t)ai->ai_socktype);
+ nvlist_add_number(nvl, "ai_protocol", (uint64_t)ai->ai_protocol);
+ nvlist_add_binary(nvl, "ai_addr", ai->ai_addr, (size_t)ai->ai_addrlen);
+ nvlist_add_string(nvl, "ai_canonname", ai->ai_canonname);
+
+ return (nvl);
+}
+
+static int
+dns_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct addrinfo hints, *hintsp, *res, *cur;
+ const char *hostname, *servname;
+ char nvlname[64];
+ nvlist_t *elem;
+ unsigned int ii;
+ int error, family, n;
+
+ if (!dns_allowed_type(limits, "ADDR"))
+ return (NO_RECOVERY);
+
+ hostname = nvlist_get_string(nvlin, "hostname");
+ servname = nvlist_get_string(nvlin, "servname");
+ if (nvlist_exists_number(nvlin, "hints.ai_flags")) {
+ size_t addrlen;
+
+ hints.ai_flags = (int)nvlist_get_number(nvlin,
+ "hints.ai_flags");
+ hints.ai_family = (int)nvlist_get_number(nvlin,
+ "hints.ai_family");
+ hints.ai_socktype = (int)nvlist_get_number(nvlin,
+ "hints.ai_socktype");
+ hints.ai_protocol = (int)nvlist_get_number(nvlin,
+ "hints.ai_protocol");
+ hints.ai_addrlen = 0;
+ hints.ai_addr = NULL;
+ hints.ai_canonname = NULL;
+ hintsp = &hints;
+ family = hints.ai_family;
+ } else {
+ hintsp = NULL;
+ family = AF_UNSPEC;
+ }
+
+ if (!dns_allowed_family(limits, family))
+ return (NO_RECOVERY);
+
+ error = getaddrinfo(hostname, servname, hintsp, &res);
+ if (error != 0)
+ goto out;
+
+ for (cur = res, ii = 0; cur != NULL; cur = cur->ai_next, ii++) {
+ elem = addrinfo_pack(cur);
+ n = snprintf(nvlname, sizeof(nvlname), "res%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_move_nvlist(nvlout, nvlname, elem);
+ }
+
+ freeaddrinfo(res);
+ error = 0;
+out:
+ return (error);
+}
+
+static bool
+limit_has_entry(const nvlist_t *limits, const char *prefix)
+{
+ const char *name;
+ size_t prefixlen;
+ void *cookie;
+
+ if (limits == NULL)
+ return (false);
+
+ prefixlen = strlen(prefix);
+
+ cookie = NULL;
+ while ((name = nvlist_next(limits, NULL, &cookie)) != NULL) {
+ if (strncmp(name, prefix, prefixlen) == 0)
+ return (true);
+ }
+
+ return (false);
+}
+
+static int
+dns_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int nvtype;
+ bool hastype, hasfamily;
+
+ hastype = false;
+ hasfamily = false;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &nvtype, &cookie)) != NULL) {
+ if (nvtype == NV_TYPE_STRING) {
+ const char *type;
+
+ if (strncmp(name, "type", sizeof("type") - 1) != 0)
+ return (EINVAL);
+ type = nvlist_get_string(newlimits, name);
+ if (strcmp(type, "ADDR") != 0 &&
+ strcmp(type, "NAME") != 0) {
+ return (EINVAL);
+ }
+ if (!dns_allowed_type(oldlimits, type))
+ return (ENOTCAPABLE);
+ hastype = true;
+ } else if (nvtype == NV_TYPE_NUMBER) {
+ int family;
+
+ if (strncmp(name, "family", sizeof("family") - 1) != 0)
+ return (EINVAL);
+ family = (int)nvlist_get_number(newlimits, name);
+ if (!dns_allowed_family(oldlimits, family))
+ return (ENOTCAPABLE);
+ hasfamily = true;
+ } else {
+ return (EINVAL);
+ }
+ }
+
+ /*
+ * If the new limit doesn't mention type or family we have to
+ * check if the current limit does have those. Missing type or
+ * family in the limit means that all types or families are
+ * allowed.
+ */
+ if (!hastype) {
+ if (limit_has_entry(oldlimits, "type"))
+ return (ENOTCAPABLE);
+ }
+ if (!hasfamily) {
+ if (limit_has_entry(oldlimits, "family"))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static int
+dns_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ int error;
+
+ if (strcmp(cmd, "gethostbyname") == 0)
+ error = dns_gethostbyname(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "gethostbyaddr") == 0)
+ error = dns_gethostbyaddr(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getnameinfo") == 0)
+ error = dns_getnameinfo(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getaddrinfo") == 0)
+ error = dns_getaddrinfo(limits, nvlin, nvlout);
+ else
+ error = NO_RECOVERY;
+
+ return (error);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.dns", PARENT_FILENO, dns_limit,
+ dns_command, argc, argv));
+}
diff --git a/libexec/casper/grp/Makefile b/libexec/casper/grp/Makefile
new file mode 100644
index 0000000..454212e
--- /dev/null
+++ b/libexec/casper/grp/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PACKAGE=casper
+PROG= grp
+
+SRCS= grp.c
+
+LIBADD= casper nv pjdlog
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/grp/Makefile.depend b/libexec/casper/grp/Makefile.depend
new file mode 100644
index 0000000..aa79c09
--- /dev/null
+++ b/libexec/casper/grp/Makefile.depend
@@ -0,0 +1,23 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcapsicum \
+ lib/libcasper \
+ lib/libcompiler_rt \
+ lib/libnv \
+ lib/libpjdlog \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/casper/grp/grp.c b/libexec/casper/grp/grp.c
new file mode 100644
index 0000000..5b3e13d
--- /dev/null
+++ b/libexec/casper/grp/grp.c
@@ -0,0 +1,390 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <grp.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcasper.h>
+#include <pjdlog.h>
+
+static bool
+grp_allowed_cmd(const nvlist_t *limits, const char *cmd)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed commands, then all commands
+ * are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "cmds"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "cmds");
+ return (nvlist_exists_null(limits, cmd));
+}
+
+static int
+grp_allowed_cmds(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!grp_allowed_cmd(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+grp_allowed_group(const nvlist_t *limits, const char *gname, gid_t gid)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed groups, then all groups are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "groups"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "groups");
+ cookie = NULL;
+ while ((name = nvlist_next(limits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ if (gid != (gid_t)-1 &&
+ nvlist_get_number(limits, name) == (uint64_t)gid) {
+ return (true);
+ }
+ break;
+ case NV_TYPE_STRING:
+ if (gname != NULL &&
+ strcmp(nvlist_get_string(limits, name),
+ gname) == 0) {
+ return (true);
+ }
+ break;
+ default:
+ PJDLOG_ABORT("Unexpected type %d.", type);
+ }
+ }
+
+ return (false);
+}
+
+static int
+grp_allowed_groups(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name, *gname;
+ void *cookie;
+ gid_t gid;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ gid = (gid_t)nvlist_get_number(newlimits, name);
+ gname = NULL;
+ break;
+ case NV_TYPE_STRING:
+ gid = (gid_t)-1;
+ gname = nvlist_get_string(newlimits, name);
+ break;
+ default:
+ return (EINVAL);
+ }
+ if (!grp_allowed_group(oldlimits, gname, gid))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+grp_allowed_field(const nvlist_t *limits, const char *field)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed fields, then all fields are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "fields"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "fields");
+ return (nvlist_exists_null(limits, field));
+}
+
+static int
+grp_allowed_fields(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!grp_allowed_field(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+grp_pack(const nvlist_t *limits, const struct group *grp, nvlist_t *nvl)
+{
+ char nvlname[64];
+ int n;
+
+ if (grp == NULL)
+ return (true);
+
+ /*
+ * If either name or GID is allowed, we allow it.
+ */
+ if (!grp_allowed_group(limits, grp->gr_name, grp->gr_gid))
+ return (false);
+
+ if (grp_allowed_field(limits, "gr_name"))
+ nvlist_add_string(nvl, "gr_name", grp->gr_name);
+ else
+ nvlist_add_string(nvl, "gr_name", "");
+ if (grp_allowed_field(limits, "gr_passwd"))
+ nvlist_add_string(nvl, "gr_passwd", grp->gr_passwd);
+ else
+ nvlist_add_string(nvl, "gr_passwd", "");
+ if (grp_allowed_field(limits, "gr_gid"))
+ nvlist_add_number(nvl, "gr_gid", (uint64_t)grp->gr_gid);
+ else
+ nvlist_add_number(nvl, "gr_gid", (uint64_t)-1);
+ if (grp_allowed_field(limits, "gr_mem") && grp->gr_mem[0] != NULL) {
+ unsigned int ngroups;
+
+ for (ngroups = 0; grp->gr_mem[ngroups] != NULL; ngroups++) {
+ n = snprintf(nvlname, sizeof(nvlname), "gr_mem[%u]",
+ ngroups);
+ assert(n > 0 && n < sizeof(nvlname));
+ nvlist_add_string(nvl, nvlname, grp->gr_mem[ngroups]);
+ }
+ nvlist_add_number(nvl, "gr_nmem", (uint64_t)ngroups);
+ }
+
+ return (true);
+}
+
+static int
+grp_getgrent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct group *grp;
+
+ for (;;) {
+ errno = 0;
+ grp = getgrent();
+ if (errno != 0)
+ return (errno);
+ if (grp_pack(limits, grp, nvlout))
+ return (0);
+ }
+
+ /* NOTREACHED */
+}
+
+static int
+grp_getgrnam(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct group *grp;
+ const char *name;
+
+ if (!nvlist_exists_string(nvlin, "name"))
+ return (EINVAL);
+ name = nvlist_get_string(nvlin, "name");
+ PJDLOG_ASSERT(name != NULL);
+
+ errno = 0;
+ grp = getgrnam(name);
+ if (errno != 0)
+ return (errno);
+
+ (void)grp_pack(limits, grp, nvlout);
+
+ return (0);
+}
+
+static int
+grp_getgrgid(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct group *grp;
+ gid_t gid;
+
+ if (!nvlist_exists_number(nvlin, "gid"))
+ return (EINVAL);
+
+ gid = (gid_t)nvlist_get_number(nvlin, "gid");
+
+ errno = 0;
+ grp = getgrgid(gid);
+ if (errno != 0)
+ return (errno);
+
+ (void)grp_pack(limits, grp, nvlout);
+
+ return (0);
+}
+
+static int
+grp_setgroupent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ int stayopen;
+
+ if (!nvlist_exists_bool(nvlin, "stayopen"))
+ return (EINVAL);
+
+ stayopen = nvlist_get_bool(nvlin, "stayopen") ? 1 : 0;
+
+ return (setgroupent(stayopen) == 0 ? EFAULT : 0);
+}
+
+static int
+grp_setgrent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ return (setgrent() == 0 ? EFAULT : 0);
+}
+
+static int
+grp_endgrent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ endgrent();
+
+ return (0);
+}
+
+static int
+grp_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const nvlist_t *limits;
+ const char *name;
+ void *cookie;
+ int error, type;
+
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "cmds") &&
+ !nvlist_exists_nvlist(newlimits, "cmds")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "fields") &&
+ !nvlist_exists_nvlist(newlimits, "fields")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "groups") &&
+ !nvlist_exists_nvlist(newlimits, "groups")) {
+ return (ENOTCAPABLE);
+ }
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NVLIST)
+ return (EINVAL);
+ limits = nvlist_get_nvlist(newlimits, name);
+ if (strcmp(name, "cmds") == 0)
+ error = grp_allowed_cmds(oldlimits, limits);
+ else if (strcmp(name, "fields") == 0)
+ error = grp_allowed_fields(oldlimits, limits);
+ else if (strcmp(name, "groups") == 0)
+ error = grp_allowed_groups(oldlimits, limits);
+ else
+ error = EINVAL;
+ if (error != 0)
+ return (error);
+ }
+
+ return (0);
+}
+
+static int
+grp_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ int error;
+
+ if (!grp_allowed_cmd(limits, cmd))
+ return (ENOTCAPABLE);
+
+ if (strcmp(cmd, "getgrent") == 0 || strcmp(cmd, "getgrent_r") == 0)
+ error = grp_getgrent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getgrnam") == 0 || strcmp(cmd, "getgrnam_r") == 0)
+ error = grp_getgrnam(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getgrgid") == 0 || strcmp(cmd, "getgrgid_r") == 0)
+ error = grp_getgrgid(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setgroupent") == 0)
+ error = grp_setgroupent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setgrent") == 0)
+ error = grp_setgrent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "endgrent") == 0)
+ error = grp_endgrent(limits, nvlin, nvlout);
+ else
+ error = EINVAL;
+
+ return (error);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.grp", PARENT_FILENO, grp_limit,
+ grp_command, argc, argv));
+}
diff --git a/libexec/casper/pwd/Makefile b/libexec/casper/pwd/Makefile
new file mode 100644
index 0000000..91dd609
--- /dev/null
+++ b/libexec/casper/pwd/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PACKAGE=casper
+PROG= pwd
+
+SRCS= pwd.c
+
+LIBADD= casper nv pjdlog
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/pwd/Makefile.depend b/libexec/casper/pwd/Makefile.depend
new file mode 100644
index 0000000..aa79c09
--- /dev/null
+++ b/libexec/casper/pwd/Makefile.depend
@@ -0,0 +1,23 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcapsicum \
+ lib/libcasper \
+ lib/libcompiler_rt \
+ lib/libnv \
+ lib/libpjdlog \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/casper/pwd/pwd.c b/libexec/casper/pwd/pwd.c
new file mode 100644
index 0000000..0a06c5f
--- /dev/null
+++ b/libexec/casper/pwd/pwd.c
@@ -0,0 +1,430 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+
+#include <errno.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcasper.h>
+#include <pjdlog.h>
+
+static bool
+pwd_allowed_cmd(const nvlist_t *limits, const char *cmd)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed commands, then all commands
+ * are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "cmds"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "cmds");
+ return (nvlist_exists_null(limits, cmd));
+}
+
+static int
+pwd_allowed_cmds(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!pwd_allowed_cmd(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+pwd_allowed_user(const nvlist_t *limits, const char *uname, uid_t uid)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed users, then all users are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "users"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "users");
+ cookie = NULL;
+ while ((name = nvlist_next(limits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ if (uid != (uid_t)-1 &&
+ nvlist_get_number(limits, name) == (uint64_t)uid) {
+ return (true);
+ }
+ break;
+ case NV_TYPE_STRING:
+ if (uname != NULL &&
+ strcmp(nvlist_get_string(limits, name),
+ uname) == 0) {
+ return (true);
+ }
+ break;
+ default:
+ PJDLOG_ABORT("Unexpected type %d.", type);
+ }
+ }
+
+ return (false);
+}
+
+static int
+pwd_allowed_users(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name, *uname;
+ void *cookie;
+ uid_t uid;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ uid = (uid_t)nvlist_get_number(newlimits, name);
+ uname = NULL;
+ break;
+ case NV_TYPE_STRING:
+ uid = (uid_t)-1;
+ uname = nvlist_get_string(newlimits, name);
+ break;
+ default:
+ return (EINVAL);
+ }
+ if (!pwd_allowed_user(oldlimits, uname, uid))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+pwd_allowed_field(const nvlist_t *limits, const char *field)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed fields, then all fields are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "fields"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "fields");
+ return (nvlist_exists_null(limits, field));
+}
+
+static int
+pwd_allowed_fields(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!pwd_allowed_field(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+pwd_pack(const nvlist_t *limits, const struct passwd *pwd, nvlist_t *nvl)
+{
+ int fields;
+
+ if (pwd == NULL)
+ return (true);
+
+ /*
+ * If either name or UID is allowed, we allow it.
+ */
+ if (!pwd_allowed_user(limits, pwd->pw_name, pwd->pw_uid))
+ return (false);
+
+ fields = pwd->pw_fields;
+
+ if (pwd_allowed_field(limits, "pw_name")) {
+ nvlist_add_string(nvl, "pw_name", pwd->pw_name);
+ } else {
+ nvlist_add_string(nvl, "pw_name", "");
+ fields &= ~_PWF_NAME;
+ }
+ if (pwd_allowed_field(limits, "pw_uid")) {
+ nvlist_add_number(nvl, "pw_uid", (uint64_t)pwd->pw_uid);
+ } else {
+ nvlist_add_number(nvl, "pw_uid", (uint64_t)-1);
+ fields &= ~_PWF_UID;
+ }
+ if (pwd_allowed_field(limits, "pw_gid")) {
+ nvlist_add_number(nvl, "pw_gid", (uint64_t)pwd->pw_gid);
+ } else {
+ nvlist_add_number(nvl, "pw_gid", (uint64_t)-1);
+ fields &= ~_PWF_GID;
+ }
+ if (pwd_allowed_field(limits, "pw_change")) {
+ nvlist_add_number(nvl, "pw_change", (uint64_t)pwd->pw_change);
+ } else {
+ nvlist_add_number(nvl, "pw_change", (uint64_t)0);
+ fields &= ~_PWF_CHANGE;
+ }
+ if (pwd_allowed_field(limits, "pw_passwd")) {
+ nvlist_add_string(nvl, "pw_passwd", pwd->pw_passwd);
+ } else {
+ nvlist_add_string(nvl, "pw_passwd", "");
+ fields &= ~_PWF_PASSWD;
+ }
+ if (pwd_allowed_field(limits, "pw_class")) {
+ nvlist_add_string(nvl, "pw_class", pwd->pw_class);
+ } else {
+ nvlist_add_string(nvl, "pw_class", "");
+ fields &= ~_PWF_CLASS;
+ }
+ if (pwd_allowed_field(limits, "pw_gecos")) {
+ nvlist_add_string(nvl, "pw_gecos", pwd->pw_gecos);
+ } else {
+ nvlist_add_string(nvl, "pw_gecos", "");
+ fields &= ~_PWF_GECOS;
+ }
+ if (pwd_allowed_field(limits, "pw_dir")) {
+ nvlist_add_string(nvl, "pw_dir", pwd->pw_dir);
+ } else {
+ nvlist_add_string(nvl, "pw_dir", "");
+ fields &= ~_PWF_DIR;
+ }
+ if (pwd_allowed_field(limits, "pw_shell")) {
+ nvlist_add_string(nvl, "pw_shell", pwd->pw_shell);
+ } else {
+ nvlist_add_string(nvl, "pw_shell", "");
+ fields &= ~_PWF_SHELL;
+ }
+ if (pwd_allowed_field(limits, "pw_expire")) {
+ nvlist_add_number(nvl, "pw_expire", (uint64_t)pwd->pw_expire);
+ } else {
+ nvlist_add_number(nvl, "pw_expire", (uint64_t)0);
+ fields &= ~_PWF_EXPIRE;
+ }
+ nvlist_add_number(nvl, "pw_fields", (uint64_t)fields);
+
+ return (true);
+}
+
+static int
+pwd_getpwent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct passwd *pwd;
+
+ for (;;) {
+ errno = 0;
+ pwd = getpwent();
+ if (errno != 0)
+ return (errno);
+ if (pwd_pack(limits, pwd, nvlout))
+ return (0);
+ }
+
+ /* NOTREACHED */
+}
+
+static int
+pwd_getpwnam(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct passwd *pwd;
+ const char *name;
+
+ if (!nvlist_exists_string(nvlin, "name"))
+ return (EINVAL);
+ name = nvlist_get_string(nvlin, "name");
+ PJDLOG_ASSERT(name != NULL);
+
+ errno = 0;
+ pwd = getpwnam(name);
+ if (errno != 0)
+ return (errno);
+
+ (void)pwd_pack(limits, pwd, nvlout);
+
+ return (0);
+}
+
+static int
+pwd_getpwuid(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct passwd *pwd;
+ uid_t uid;
+
+ if (!nvlist_exists_number(nvlin, "uid"))
+ return (EINVAL);
+
+ uid = (uid_t)nvlist_get_number(nvlin, "uid");
+
+ errno = 0;
+ pwd = getpwuid(uid);
+ if (errno != 0)
+ return (errno);
+
+ (void)pwd_pack(limits, pwd, nvlout);
+
+ return (0);
+}
+
+static int
+pwd_setpassent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ int stayopen;
+
+ if (!nvlist_exists_bool(nvlin, "stayopen"))
+ return (EINVAL);
+
+ stayopen = nvlist_get_bool(nvlin, "stayopen") ? 1 : 0;
+
+ return (setpassent(stayopen) == 0 ? EFAULT : 0);
+}
+
+static int
+pwd_setpwent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ setpwent();
+
+ return (0);
+}
+
+static int
+pwd_endpwent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ endpwent();
+
+ return (0);
+}
+
+static int
+pwd_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const nvlist_t *limits;
+ const char *name;
+ void *cookie;
+ int error, type;
+
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "cmds") &&
+ !nvlist_exists_nvlist(newlimits, "cmds")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "fields") &&
+ !nvlist_exists_nvlist(newlimits, "fields")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "users") &&
+ !nvlist_exists_nvlist(newlimits, "users")) {
+ return (ENOTCAPABLE);
+ }
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NVLIST)
+ return (EINVAL);
+ limits = nvlist_get_nvlist(newlimits, name);
+ if (strcmp(name, "cmds") == 0)
+ error = pwd_allowed_cmds(oldlimits, limits);
+ else if (strcmp(name, "fields") == 0)
+ error = pwd_allowed_fields(oldlimits, limits);
+ else if (strcmp(name, "users") == 0)
+ error = pwd_allowed_users(oldlimits, limits);
+ else
+ error = EINVAL;
+ if (error != 0)
+ return (error);
+ }
+
+ return (0);
+}
+
+static int
+pwd_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ int error;
+
+ if (!pwd_allowed_cmd(limits, cmd))
+ return (ENOTCAPABLE);
+
+ if (strcmp(cmd, "getpwent") == 0 || strcmp(cmd, "getpwent_r") == 0)
+ error = pwd_getpwent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getpwnam") == 0 || strcmp(cmd, "getpwnam_r") == 0)
+ error = pwd_getpwnam(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getpwuid") == 0 || strcmp(cmd, "getpwuid_r") == 0)
+ error = pwd_getpwuid(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setpassent") == 0)
+ error = pwd_setpassent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setpwent") == 0)
+ error = pwd_setpwent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "endpwent") == 0)
+ error = pwd_endpwent(limits, nvlin, nvlout);
+ else
+ error = EINVAL;
+
+ return (error);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.pwd", PARENT_FILENO, pwd_limit,
+ pwd_command, argc, argv));
+}
diff --git a/libexec/casper/random/Makefile b/libexec/casper/random/Makefile
new file mode 100644
index 0000000..208f299
--- /dev/null
+++ b/libexec/casper/random/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PACKAGE=casper
+PROG= random
+
+SRCS= random.c
+
+LIBADD= casper nv
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/random/Makefile.depend b/libexec/casper/random/Makefile.depend
new file mode 100644
index 0000000..aa79c09
--- /dev/null
+++ b/libexec/casper/random/Makefile.depend
@@ -0,0 +1,23 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcapsicum \
+ lib/libcasper \
+ lib/libcompiler_rt \
+ lib/libnv \
+ lib/libpjdlog \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/casper/random/random.c b/libexec/casper/random/random.c
new file mode 100644
index 0000000..db91685
--- /dev/null
+++ b/libexec/casper/random/random.c
@@ -0,0 +1,82 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/nv.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcasper.h>
+#include <pjdlog.h>
+
+#define MAXSIZE (1024 * 1024)
+
+static int
+random_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ void *data;
+ size_t size;
+
+ if (strcmp(cmd, "generate") != 0)
+ return (EINVAL);
+ if (!nvlist_exists_number(nvlin, "size"))
+ return (EINVAL);
+
+ size = (size_t)nvlist_get_number(nvlin, "size");
+ if (size == 0 || size > MAXSIZE)
+ return (EINVAL);
+
+ data = malloc(size);
+ if (data == NULL)
+ return (ENOMEM);
+
+ arc4random_buf(data, size);
+
+ nvlist_move_binary(nvlout, "data", data, size);
+
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ /*
+ * TODO: Sandbox this.
+ */
+
+ return (service_start("system.random", PARENT_FILENO, NULL,
+ random_command, argc, argv));
+}
diff --git a/libexec/casper/sysctl/Makefile b/libexec/casper/sysctl/Makefile
new file mode 100644
index 0000000..e9b4bf6
--- /dev/null
+++ b/libexec/casper/sysctl/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PACKAGE=casper
+PROG= sysctl
+
+SRCS= sysctl.c
+
+LIBADD= casper nv pjdlog
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/sysctl/Makefile.depend b/libexec/casper/sysctl/Makefile.depend
new file mode 100644
index 0000000..aa79c09
--- /dev/null
+++ b/libexec/casper/sysctl/Makefile.depend
@@ -0,0 +1,23 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcapsicum \
+ lib/libcasper \
+ lib/libcompiler_rt \
+ lib/libnv \
+ lib/libpjdlog \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/casper/sysctl/sysctl.c b/libexec/casper/sysctl/sysctl.c
new file mode 100644
index 0000000..4cbc505
--- /dev/null
+++ b/libexec/casper/sysctl/sysctl.c
@@ -0,0 +1,249 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/nv.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcapsicum_sysctl.h>
+#include <libcasper.h>
+#include <pjdlog.h>
+
+static int
+sysctl_check_one(const nvlist_t *nvl, bool islimit)
+{
+ const char *name;
+ void *cookie;
+ int type;
+ unsigned int fields;
+
+ /* NULL nvl is of course invalid. */
+ if (nvl == NULL)
+ return (EINVAL);
+ if (nvlist_error(nvl) != 0)
+ return (nvlist_error(nvl));
+
+#define HAS_NAME 0x01
+#define HAS_OPERATION 0x02
+
+ fields = 0;
+ cookie = NULL;
+ while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) {
+ /* We accept only one 'name' and one 'operation' in nvl. */
+ if (strcmp(name, "name") == 0) {
+ if (type != NV_TYPE_STRING)
+ return (EINVAL);
+ /* Only one 'name' can be present. */
+ if ((fields & HAS_NAME) != 0)
+ return (EINVAL);
+ fields |= HAS_NAME;
+ } else if (strcmp(name, "operation") == 0) {
+ uint64_t operation;
+
+ if (type != NV_TYPE_NUMBER)
+ return (EINVAL);
+ /*
+ * We accept only CAP_SYSCTL_READ and
+ * CAP_SYSCTL_WRITE flags.
+ */
+ operation = nvlist_get_number(nvl, name);
+ if ((operation & ~(CAP_SYSCTL_RDWR)) != 0)
+ return (EINVAL);
+ /* ...but there has to be at least one of them. */
+ if ((operation & (CAP_SYSCTL_RDWR)) == 0)
+ return (EINVAL);
+ /* Only one 'operation' can be present. */
+ if ((fields & HAS_OPERATION) != 0)
+ return (EINVAL);
+ fields |= HAS_OPERATION;
+ } else if (islimit) {
+ /* If this is limit, there can be no other fields. */
+ return (EINVAL);
+ }
+ }
+
+ /* Both fields has to be there. */
+ if (fields != (HAS_NAME | HAS_OPERATION))
+ return (EINVAL);
+
+#undef HAS_OPERATION
+#undef HAS_NAME
+
+ return (0);
+}
+
+static bool
+sysctl_allowed(const nvlist_t *limits, const char *chname, uint64_t choperation)
+{
+ uint64_t operation;
+ const char *name;
+ void *cookie;
+ int type;
+
+ if (limits == NULL)
+ return (true);
+
+ cookie = NULL;
+ while ((name = nvlist_next(limits, &type, &cookie)) != NULL) {
+ PJDLOG_ASSERT(type == NV_TYPE_NUMBER);
+
+ operation = nvlist_get_number(limits, name);
+ if ((operation & choperation) != choperation)
+ continue;
+
+ if ((operation & CAP_SYSCTL_RECURSIVE) == 0) {
+ if (strcmp(name, chname) != 0)
+ continue;
+ } else {
+ size_t namelen;
+
+ namelen = strlen(name);
+ if (strncmp(name, chname, namelen) != 0)
+ continue;
+ if (chname[namelen] != '.' && chname[namelen] != '\0')
+ continue;
+ }
+
+ return (true);
+ }
+
+ return (false);
+}
+
+static int
+sysctl_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const nvlist_t *nvl;
+ const char *name;
+ void *cookie;
+ uint64_t operation;
+ int error, type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NUMBER)
+ return (EINVAL);
+ operation = nvlist_get_number(newlimits, name);
+ if ((operation & ~(CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE)) != 0)
+ return (EINVAL);
+ if ((operation & (CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE)) == 0)
+ return (EINVAL);
+ if (!sysctl_allowed(oldlimits, name, operation))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static int
+sysctl_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ const char *name;
+ const void *newp;
+ void *oldp;
+ uint64_t operation;
+ size_t oldlen, newlen;
+ size_t *oldlenp;
+ int error;
+
+ if (strcmp(cmd, "sysctl") != 0)
+ return (EINVAL);
+ error = sysctl_check_one(nvlin, false);
+ if (error != 0)
+ return (error);
+
+ name = nvlist_get_string(nvlin, "name");
+ operation = nvlist_get_number(nvlin, "operation");
+ if (!sysctl_allowed(limits, name, operation))
+ return (ENOTCAPABLE);
+
+ if ((operation & CAP_SYSCTL_WRITE) != 0) {
+ if (!nvlist_exists_binary(nvlin, "newp"))
+ return (EINVAL);
+ newp = nvlist_get_binary(nvlin, "newp", &newlen);
+ PJDLOG_ASSERT(newp != NULL && newlen > 0);
+ } else {
+ newp = NULL;
+ newlen = 0;
+ }
+
+ if ((operation & CAP_SYSCTL_READ) != 0) {
+ if (nvlist_exists_null(nvlin, "justsize")) {
+ oldp = NULL;
+ oldlen = 0;
+ oldlenp = &oldlen;
+ } else {
+ if (!nvlist_exists_number(nvlin, "oldlen"))
+ return (EINVAL);
+ oldlen = (size_t)nvlist_get_number(nvlin, "oldlen");
+ if (oldlen == 0)
+ return (EINVAL);
+ oldp = calloc(1, oldlen);
+ if (oldp == NULL)
+ return (ENOMEM);
+ oldlenp = &oldlen;
+ }
+ } else {
+ oldp = NULL;
+ oldlen = 0;
+ oldlenp = NULL;
+ }
+
+ if (sysctlbyname(name, oldp, oldlenp, newp, newlen) == -1) {
+ error = errno;
+ free(oldp);
+ return (error);
+ }
+
+ if ((operation & CAP_SYSCTL_READ) != 0) {
+ if (nvlist_exists_null(nvlin, "justsize"))
+ nvlist_add_number(nvlout, "oldlen", (uint64_t)oldlen);
+ else
+ nvlist_move_binary(nvlout, "oldp", oldp, oldlen);
+ }
+
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.sysctl", PARENT_FILENO, sysctl_limit,
+ sysctl_command, argc, argv));
+}
diff --git a/libexec/dma/Makefile.inc b/libexec/dma/Makefile.inc
index e9a0d0a..4db4bf1 100644
--- a/libexec/dma/Makefile.inc
+++ b/libexec/dma/Makefile.inc
@@ -11,3 +11,4 @@ CFLAGS= -I${DMA_SOURCES} \
-DDMA_ROOT_USER='"mailnull"' \
-DDMA_GROUP='"mail"'
BINGRP= mail
+PACKAGE= dma
diff --git a/libexec/mail.local/Makefile b/libexec/mail.local/Makefile
index 79844e8..6b4256f 100644
--- a/libexec/mail.local/Makefile
+++ b/libexec/mail.local/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 7/19/93
# $FreeBSD$
+PACKAGE=sendmail
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
.PATH: ${SENDMAIL_DIR}/mail.local
diff --git a/libexec/rlogind/Makefile b/libexec/rlogind/Makefile
index 282ec63..b932702 100644
--- a/libexec/rlogind/Makefile
+++ b/libexec/rlogind/Makefile
@@ -3,8 +3,10 @@
.include <src.opts.mk>
+PACKAGE=rcmds
PROG= rlogind
MAN= rlogind.8
+PACKAGE=rcmds
LIBADD= util
WARNS?= 2
diff --git a/libexec/rshd/Makefile b/libexec/rshd/Makefile
index c856995..498b699 100644
--- a/libexec/rshd/Makefile
+++ b/libexec/rshd/Makefile
@@ -1,9 +1,12 @@
# From: @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$
+PACKAGE=rcmds
PROG= rshd
MAN= rshd.8
+PACKAGE=rcmds
+
WARNS?= 3
WFORMAT=0
diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index ae49e9b..e2ebcce 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -5,9 +5,13 @@
# make DEBUG_FLAGS=-g DEBUG=-DDEBUG MK_TESTS=no all
.include <src.opts.mk>
+PACKAGE= clibs
MK_SSP= no
PROG?= ld-elf.so.1
+.if (${PROG:M*ld-elf32*} != "")
+TAGS+= lib32
+.endif
SRCS= rtld_start.S \
reloc.c rtld.c rtld_lock.c rtld_printf.c map_object.c \
malloc.c xmalloc.c debug.c libmap.c
diff --git a/libexec/rtld-elf/tests/Makefile b/libexec/rtld-elf/tests/Makefile
index 3aecba0..f6ca605 100644
--- a/libexec/rtld-elf/tests/Makefile
+++ b/libexec/rtld-elf/tests/Makefile
@@ -2,6 +2,9 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
SUBDIR+= libpythagoras target
SUBDIR_DEPEND_target= libpythagoras
diff --git a/libexec/rtld-elf/tests/libpythagoras/Makefile b/libexec/rtld-elf/tests/libpythagoras/Makefile
index 9ad4b88..0e52dbd 100644
--- a/libexec/rtld-elf/tests/libpythagoras/Makefile
+++ b/libexec/rtld-elf/tests/libpythagoras/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
LIB= pythagoras
SHLIB_MAJOR= 0
diff --git a/libexec/rtld-elf/tests/target/Makefile b/libexec/rtld-elf/tests/target/Makefile
index d5305f9..7d80057 100644
--- a/libexec/rtld-elf/tests/target/Makefile
+++ b/libexec/rtld-elf/tests/target/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
PROG= target
BINDIR= ${TESTSBASE}/libexec/rtld-elf
diff --git a/libexec/smrsh/Makefile b/libexec/smrsh/Makefile
index e2e9c3b..02590ae 100644
--- a/libexec/smrsh/Makefile
+++ b/libexec/smrsh/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 7/2/95
# $FreeBSD$
+PACKAGE=sendmail
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
.PATH: ${SENDMAIL_DIR}/smrsh
diff --git a/libexec/tests/Makefile b/libexec/tests/Makefile
index a0e63e5..04afe9a 100644
--- a/libexec/tests/Makefile
+++ b/libexec/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TEST+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/release/packages/Makefile.package b/release/packages/Makefile.package
new file mode 100644
index 0000000..40faed8
--- /dev/null
+++ b/release/packages/Makefile.package
@@ -0,0 +1,73 @@
+#
+# $FreeBSD$
+#
+
+acct_COMMENT= Accounting Utilties
+acct_DESC= Accounting Utilties
+acpi_COMMENT= ACPI Utilities
+acpi_DESC= ACPI Utilities
+amd_COMMENT= AMD Utilities
+amd_DESC= AMD Utilities
+apm_COMMENT= APM Utilities
+apm_DESC= APM Utilities
+at_COMMENT= AT Utilities
+at_DESC= AT Utilities
+autofs_COMMENT= Autofs Utilities
+autofs_DESC= Autofs Utilities
+bhyve_COMMENT= Bhyve Utilities
+bhyve_DESC= Bhyve Utilities
+binutils_COMMENT= Binutils
+binutils_DESC= Binutils
+bsdinstall_COMMENT= BSDInstall Utilities
+bsdinstall_DESC= BSDInstall Utilities
+bsnmp_COMMENT= BSNMP Utilities
+bsnmp_DESC= BSNMP Utilities
+clang_COMMENT= Clang Utilities
+clang_DESC= Clang Utilities
+clibs_COMMENT= Core C Libraries
+clibs_DESC= Core C Libraries
+dma_COMMENT= DMA Mail Agent Utilities
+dma_DESC= DMA Mail Agent Utilities
+docs_COMMENT= Documentation
+docs_DESC= Documentation
+ee_COMMENT= Easy Editor Utilities
+ee_DESC= Easy Editor Utilities
+gdb_COMMENT= GDB Utilities
+gdb_DESC= GDB Utilities
+groff_COMMENT= Groff Utilities
+groff_DESC= Groff Utilities
+hast_COMMENT= Highly Available Storage daemon
+hast_DESC= Highly Available Storage daemon
+jail_COMMENT= Jail Utilities
+jail_DESC= Jail Utilities
+kernel_COMMENT= FreeBSD Kernel
+kernel_DESC= FreeBSD Kernel
+manuals_COMMENT= Manual Pages
+manuals_DESC= Manual Pages
+rcmds_COMMENT= Remote Command Utilities
+rcmds_DESC= Remote Command Utilities
+rescue_COMMENT= Rescue Utilities
+rescue_DESC= Rescue Utilities
+runtime_COMMENT= FreeBSD Base System
+runtime_DESC= FreeBSD Base System
+runtime-debug_DESCR= Debugging Symbols
+runtime-development_DESCR=Development Files
+runtime-profile_DESCR= Profiling Libraries
+runtime-lib32_DESCR= 32-bit Libraries
+runtime-lib32-debug_DESCR=32-bit Debugging Symbols
+runtime-lib32-development_DESCR=32-bit Development Files
+runtime-lib32-profile_DESCR=32-bit Profiling Libraries
+sendmail_COMMENT= Sendmail Utilities
+sendmail_DESC= Sendmail Utilities
+ssh_COMMENT= Secure Shell Utilities
+ssh_DESC= Secure Shell Utilities
+svn_COMMENT= Subversion Version Control System
+svn_DESC= Subversion Version Control System
+syscons_COMMENT= Syscons Console
+syscons_DESC= Syscons Console
+tests_COMMENT= Test Suite
+tests_DESC= Test Suite
+unbound_COMMENT= Unbound DNS Resolver
+unbound_DESC= Unbound DNS Resolver
+vi_COMMENT= Vi Editor
+vi_DESC= Vi Editor
diff --git a/release/packages/acct.ucl b/release/packages/acct.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/acct.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/acpi.ucl b/release/packages/acpi.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/acpi.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/amd.ucl b/release/packages/amd.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/amd.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/apm.ucl b/release/packages/apm.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/apm.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/at.ucl b/release/packages/at.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/at.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/autofs.ucl b/release/packages/autofs.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/autofs.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/bhyve.ucl b/release/packages/bhyve.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/bhyve.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/binutils.ucl b/release/packages/binutils.ucl
new file mode 100644
index 0000000..281d2a5
--- /dev/null
+++ b/release/packages/binutils.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ GPLv2 ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/bsdinstall.ucl b/release/packages/bsdinstall.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/bsdinstall.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/bsnmp.ucl b/release/packages/bsnmp.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/bsnmp.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/clang.ucl b/release/packages/clang.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/clang.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/clibs.ucl b/release/packages/clibs.ucl
new file mode 100644
index 0000000..38844f0
--- /dev/null
+++ b/release/packages/clibs.ucl
@@ -0,0 +1,17 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
diff --git a/release/packages/dma.ucl b/release/packages/dma.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/dma.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/docs.ucl b/release/packages/docs.ucl
new file mode 100644
index 0000000..38844f0
--- /dev/null
+++ b/release/packages/docs.ucl
@@ -0,0 +1,17 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
diff --git a/release/packages/ee.ucl b/release/packages/ee.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/ee.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/gdb.ucl b/release/packages/gdb.ucl
new file mode 100644
index 0000000..281d2a5
--- /dev/null
+++ b/release/packages/gdb.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ GPLv2 ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/generate-ucl.sh b/release/packages/generate-ucl.sh
new file mode 100755
index 0000000..9a963f0
--- /dev/null
+++ b/release/packages/generate-ucl.sh
@@ -0,0 +1,141 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+main() {
+ desc=
+ comment=
+ debug=
+ uclsource=
+ while getopts "do:s:u:" arg; do
+ case ${arg} in
+ d)
+ debug=1
+ ;;
+ o)
+ outname="${OPTARG}"
+ origname="${OPTARG}"
+ ;;
+ s)
+ srctree="${OPTARG}"
+ ;;
+ u)
+ uclfile="${OPTARG}"
+ ;;
+ *)
+ echo "Unknown argument"
+ ;;
+ esac
+ done
+
+ shift $(( ${OPTIND} - 1 ))
+
+ outname="$(echo ${outname} | tr '-' '_')"
+
+ case "${outname}" in
+ runtime)
+ outname="runtime"
+ uclfile="${uclfile}"
+ ;;
+ runtime_manuals)
+ outname="${origname}"
+ pkgdeps="runtime"
+ ;;
+ runtime_*)
+ outname="${origname}"
+ uclfile="${outname##*}${uclfile}"
+ pkgdeps="runtime"
+ _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)"
+ ;;
+ *_lib32_development)
+ outname="${outname%%_lib32_development}"
+ _descr="32-bit Libraries, Development Files"
+ pkgdeps="${outname}"
+ ;;
+ *_lib32_debug)
+ outname="${outname%%_lib32_debug}"
+ _descr="32-bit Libraries, Debugging Symbols"
+ pkgdeps="${outname}"
+ ;;
+ *_lib32_profile)
+ outname="${outname%%_lib32_profile}"
+ _descr="32-bit Libraries, Profiling"
+ pkgdeps="${outname}"
+ ;;
+ *_lib32)
+ outname="${outname%%_lib32}"
+ _descr="32-bit Libraries"
+ pkgdeps="${outname}"
+ ;;
+ *_development)
+ outname="${outname%%_development}"
+ _descr="Development Files"
+ pkgdeps="${outname}"
+ ;;
+ *_profile)
+ outname="${outname%%_profile}"
+ _descr="Profiling Libraries"
+ pkgdeps="${outname}"
+ ;;
+ *_debug)
+ outname="${outname%%_debug}"
+ _descr="Debugging Symbols"
+ pkgdeps="${outname}"
+ ;;
+ ${origname})
+ pkgdeps="runtime"
+ ;;
+ *)
+ uclfile="${outname##*}${origname}"
+ outname="${outname##*}${origname}"
+ ;;
+ esac
+
+ outname="${outname%%_*}"
+
+ desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)"
+ comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)"
+
+ uclsource="${srctree}/release/packages/${outname}.ucl"
+ if [ ! -e "${uclsource}" ]; then
+ uclsource="${srctree}/release/packages/template.ucl"
+ fi
+
+ if [ ! -z "${debug}" ]; then
+ echo ""
+ echo "==============================================================="
+ echo "DEBUG:"
+ echo "_descr=${_descr}"
+ echo "outname=${outname}"
+ echo "origname=${origname}"
+ echo "srctree=${srctree}"
+ echo "uclfile=${uclfile}"
+ echo "desc=${desc}"
+ echo "comment=${comment}"
+ echo "cp ${uclsource} -> ${uclfile}"
+ echo "==============================================================="
+ echo ""
+ echo ""
+ echo ""
+ fi
+
+ [ -z "${comment}" ] && comment="${outname} package"
+ [ ! -z "${_descr}" ] && comment="${comment} (${_descr})"
+ [ -z "${desc}" ] && desc="${outname} package"
+
+ cp "${uclsource}" "${uclfile}"
+ cap_arg="$(make -C ${srctree}/etc -VCAP_MKDB_ENDIAN)"
+ pwd_arg="$(make -C ${srctree}/etc -VPWD_MKDB_ENDIAN)"
+ sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \
+ -e "s/%PKGNAME%/${origname}/" \
+ -e "s/%COMMENT%/${comment}/" \
+ -e "s/%DESC%/${desc}/" \
+ -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \
+ -e "s/%PWD_MKDB_ENDIAN%/${pwd_arg}/g" \
+ -e "s/%PKGDEPS%/${pkgdeps}/" \
+ ${uclfile}
+ return 0
+}
+
+main "${@}"
diff --git a/release/packages/groff.ucl b/release/packages/groff.ucl
new file mode 100644
index 0000000..281d2a5
--- /dev/null
+++ b/release/packages/groff.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ GPLv2 ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/jail.ucl b/release/packages/jail.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/jail.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/kernel.ucl b/release/packages/kernel.ucl
new file mode 100644
index 0000000..c89cea6
--- /dev/null
+++ b/release/packages/kernel.ucl
@@ -0,0 +1,22 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+scripts: {
+ post-install = <<EOD
+ /usr/sbin/kldxref ${PKG_ROOTDIR}/boot/kernel
+EOD
+}
diff --git a/release/packages/rcmds.ucl b/release/packages/rcmds.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/rcmds.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/runtime-debug.ucl b/release/packages/runtime-debug.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/runtime-debug.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/runtime-development.ucl b/release/packages/runtime-development.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/runtime-development.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/runtime-lib32.ucl b/release/packages/runtime-lib32.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/runtime-lib32.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/runtime-manuals.ucl b/release/packages/runtime-manuals.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/runtime-manuals.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/runtime-profile.ucl b/release/packages/runtime-profile.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/runtime-profile.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/runtime.ucl b/release/packages/runtime.ucl
new file mode 100644
index 0000000..be45369
--- /dev/null
+++ b/release/packages/runtime.ucl
@@ -0,0 +1,29 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+scripts: {
+ post-install = <<EOD
+ cap_mkdb %CAP_MKDB_ENDIAN% ${PKG_ROOTDIR}/etc/login.conf
+ pwd_mkdb %PWD_MKDB_ENDIAN% -i -p -d ${PKG_ROOTDIR}/etc ${PKG_ROOTDIR}/etc/master.passwd
+EOD
+}
+deps: {
+ "FreeBSD-clibs": {
+ origin: "base"
+ version: "%VERSION%"
+ }
+}
diff --git a/release/packages/ssh.ucl b/release/packages/ssh.ucl
new file mode 100644
index 0000000..aa93464
--- /dev/null
+++ b/release/packages/ssh.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ ISCL ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/svn.ucl b/release/packages/svn.ucl
new file mode 100644
index 0000000..4fd345e
--- /dev/null
+++ b/release/packages/svn.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ APACHE20 ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/syscons.ucl b/release/packages/syscons.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/syscons.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/template.ucl b/release/packages/template.ucl
new file mode 100644
index 0000000..38844f0
--- /dev/null
+++ b/release/packages/template.ucl
@@ -0,0 +1,17 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
diff --git a/release/packages/tests.ucl b/release/packages/tests.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/tests.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/unbound.ucl b/release/packages/unbound.ucl
new file mode 100644
index 0000000..9b95375
--- /dev/null
+++ b/release/packages/unbound.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD4CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/packages/vi.ucl b/release/packages/vi.ucl
new file mode 100644
index 0000000..753c26b
--- /dev/null
+++ b/release/packages/vi.ucl
@@ -0,0 +1,24 @@
+#
+# $FreeBSD$
+#
+
+name = "FreeBSD-%PKGNAME%"
+origin = "base"
+version = "%VERSION%"
+comment = "%COMMENT%"
+categories = [ base ]
+maintainer = "re@FreeBSD.org"
+www = "https://www.FreeBSD.org"
+prefix = "/"
+licenselogic = "single"
+licenses = [ BSD2CLAUSE ]
+desc = <<EOD
+%DESC%
+EOD
+deps: {
+ FreeBSD-%PKGDEPS%: {
+ origin: "base",
+ version: "%VERSION%"
+ }
+}
+
diff --git a/release/scripts/make-pkg-package.sh b/release/scripts/make-pkg-package.sh
new file mode 100755
index 0000000..ab9418b
--- /dev/null
+++ b/release/scripts/make-pkg-package.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# Simulate the build environment.
+eval $(make -C ${SRCDIR} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} buildenvvars)
+export WRKDIRPREFIX=/tmp/ports.${TARGET}
+export WSTAGEDIR=${WSTAGEDIR}
+export REPODIR=${REPODIR}
+export PKG_VERSION=${PKG_VERSION}
+export WRKDIR=$(make -C ${PORTSDIR}/ports-mgmt/pkg -V WRKDIR)
+
+make -C ${PORTSDIR}/ports-mgmt/pkg TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+ CONFIGURE_ARGS="--host=$(uname -m)-portbld-freebsd${REVISION}" \
+ stage create-manifest
+
+pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh \
+ create -v -m ${WRKDIR}/.metadir/ \
+ -r ${WRKDIR}/stage \
+ -p ${WRKDIR}/.PLIST.mktmp \
+ -o ${REPODIR}/$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
+mkdir -p ${REPODIR}/$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}/Latest/
+cd ${REPODIR}/$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}/Latest/ && \
+ ln -s ../pkg-*.txz
diff --git a/release/scripts/mtree-to-plist.awk b/release/scripts/mtree-to-plist.awk
new file mode 100644
index 0000000..d3157ec
--- /dev/null
+++ b/release/scripts/mtree-to-plist.awk
@@ -0,0 +1,80 @@
+#!/usr/bin/awk
+/^[^#]/ {
+ gsub(/^\./,"", $1)
+ uname = gname = mode = flags = tags = type = ""
+ for (i=2; i<=NF; i++) {
+ if ($i ~ /^uname=/) {
+ uname=$i
+ gsub(/uname=/, "", uname)
+ } else if ($i ~ /^gname=/) {
+ gname=$i
+ gsub(/gname=/, "", gname)
+ } else if ($i ~ /^mode=/) {
+ mode=$i
+ gsub(/mode=/,"", mode)
+ } else if ($i ~ /^flags=/) {
+ flags=$i
+ gsub(/flags=/, "", flags)
+ } else if ($i ~ /^tags=/) {
+ tags=$i
+ gsub(/tags=/, "", tags)
+ } else if ($i ~ /^type=dir/) {
+ type="dir"
+ }
+ }
+ if (kernel != "") {
+ tags="package=kernel"
+ if (_kernconf != "") {
+ tags=tags""_kernconf
+ }
+ }
+ if (length(tags) == 0)
+ next
+ if (tags ~ /package=/) {
+ ext = pkgname = pkgend = ""
+ split(tags, a, ",");
+ for (i in a) {
+ if (a[i] ~ /^package=/) {
+ pkgname=a[i]
+ gsub(/package=/, "", pkgname)
+ } else if (a[i] == "config") {
+ type="config"
+ } else if (a[i] == "development" || a[i] == "profile" || a[i] == "debug" || a[i] == "docs") {
+ pkgend=a[i]
+ } else {
+ if (ext != "")
+ ext=ext"-"a[i]
+ else
+ ext=a[i]
+ }
+ }
+ if (ext != "") {
+ pkgname=pkgname"-"ext
+ }
+ if (pkgend != "") {
+ if (pkgend == "docs") {
+ pkgname=pkgend
+ } else {
+ pkgname=pkgname"-"pkgend
+ }
+ }
+ } else {
+ print "No packages specified in line: $0"
+ next
+ }
+ if (kernel != "") {
+ output="kernel"
+ if (_kernconf != "") {
+ output=output"."_kernconf
+ }
+ if ($1 ~ /^\/usr\/lib\/debug\/boot/) {
+ output=output"-debug.plist"
+ } else {
+ output=output".plist"
+ }
+ } else {
+ output=pkgname".plist"
+ }
+
+ print "@"type"("uname","gname","mode","flags") " $1 > output
+}
diff --git a/rescue/librescue/Makefile b/rescue/librescue/Makefile
index ad4931e..4ca6db9 100644
--- a/rescue/librescue/Makefile
+++ b/rescue/librescue/Makefile
@@ -3,6 +3,7 @@
#
.include <src.opts.mk>
+PACKAGE= rescue
MK_SSP= no
# Certain library entries have hard-coded references to
diff --git a/rescue/rescue/Makefile b/rescue/rescue/Makefile
index de314df..70d3a37 100644
--- a/rescue/rescue/Makefile
+++ b/rescue/rescue/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=rescue
MAN=
MK_SSP= no
diff --git a/sbin/adjkerntz/Makefile b/sbin/adjkerntz/Makefile
index 27c1289..e30841e 100644
--- a/sbin/adjkerntz/Makefile
+++ b/sbin/adjkerntz/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= adjkerntz
MAN= adjkerntz.8
diff --git a/sbin/atm/atmconfig/Makefile b/sbin/atm/atmconfig/Makefile
index a77eb25..75a2ede 100644
--- a/sbin/atm/atmconfig/Makefile
+++ b/sbin/atm/atmconfig/Makefile
@@ -7,6 +7,7 @@
.include <src.opts.mk>
+PACKAGE=atm
PROG= atmconfig
SRCS= main.c diag.c natm.c
MAN= atmconfig.8
diff --git a/sbin/badsect/Makefile b/sbin/badsect/Makefile
index 68e2964..c344e6c 100644
--- a/sbin/badsect/Makefile
+++ b/sbin/badsect/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= badsect
LIBADD= ufs
MAN= badsect.8
diff --git a/sbin/bsdlabel/Makefile b/sbin/bsdlabel/Makefile
index 42f0f1c..d2e34d36 100644
--- a/sbin/bsdlabel/Makefile
+++ b/sbin/bsdlabel/Makefile
@@ -3,6 +3,7 @@
.PATH: ${.CURDIR}/../../sys/geom
+PACKAGE=runtime
PROG= bsdlabel
SRCS= bsdlabel.c geom_bsd_enc.c
MAN+= bsdlabel.8
diff --git a/sbin/camcontrol/Makefile b/sbin/camcontrol/Makefile
index cbc5452..f1101d3 100644
--- a/sbin/camcontrol/Makefile
+++ b/sbin/camcontrol/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= camcontrol
SRCS= camcontrol.c util.c
.if !defined(RELEASE_CRUNCH)
diff --git a/sbin/casperd/Makefile b/sbin/casperd/Makefile
new file mode 100644
index 0000000..698263c
--- /dev/null
+++ b/sbin/casperd/Makefile
@@ -0,0 +1,18 @@
+# $FreeBSD$
+
+PACKAGE=casper
+PROG= casperd
+
+SRCS= casperd.c zygote.c
+
+LIBADD= casper nv pjdlog util
+
+MAN= casperd.8
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../lib/libnv
+CFLAGS+=-I${.CURDIR}/../../lib/libpjdlog
+
+.include <bsd.prog.mk>
diff --git a/sbin/ccdconfig/Makefile b/sbin/ccdconfig/Makefile
index 3b64daf..c01b0c5 100644
--- a/sbin/ccdconfig/Makefile
+++ b/sbin/ccdconfig/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=ccdconfig
PROG= ccdconfig
MAN= ccdconfig.8
diff --git a/sbin/clri/Makefile b/sbin/clri/Makefile
index 1ae0cf4..114f563 100644
--- a/sbin/clri/Makefile
+++ b/sbin/clri/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= clri
MAN= clri.8
WARNS?= 2
diff --git a/sbin/comcontrol/Makefile b/sbin/comcontrol/Makefile
index d875756..9bfc468 100644
--- a/sbin/comcontrol/Makefile
+++ b/sbin/comcontrol/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 5.4 (Berkeley) 6/5/91
# $FreeBSD$
+PACKAGE=runtime
PROG= comcontrol
MAN= comcontrol.8
diff --git a/sbin/conscontrol/Makefile b/sbin/conscontrol/Makefile
index 9014d80..0bd82e6 100644
--- a/sbin/conscontrol/Makefile
+++ b/sbin/conscontrol/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= conscontrol
MAN= conscontrol.8
WARNS?= 2
diff --git a/sbin/ddb/Makefile b/sbin/ddb/Makefile
index 72abbed..914942e 100644
--- a/sbin/ddb/Makefile
+++ b/sbin/ddb/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= ddb
SRCS= ddb.c ddb_capture.c ddb_script.c
MAN= ddb.8
diff --git a/sbin/devd/Makefile b/sbin/devd/Makefile
index fc00216..4e5fa47 100644
--- a/sbin/devd/Makefile
+++ b/sbin/devd/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG_CXX=devd
SRCS= devd.cc token.l parse.y y.tab.h
MAN= devd.8 devd.conf.5
diff --git a/sbin/devd/tests/Makefile b/sbin/devd/tests/Makefile
index e06928c..bdec4c4 100644
--- a/sbin/devd/tests/Makefile
+++ b/sbin/devd/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_C= client_test
TEST_METADATA.client_test= required_programs="devd"
TEST_METADATA.client_test+= required_user="root"
diff --git a/sbin/devfs/Makefile b/sbin/devfs/Makefile
index 29b0f54..eee24e0 100644
--- a/sbin/devfs/Makefile
+++ b/sbin/devfs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= devfs
SRCS= devfs.c rule.c
MAN= devfs.8
diff --git a/sbin/dhclient/Makefile b/sbin/dhclient/Makefile
index 868df6d..2e9881f 100644
--- a/sbin/dhclient/Makefile
+++ b/sbin/dhclient/Makefile
@@ -33,6 +33,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
SRCS= dhclient.c clparse.c alloc.c dispatch.c hash.c bpf.c options.c \
tree.c conflex.c errwarn.c inet.c packet.c convert.c tables.c \
parse.c privsep.c
diff --git a/sbin/dhclient/tests/Makefile b/sbin/dhclient/tests/Makefile
index fd3df4e..88516d9 100644
--- a/sbin/dhclient/tests/Makefile
+++ b/sbin/dhclient/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
.PATH: ${.CURDIR}/..
PLAIN_TESTS_C= option-domain-search_test
diff --git a/sbin/dmesg/Makefile b/sbin/dmesg/Makefile
index 64a0155..a443225 100644
--- a/sbin/dmesg/Makefile
+++ b/sbin/dmesg/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= dmesg
MAN= dmesg.8
diff --git a/sbin/dump/Makefile b/sbin/dump/Makefile
index e3d9aef..7c89570 100644
--- a/sbin/dump/Makefile
+++ b/sbin/dump/Makefile
@@ -13,6 +13,7 @@
# DEBUG use local directory to find ddate and dumpdates
# TDEBUG trace out the process forking
+PACKAGE=runtime
PROG= dump
LINKS= ${BINDIR}/dump ${BINDIR}/rdump
CFLAGS+=-DRDUMP
diff --git a/sbin/dumpfs/Makefile b/sbin/dumpfs/Makefile
index 87eb89b..03e1aae 100644
--- a/sbin/dumpfs/Makefile
+++ b/sbin/dumpfs/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= dumpfs
WARNS?= 2
LIBADD= ufs
diff --git a/sbin/dumpon/Makefile b/sbin/dumpon/Makefile
index d11ccc7..782117c 100644
--- a/sbin/dumpon/Makefile
+++ b/sbin/dumpon/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= dumpon
MAN= dumpon.8
diff --git a/sbin/etherswitchcfg/Makefile b/sbin/etherswitchcfg/Makefile
index b5cf39a..547a272 100644
--- a/sbin/etherswitchcfg/Makefile
+++ b/sbin/etherswitchcfg/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 5.4 (Berkeley) 6/5/91
# $FreeBSD$
+PACKAGE=runtime
PROG= etherswitchcfg
MAN= etherswitchcfg.8
SRCS= etherswitchcfg.c ifmedia.c
diff --git a/sbin/fdisk/Makefile b/sbin/fdisk/Makefile
index a49c699..fc4bcba 100644
--- a/sbin/fdisk/Makefile
+++ b/sbin/fdisk/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= fdisk
SRCS= fdisk.c geom_mbr_enc.c
WARNS?= 4
diff --git a/sbin/fdisk_pc98/Makefile b/sbin/fdisk_pc98/Makefile
index 9915267..7bfa063 100644
--- a/sbin/fdisk_pc98/Makefile
+++ b/sbin/fdisk_pc98/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= fdisk
SRCS= fdisk.c geom_pc98_enc.c
WARNS?= 4
diff --git a/sbin/ffsinfo/Makefile b/sbin/ffsinfo/Makefile
index 7fd033d..cdc9e7b 100644
--- a/sbin/ffsinfo/Makefile
+++ b/sbin/ffsinfo/Makefile
@@ -7,6 +7,7 @@
GROWFS= ${.CURDIR}/../growfs
.PATH: ${GROWFS}
+PACKAGE=runtime
PROG= ffsinfo
SRCS= ffsinfo.c debug.c
MAN= ffsinfo.8
diff --git a/sbin/fsck/Makefile b/sbin/fsck/Makefile
index 22de03c..8d3dd21 100644
--- a/sbin/fsck/Makefile
+++ b/sbin/fsck/Makefile
@@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.14 1996/09/27 22:38:37 christos Exp $
# $FreeBSD$
+PACKAGE=runtime
PROG= fsck
SRCS= fsck.c fsutil.c preen.c
MAN= fsck.8
diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile
index 0275469..b00aee5 100644
--- a/sbin/fsck_ffs/Makefile
+++ b/sbin/fsck_ffs/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
# @(#)Makefile 8.2 (Berkeley) 4/27/95
+PACKAGE=runtime
PROG= fsck_ffs
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_ufs
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd
diff --git a/sbin/fsck_msdosfs/Makefile b/sbin/fsck_msdosfs/Makefile
index f9dd9fa..0de68f1 100644
--- a/sbin/fsck_msdosfs/Makefile
+++ b/sbin/fsck_msdosfs/Makefile
@@ -4,6 +4,7 @@
FSCK= ${.CURDIR}/../fsck
.PATH: ${FSCK}
+PACKAGE=runtime
PROG= fsck_msdosfs
MAN= fsck_msdosfs.8
SRCS= main.c check.c boot.c fat.c dir.c fsutil.c
diff --git a/sbin/fsdb/Makefile b/sbin/fsdb/Makefile
index e0a9cc3..729f9cd 100644
--- a/sbin/fsdb/Makefile
+++ b/sbin/fsdb/Makefile
@@ -2,6 +2,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= fsdb
MAN= fsdb.8
SRCS= fsdb.c fsdbutil.c \
diff --git a/sbin/fsirand/Makefile b/sbin/fsirand/Makefile
index 2ae820a..c415b11 100644
--- a/sbin/fsirand/Makefile
+++ b/sbin/fsirand/Makefile
@@ -1,6 +1,7 @@
# $OpenBSD: Makefile,v 1.1 1997/01/26 02:23:20 millert Exp $
# $FreeBSD$
+PACKAGE=runtime
PROG= fsirand
MAN= fsirand.8
WARNS?= 3
diff --git a/sbin/gbde/Makefile b/sbin/gbde/Makefile
index f80f8cd..2e5dc81 100644
--- a/sbin/gbde/Makefile
+++ b/sbin/gbde/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= gbde
SRCS= gbde.c template.c
SRCS+= rijndael-alg-fst.c
diff --git a/sbin/geom/Makefile b/sbin/geom/Makefile
index 19a5636..5ef8fb8 100644
--- a/sbin/geom/Makefile
+++ b/sbin/geom/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.if defined(RESCUE) || defined(RELEASE_CRUNCH)
.PATH: ${.CURDIR}/class/part \
diff --git a/sbin/geom/class/cache/Makefile b/sbin/geom/class/cache/Makefile
index 35f81d8..63b740b 100644
--- a/sbin/geom/class/cache/Makefile
+++ b/sbin/geom/class/cache/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= cache
diff --git a/sbin/geom/class/concat/Makefile b/sbin/geom/class/concat/Makefile
index 34e2c28..1338056 100644
--- a/sbin/geom/class/concat/Makefile
+++ b/sbin/geom/class/concat/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= concat
diff --git a/sbin/geom/class/eli/Makefile b/sbin/geom/class/eli/Makefile
index 5eff32c..74749d2 100644
--- a/sbin/geom/class/eli/Makefile
+++ b/sbin/geom/class/eli/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc ${.CURDIR}/../../../../sys/geom/eli ${.CURDIR}/../../../../sys/crypto/sha2
GEOM_CLASS= eli
diff --git a/sbin/geom/class/journal/Makefile b/sbin/geom/class/journal/Makefile
index 0e1a38ea..14fff15 100644
--- a/sbin/geom/class/journal/Makefile
+++ b/sbin/geom/class/journal/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= journal
diff --git a/sbin/geom/class/label/Makefile b/sbin/geom/class/label/Makefile
index 0b609a1..2a51c5b 100644
--- a/sbin/geom/class/label/Makefile
+++ b/sbin/geom/class/label/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= label
diff --git a/sbin/geom/class/mirror/Makefile b/sbin/geom/class/mirror/Makefile
index ce7ee64..195c9d5 100644
--- a/sbin/geom/class/mirror/Makefile
+++ b/sbin/geom/class/mirror/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= mirror
diff --git a/sbin/geom/class/mountver/Makefile b/sbin/geom/class/mountver/Makefile
index 750d1a5..3dba589 100644
--- a/sbin/geom/class/mountver/Makefile
+++ b/sbin/geom/class/mountver/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= mountver
diff --git a/sbin/geom/class/multipath/Makefile b/sbin/geom/class/multipath/Makefile
index ff40fe9..2a6b7cc 100644
--- a/sbin/geom/class/multipath/Makefile
+++ b/sbin/geom/class/multipath/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= multipath
diff --git a/sbin/geom/class/nop/Makefile b/sbin/geom/class/nop/Makefile
index d9a6ca6..903cfcf0 100644
--- a/sbin/geom/class/nop/Makefile
+++ b/sbin/geom/class/nop/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= nop
diff --git a/sbin/geom/class/part/Makefile b/sbin/geom/class/part/Makefile
index 4b67de4..b67d11f 100644
--- a/sbin/geom/class/part/Makefile
+++ b/sbin/geom/class/part/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= part
diff --git a/sbin/geom/class/raid/Makefile b/sbin/geom/class/raid/Makefile
index 07d7140..79c05a2 100644
--- a/sbin/geom/class/raid/Makefile
+++ b/sbin/geom/class/raid/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= raid
diff --git a/sbin/geom/class/raid3/Makefile b/sbin/geom/class/raid3/Makefile
index 74e1245..b8bc5ea 100644
--- a/sbin/geom/class/raid3/Makefile
+++ b/sbin/geom/class/raid3/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= raid3
diff --git a/sbin/geom/class/sched/Makefile b/sbin/geom/class/sched/Makefile
index 6f54d3f..17e4523 100644
--- a/sbin/geom/class/sched/Makefile
+++ b/sbin/geom/class/sched/Makefile
@@ -1,6 +1,7 @@
# GEOM_LIBRARY_PATH
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= sched
diff --git a/sbin/geom/class/shsec/Makefile b/sbin/geom/class/shsec/Makefile
index 6b5c835..51cee34 100644
--- a/sbin/geom/class/shsec/Makefile
+++ b/sbin/geom/class/shsec/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= shsec
diff --git a/sbin/geom/class/stripe/Makefile b/sbin/geom/class/stripe/Makefile
index 8ee5f6e..c0fdef1 100644
--- a/sbin/geom/class/stripe/Makefile
+++ b/sbin/geom/class/stripe/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc
GEOM_CLASS= stripe
diff --git a/sbin/geom/class/virstor/Makefile b/sbin/geom/class/virstor/Makefile
index 0924f0d..0fe24e6 100644
--- a/sbin/geom/class/virstor/Makefile
+++ b/sbin/geom/class/virstor/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
.PATH: ${.CURDIR}/../../misc ${.CURDIR}/../../../../sys/geom/virstor
GEOM_CLASS= virstor
diff --git a/sbin/geom/core/Makefile b/sbin/geom/core/Makefile
index 0636d03..8b69b72 100644
--- a/sbin/geom/core/Makefile
+++ b/sbin/geom/core/Makefile
@@ -2,6 +2,7 @@
.PATH: ${.CURDIR}/../misc
+PACKAGE=runtime
PROG= geom
MAN= geom.8
SRCS= geom.c subr.c
diff --git a/sbin/growfs/Makefile b/sbin/growfs/Makefile
index e7017a7..a75c644 100644
--- a/sbin/growfs/Makefile
+++ b/sbin/growfs/Makefile
@@ -8,6 +8,7 @@
.PATH: ${.CURDIR}/../mount
+PACKAGE=runtime
PROG= growfs
SRCS= growfs.c getmntopts.c
MAN= growfs.8
diff --git a/sbin/growfs/tests/Makefile b/sbin/growfs/tests/Makefile
index 6a3208d..5fdceb7 100644
--- a/sbin/growfs/tests/Makefile
+++ b/sbin/growfs/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_PERL= legacy_test
.include <bsd.test.mk>
diff --git a/sbin/gvinum/Makefile b/sbin/gvinum/Makefile
index 0e56920..5bb40ea 100644
--- a/sbin/gvinum/Makefile
+++ b/sbin/gvinum/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= gvinum
SRCS= gvinum.c gvinum.h geom_vinum_share.c
MAN= gvinum.8
diff --git a/sbin/hastctl/Makefile b/sbin/hastctl/Makefile
index 41d443d..a24b55e 100644
--- a/sbin/hastctl/Makefile
+++ b/sbin/hastctl/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=hast
.PATH: ${.CURDIR}/../hastd
PROG= hastctl
diff --git a/sbin/hastd/Makefile b/sbin/hastd/Makefile
index e3fed8d..7ffebf9 100644
--- a/sbin/hastd/Makefile
+++ b/sbin/hastd/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=hast
PROG= hastd
SRCS= activemap.c
SRCS+= control.c crc32.c
diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile
index b5616a4..a3623d5 100644
--- a/sbin/ifconfig/Makefile
+++ b/sbin/ifconfig/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= ifconfig
SRCS= ifconfig.c # base support
diff --git a/sbin/ifconfig/tests/Makefile b/sbin/ifconfig/tests/Makefile
index 93967c7..8a55191 100644
--- a/sbin/ifconfig/tests/Makefile
+++ b/sbin/ifconfig/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= nonexistent_test
.include <netbsd-tests.test.mk>
diff --git a/sbin/init/Makefile b/sbin/init/Makefile
index 29ad63d..cf6de6c 100644
--- a/sbin/init/Makefile
+++ b/sbin/init/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 7/19/93
# $FreeBSD$
+PACKAGE=runtime
PROG= init
SRCS= init.c getmntopts.c
MAN= init.8
diff --git a/sbin/ipf/ipf/Makefile b/sbin/ipf/ipf/Makefile
index 2ff340f..1f82578 100644
--- a/sbin/ipf/ipf/Makefile
+++ b/sbin/ipf/ipf/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= ipf
PROG= ipf
SRCS= ${GENHDRS} ipf.c ipfcomp.c ipf_y.c ipf_l.c bpf_filter.c
MAN= ipfilter.4 ipfilter.5 ipf.8 ipf.4 ipf.5 ipl.4
diff --git a/sbin/ipf/ipfs/Makefile b/sbin/ipf/ipfs/Makefile
index a64f805..6f76f9d 100644
--- a/sbin/ipf/ipfs/Makefile
+++ b/sbin/ipf/ipfs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=ipf
PROG= ipfs
MAN= ipfs.8
diff --git a/sbin/ipf/ipfstat/Makefile b/sbin/ipf/ipfstat/Makefile
index 14823cf..4714f2c 100644
--- a/sbin/ipf/ipfstat/Makefile
+++ b/sbin/ipf/ipfstat/Makefile
@@ -2,6 +2,7 @@
NOGCCERROR= # defined
+PACKAGE= ipf
PROG= ipfstat
SRCS= ipfstat.c
MAN= ipfstat.8
diff --git a/sbin/ipf/ipftest/Makefile b/sbin/ipf/ipftest/Makefile
index a74599f..63cafab 100644
--- a/sbin/ipf/ipftest/Makefile
+++ b/sbin/ipf/ipftest/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= ipf
PROG= ipftest
SRCS= ${GENHDRS} ipftest.c fil.c ip_frag.c ip_state.c ip_nat.c \
ip_nat6.c \
diff --git a/sbin/ipf/ipmon/Makefile b/sbin/ipf/ipmon/Makefile
index 031f929..5d76a05 100644
--- a/sbin/ipf/ipmon/Makefile
+++ b/sbin/ipf/ipmon/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= ipf
PROG= ipmon
SRCS= ${GENHDRS} ipmon.c ipmon_y.c ipmon_l.c
MAN= ipmon.8
diff --git a/sbin/ipf/ipnat/Makefile b/sbin/ipf/ipnat/Makefile
index 74be486..ba9c50e 100644
--- a/sbin/ipf/ipnat/Makefile
+++ b/sbin/ipf/ipnat/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= ipf
PROG= ipnat
SRCS= ${GENHDRS} ipnat.c ipnat_y.c ipnat_l.c
MAN= ipnat.8 ipnat.4 ipnat.5
diff --git a/sbin/ipf/ippool/Makefile b/sbin/ipf/ippool/Makefile
index eedebef..ab350f2 100644
--- a/sbin/ipf/ippool/Makefile
+++ b/sbin/ipf/ippool/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= ipf
PROG= ippool
SRCS= ${GENHDRS} ippool_y.c ippool_l.c kmem.c ippool.c
MAN= ippool.5 ippool.8
diff --git a/sbin/ipf/ipresend/Makefile b/sbin/ipf/ipresend/Makefile
index 5e0ac15..da1879b 100644
--- a/sbin/ipf/ipresend/Makefile
+++ b/sbin/ipf/ipresend/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= ipf
PROG= ipresend
SRCS= ipresend.c ip.c resend.c sbpf.c sock.c 44arp.c
MAN= ipresend.1
diff --git a/sbin/ipf/libipf/Makefile b/sbin/ipf/libipf/Makefile
index 7a7a011..a8f43e2 100644
--- a/sbin/ipf/libipf/Makefile
+++ b/sbin/ipf/libipf/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= ipf
LIB= ipf
INTERNALLIB=
diff --git a/sbin/ipfw/Makefile b/sbin/ipfw/Makefile
index efd99fc..668f22a 100644
--- a/sbin/ipfw/Makefile
+++ b/sbin/ipfw/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=ipfw
PROG= ipfw
SRCS= ipfw2.c dummynet.c ipv6.c main.c nat.c tables.c
WARNS?= 2
diff --git a/sbin/iscontrol/Makefile b/sbin/iscontrol/Makefile
index 9c4d9f4..6b0fe3a 100644
--- a/sbin/iscontrol/Makefile
+++ b/sbin/iscontrol/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=iscsi_legacy
SRCS= iscontrol.c pdu.c fsm.c config.c login.c auth_subr.c misc.c
PROG= iscontrol
LIBADD= cam md
diff --git a/sbin/kldconfig/Makefile b/sbin/kldconfig/Makefile
index a478c4b..3efb34f 100644
--- a/sbin/kldconfig/Makefile
+++ b/sbin/kldconfig/Makefile
@@ -26,6 +26,7 @@
# $FreeBSD$
#
+PACKAGE=runtime
PROG= kldconfig
MAN= kldconfig.8
diff --git a/sbin/kldload/Makefile b/sbin/kldload/Makefile
index 05ad5ba..13c0f0e 100644
--- a/sbin/kldload/Makefile
+++ b/sbin/kldload/Makefile
@@ -26,6 +26,7 @@
# $FreeBSD$
#
+PACKAGE=runtime
PROG= kldload
MAN= kldload.8
diff --git a/sbin/kldstat/Makefile b/sbin/kldstat/Makefile
index 4bf022e..2d0c443 100644
--- a/sbin/kldstat/Makefile
+++ b/sbin/kldstat/Makefile
@@ -26,6 +26,7 @@
# $FreeBSD$
#
+PACKAGE=runtime
PROG= kldstat
MAN= kldstat.8
diff --git a/sbin/kldunload/Makefile b/sbin/kldunload/Makefile
index 1a25a02..5688f79 100644
--- a/sbin/kldunload/Makefile
+++ b/sbin/kldunload/Makefile
@@ -26,6 +26,7 @@
# $FreeBSD$
#
+PACKAGE=runtime
PROG= kldunload
MAN= kldunload.8
diff --git a/sbin/ldconfig/Makefile b/sbin/ldconfig/Makefile
index 15c3808..6589dbc 100644
--- a/sbin/ldconfig/Makefile
+++ b/sbin/ldconfig/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= ldconfig
SRCS= elfhints.c ldconfig.c shlib.c support.c
LDDIR?= ${.CURDIR}/../../libexec/rtld-aout
diff --git a/sbin/md5/Makefile b/sbin/md5/Makefile
index 5f927c4..6b65172 100644
--- a/sbin/md5/Makefile
+++ b/sbin/md5/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/9/93
# $FreeBSD$
+PACKAGE=runtime
PROG= md5
LINKS= ${BINDIR}/md5 ${BINDIR}/rmd160 \
diff --git a/sbin/mdconfig/Makefile b/sbin/mdconfig/Makefile
index 6be9129..21db48a 100644
--- a/sbin/mdconfig/Makefile
+++ b/sbin/mdconfig/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= mdconfig
MAN= mdconfig.8
diff --git a/sbin/mdconfig/tests/Makefile b/sbin/mdconfig/tests/Makefile
index 6c179fc..58507d3 100644
--- a/sbin/mdconfig/tests/Makefile
+++ b/sbin/mdconfig/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= mdconfig_test
TEST_METADATA.mdconfig_test+= required_user="root"
diff --git a/sbin/mdmfs/Makefile b/sbin/mdmfs/Makefile
index 999793f..e8d2d7b 100644
--- a/sbin/mdmfs/Makefile
+++ b/sbin/mdmfs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= mdmfs
LINKS= ${BINDIR}/${PROG} ${BINDIR}/mount_mfs
MAN= mdmfs.8
diff --git a/sbin/mknod/Makefile b/sbin/mknod/Makefile
index 63235b2..610d2a4 100644
--- a/sbin/mknod/Makefile
+++ b/sbin/mknod/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= mknod
MAN= mknod.8
diff --git a/sbin/mksnap_ffs/Makefile b/sbin/mksnap_ffs/Makefile
index de96fa0..33040ec 100644
--- a/sbin/mksnap_ffs/Makefile
+++ b/sbin/mksnap_ffs/Makefile
@@ -2,6 +2,7 @@
.PATH: ${.CURDIR}/../mount
+PACKAGE=runtime
PROG= mksnap_ffs
SRCS= mksnap_ffs.c getmntopts.c
MAN= mksnap_ffs.8
diff --git a/sbin/mount/Makefile b/sbin/mount/Makefile
index f95085a..80d4023 100644
--- a/sbin/mount/Makefile
+++ b/sbin/mount/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.6 (Berkeley) 5/8/95
# $FreeBSD$
+PACKAGE=runtime
PROG= mount
SRCS= mount.c mount_fs.c getmntopts.c vfslist.c
MAN= mount.8 mount.conf.8
diff --git a/sbin/mount_cd9660/Makefile b/sbin/mount_cd9660/Makefile
index c70892c..83d58a2 100644
--- a/sbin/mount_cd9660/Makefile
+++ b/sbin/mount_cd9660/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
+PACKAGE=runtime
PROG= mount_cd9660
SRCS= mount_cd9660.c getmntopts.c
MAN= mount_cd9660.8
diff --git a/sbin/mount_fusefs/Makefile b/sbin/mount_fusefs/Makefile
index 9c84fa6..2197580 100644
--- a/sbin/mount_fusefs/Makefile
+++ b/sbin/mount_fusefs/Makefile
@@ -20,6 +20,7 @@ DEBUG_FLAGS+= -D_DEBUG_MSG
DEBUG_FLAGS+= -DFUSE4BSD_VERSION="\"${F4BVERS}\""
.endif
+PACKAGE=runtime
PROG= mount_fusefs
SRCS= mount_fusefs.c getmntopts.c
MAN8= mount_fusefs.8
diff --git a/sbin/mount_msdosfs/Makefile b/sbin/mount_msdosfs/Makefile
index ede86b4..abbad5e 100644
--- a/sbin/mount_msdosfs/Makefile
+++ b/sbin/mount_msdosfs/Makefile
@@ -2,6 +2,7 @@
# $FreeBSD$
#
+PACKAGE=runtime
PROG= mount_msdosfs
SRCS= mount_msdosfs.c getmntopts.c
MAN= mount_msdosfs.8
diff --git a/sbin/mount_nfs/Makefile b/sbin/mount_nfs/Makefile
index 75f7817..76c2bfb 100644
--- a/sbin/mount_nfs/Makefile
+++ b/sbin/mount_nfs/Makefile
@@ -2,6 +2,7 @@
#
# $FreeBSD$
+PACKAGE=runtime
PROG= mount_nfs
SRCS= mount_nfs.c getmntopts.c mounttab.c
MAN= mount_nfs.8
diff --git a/sbin/mount_nullfs/Makefile b/sbin/mount_nullfs/Makefile
index 0b2ecc5..c9b5279 100644
--- a/sbin/mount_nullfs/Makefile
+++ b/sbin/mount_nullfs/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
+PACKAGE=runtime
PROG= mount_nullfs
SRCS= mount_nullfs.c getmntopts.c
MAN= mount_nullfs.8
diff --git a/sbin/mount_udf/Makefile b/sbin/mount_udf/Makefile
index 12d5d58..f0f50ab 100644
--- a/sbin/mount_udf/Makefile
+++ b/sbin/mount_udf/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= mount_udf
SRCS= mount_udf.c getmntopts.c
MAN= mount_udf.8
diff --git a/sbin/mount_unionfs/Makefile b/sbin/mount_unionfs/Makefile
index 276fc74..cca1ea0 100644
--- a/sbin/mount_unionfs/Makefile
+++ b/sbin/mount_unionfs/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
+PACKAGE=runtime
PROG= mount_unionfs
SRCS= mount_unionfs.c getmntopts.c
MAN= mount_unionfs.8
diff --git a/sbin/nandfs/Makefile b/sbin/nandfs/Makefile
index 5757f8c..40af577 100644
--- a/sbin/nandfs/Makefile
+++ b/sbin/nandfs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=nandfs
PROG= nandfs
SRCS= nandfs.c lssnap.c mksnap.c rmsnap.c
MAN= nandfs.8
diff --git a/sbin/natd/Makefile b/sbin/natd/Makefile
index 44e5b6f..aef193b 100644
--- a/sbin/natd/Makefile
+++ b/sbin/natd/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= natd
PROG = natd
SRCS = natd.c icmp.c
WARNS?= 3
diff --git a/sbin/newfs_msdos/Makefile b/sbin/newfs_msdos/Makefile
index ec5e848..3a2c49f 100644
--- a/sbin/newfs_msdos/Makefile
+++ b/sbin/newfs_msdos/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= newfs_msdos
MAN= newfs_msdos.8
SRCS= newfs_msdos.c mkfs_msdos.c
diff --git a/sbin/newfs_nandfs/Makefile b/sbin/newfs_nandfs/Makefile
index 7a39fbb..9b1b300 100644
--- a/sbin/newfs_nandfs/Makefile
+++ b/sbin/newfs_nandfs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=nandfs
PROG= newfs_nandfs
MAN= newfs_nandfs.8
diff --git a/sbin/nfsiod/Makefile b/sbin/nfsiod/Makefile
index 47cd290..ea66a6d 100644
--- a/sbin/nfsiod/Makefile
+++ b/sbin/nfsiod/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= nfsiod
MAN= nfsiod.8
diff --git a/sbin/nos-tun/Makefile b/sbin/nos-tun/Makefile
index 9f1024f..480141e 100644
--- a/sbin/nos-tun/Makefile
+++ b/sbin/nos-tun/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= nos-tun
MAN= nos-tun.8
WARNS?= 3
diff --git a/sbin/nvmecontrol/Makefile b/sbin/nvmecontrol/Makefile
index e8a2371..42dd591 100644
--- a/sbin/nvmecontrol/Makefile
+++ b/sbin/nvmecontrol/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= nvmecontrol
SRCS= nvmecontrol.c devlist.c firmware.c identify.c logpage.c \
perftest.c reset.c nvme_util.c power.c
diff --git a/sbin/pfctl/Makefile b/sbin/pfctl/Makefile
index de3b7ec..91ebf55 100644
--- a/sbin/pfctl/Makefile
+++ b/sbin/pfctl/Makefile
@@ -5,6 +5,7 @@
# pf_ruleset.c is shared between kernel and pfctl
.PATH: ${.CURDIR}/../../sys/netpfil/pf
+PACKAGE=pf
PROG= pfctl
MAN= pfctl.8
diff --git a/sbin/pflogd/Makefile b/sbin/pflogd/Makefile
index 49a311e..bb74500 100644
--- a/sbin/pflogd/Makefile
+++ b/sbin/pflogd/Makefile
@@ -2,6 +2,7 @@
.PATH: ${.CURDIR}/../../contrib/pf/pflogd
+PACKAGE=pf
PROG= pflogd
SRCS= pflogd.c pidfile.c privsep.c privsep_fdpass.c
MAN= pflogd.8
diff --git a/sbin/ping/Makefile b/sbin/ping/Makefile
index 31e6153..21a4dcc 100644
--- a/sbin/ping/Makefile
+++ b/sbin/ping/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= ping
MAN= ping.8
BINOWN= root
diff --git a/sbin/ping6/Makefile b/sbin/ping6/Makefile
index 707bff4..78874f5 100644
--- a/sbin/ping6/Makefile
+++ b/sbin/ping6/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= ping6
MAN= ping6.8
diff --git a/sbin/quotacheck/Makefile b/sbin/quotacheck/Makefile
index 7be3e35..601c19e 100644
--- a/sbin/quotacheck/Makefile
+++ b/sbin/quotacheck/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
# @(#)Makefile 8.1 (Berkeley) 6/5/93
+PACKAGE=quotacheck
PROG= quotacheck
SRCS= quotacheck.c preen.c fsutil.c utilities.c
WARNS?= 2
diff --git a/sbin/rcorder/Makefile b/sbin/rcorder/Makefile
index 2f1bbac..71bc82c 100644
--- a/sbin/rcorder/Makefile
+++ b/sbin/rcorder/Makefile
@@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.1 1999/11/23 05:28:20 mrg Exp $
# $FreeBSD$
+PACKAGE=runtime
PROG= rcorder
SRCS= ealloc.c hash.c rcorder.c
MAN= rcorder.8
diff --git a/sbin/reboot/Makefile b/sbin/reboot/Makefile
index aa41e30..87c4730 100644
--- a/sbin/reboot/Makefile
+++ b/sbin/reboot/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= reboot
MAN= reboot.8 nextboot.8
MLINKS= reboot.8 halt.8 reboot.8 fastboot.8 reboot.8 fasthalt.8
diff --git a/sbin/recoverdisk/Makefile b/sbin/recoverdisk/Makefile
index 136e570..41ef1f3 100644
--- a/sbin/recoverdisk/Makefile
+++ b/sbin/recoverdisk/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= recoverdisk
.include <bsd.prog.mk>
diff --git a/sbin/resolvconf/Makefile b/sbin/resolvconf/Makefile
index 2d4701e..783d8b6 100644
--- a/sbin/resolvconf/Makefile
+++ b/sbin/resolvconf/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
DIST= ${.CURDIR}/../../contrib/openresolv
.PATH: ${DIST}
diff --git a/sbin/restore/Makefile b/sbin/restore/Makefile
index c462f51..58fed3e 100644
--- a/sbin/restore/Makefile
+++ b/sbin/restore/Makefile
@@ -3,6 +3,7 @@
.PATH: ${.CURDIR}/../dump
+PACKAGE=runtime
PROG= restore
LINKS= ${BINDIR}/restore ${BINDIR}/rrestore
MAN= restore.8
diff --git a/sbin/route/Makefile b/sbin/route/Makefile
index 25134e4..a1db0b6 100644
--- a/sbin/route/Makefile
+++ b/sbin/route/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= route
MAN= route.8
SRCS= route.c keywords.h
diff --git a/sbin/routed/Makefile b/sbin/routed/Makefile
index 2308722..c01ab41 100644
--- a/sbin/routed/Makefile
+++ b/sbin/routed/Makefile
@@ -1,6 +1,7 @@
# Make `routed` for FreeBSD
# $FreeBSD$
+PACKAGE=runtime
PROG= routed
MAN= routed.8
SRCS= if.c input.c main.c output.c parms.c radix.c rdisc.c table.c trace.c
diff --git a/sbin/routed/rtquery/Makefile b/sbin/routed/rtquery/Makefile
index 4df7dc2..a9893a9 100644
--- a/sbin/routed/rtquery/Makefile
+++ b/sbin/routed/rtquery/Makefile
@@ -2,6 +2,7 @@
# $Revision: 1.6 $
# $FreeBSD$
+PACKAGE=runtime
PROG= rtquery
MAN= rtquery.8
LIBADD= md
diff --git a/sbin/rtsol/Makefile b/sbin/rtsol/Makefile
index 8356ea4..f12107a 100644
--- a/sbin/rtsol/Makefile
+++ b/sbin/rtsol/Makefile
@@ -16,6 +16,7 @@
.PATH: ${.CURDIR}/../../usr.sbin/rtsold
+PACKAGE=runtime
PROG= rtsol
SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c
MAN=
diff --git a/sbin/savecore/Makefile b/sbin/savecore/Makefile
index 5134e4c..f5eeb77 100644
--- a/sbin/savecore/Makefile
+++ b/sbin/savecore/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=runtime
PROG= savecore
LIBADD= z xo
MAN= savecore.8
diff --git a/sbin/sconfig/Makefile b/sbin/sconfig/Makefile
index 9698c04..bce914f 100644
--- a/sbin/sconfig/Makefile
+++ b/sbin/sconfig/Makefile
@@ -1,6 +1,7 @@
# Cronyx Id: sbin.sconfig.Makefile,v 1.1.4.1 2003/02/17 12:51:24 rik Exp $
# $FreeBSD$
+PACKAGE=runtime
PROG= sconfig
MAN= sconfig.8
MANSUBDIR= /i386
diff --git a/sbin/setkey/Makefile b/sbin/setkey/Makefile
index e974af5..0777fff 100644
--- a/sbin/setkey/Makefile
+++ b/sbin/setkey/Makefile
@@ -29,6 +29,7 @@
.include <src.opts.mk>
+PACKAGE=runtime
PROG= setkey
MAN= setkey.8
SRCS= setkey.c parse.y token.l
diff --git a/sbin/shutdown/Makefile b/sbin/shutdown/Makefile
index 905d1bc..fc7e38b 100644
--- a/sbin/shutdown/Makefile
+++ b/sbin/shutdown/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= shutdown
MAN= shutdown.8
LINKS= ${BINDIR}/shutdown ${BINDIR}/poweroff
diff --git a/sbin/swapon/Makefile b/sbin/swapon/Makefile
index e9074be..c832be3 100644
--- a/sbin/swapon/Makefile
+++ b/sbin/swapon/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= swapon
MAN= swapon.8
LINKS= ${BINDIR}/swapon ${BINDIR}/swapoff
diff --git a/sbin/sysctl/Makefile b/sbin/sysctl/Makefile
index 06ff9b4..30099ae 100644
--- a/sbin/sysctl/Makefile
+++ b/sbin/sysctl/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$
+PACKAGE=runtime
PROG= sysctl
WARNS?= 3
MAN= sysctl.8
diff --git a/sbin/tests/Makefile b/sbin/tests/Makefile
index a0e63e5..609357e 100644
--- a/sbin/tests/Makefile
+++ b/sbin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/sbin/tunefs/Makefile b/sbin/tunefs/Makefile
index 07fe3b1..a62d2f4 100644
--- a/sbin/tunefs/Makefile
+++ b/sbin/tunefs/Makefile
@@ -1,6 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime
PROG= tunefs
LIBADD= ufs
MAN= tunefs.8
diff --git a/sbin/umount/Makefile b/sbin/umount/Makefile
index e472b41..cdc66b9 100644
--- a/sbin/umount/Makefile
+++ b/sbin/umount/Makefile
@@ -2,6 +2,7 @@
#
# $FreeBSD$
+PACKAGE=runtime
PROG= umount
SRCS= umount.c vfslist.c mounttab.c
MAN= umount.8
diff --git a/secure/lib/libssh/Makefile b/secure/lib/libssh/Makefile
index 2eae203..35e291b 100644
--- a/secure/lib/libssh/Makefile
+++ b/secure/lib/libssh/Makefile
@@ -23,6 +23,7 @@ SRCS+= authfd.c authfile.c bufaux.c bufbn.c bufec.c buffer.c \
kex.c kexdh.c kexgex.c kexecdh.c kexc25519.c \
kexdhc.c kexgexc.c kexecdhc.c kexc25519c.c \
kexdhs.c kexgexs.c kexecdhs.c kexc25519s.c
+PACKAGE= ssh
# gss-genr.c should be in $SRCS but causes linking problems, so it is
# compiled directly into sshd instead.
diff --git a/secure/lib/tests/Makefile b/secure/lib/tests/Makefile
index a0e63e5..609357e 100644
--- a/secure/lib/tests/Makefile
+++ b/secure/lib/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/secure/libexec/Makefile.inc b/secure/libexec/Makefile.inc
index 6d620e2..084a719 100644
--- a/secure/libexec/Makefile.inc
+++ b/secure/libexec/Makefile.inc
@@ -1,5 +1,6 @@
# $FreeBSD$
BINDIR?= /usr/libexec
+PACKAGE= ssh
.include "../Makefile.inc"
diff --git a/secure/libexec/tests/Makefile b/secure/libexec/tests/Makefile
index a0e63e5..609357e 100644
--- a/secure/libexec/tests/Makefile
+++ b/secure/libexec/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/secure/tests/Makefile b/secure/tests/Makefile
index a0e63e5..609357e 100644
--- a/secure/tests/Makefile
+++ b/secure/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/secure/usr.bin/scp/Makefile b/secure/usr.bin/scp/Makefile
index 18cfbaf..ca00921 100644
--- a/secure/usr.bin/scp/Makefile
+++ b/secure/usr.bin/scp/Makefile
@@ -4,6 +4,7 @@
PROG= scp
SRCS= scp.c
+PACKAGE= ssh
CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
SRCS+= ssh_namespace.h
diff --git a/secure/usr.bin/sftp/Makefile b/secure/usr.bin/sftp/Makefile
index 9cea9fe..4b1f24e 100644
--- a/secure/usr.bin/sftp/Makefile
+++ b/secure/usr.bin/sftp/Makefile
@@ -4,6 +4,7 @@
PROG= sftp
SRCS= sftp.c sftp-client.c sftp-common.c sftp-glob.c progressmeter.c
+PACKAGE= ssh
CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
SRCS+= ssh_namespace.h
diff --git a/secure/usr.bin/ssh-add/Makefile b/secure/usr.bin/ssh-add/Makefile
index 2f5d76e..70feb8b 100644
--- a/secure/usr.bin/ssh-add/Makefile
+++ b/secure/usr.bin/ssh-add/Makefile
@@ -4,6 +4,7 @@
PROG= ssh-add
SRCS+= ssh-add.c
+PACKAGE= ssh
CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
SRCS+= ssh_namespace.h
diff --git a/secure/usr.bin/ssh-agent/Makefile b/secure/usr.bin/ssh-agent/Makefile
index e79a02e..1e77d96 100644
--- a/secure/usr.bin/ssh-agent/Makefile
+++ b/secure/usr.bin/ssh-agent/Makefile
@@ -4,6 +4,7 @@
PROG= ssh-agent
SRCS= ssh-agent.c
+PACKAGE= ssh
CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
SRCS+= ssh_namespace.h
diff --git a/secure/usr.bin/ssh-keygen/Makefile b/secure/usr.bin/ssh-keygen/Makefile
index c3d6b2f..5cd6e2f 100644
--- a/secure/usr.bin/ssh-keygen/Makefile
+++ b/secure/usr.bin/ssh-keygen/Makefile
@@ -4,6 +4,7 @@
PROG= ssh-keygen
SRCS= ssh-keygen.c
+PACKAGE= ssh
CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
SRCS+= ssh_namespace.h
diff --git a/secure/usr.bin/ssh-keyscan/Makefile b/secure/usr.bin/ssh-keyscan/Makefile
index a2237a4..95b85e4 100644
--- a/secure/usr.bin/ssh-keyscan/Makefile
+++ b/secure/usr.bin/ssh-keyscan/Makefile
@@ -4,6 +4,7 @@
PROG= ssh-keyscan
SRCS= ssh-keyscan.c roaming_dummy.c
+PACKAGE= ssh
CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
SRCS+= ssh_namespace.h
diff --git a/secure/usr.bin/ssh/Makefile b/secure/usr.bin/ssh/Makefile
index cad6b30..38eab11 100644
--- a/secure/usr.bin/ssh/Makefile
+++ b/secure/usr.bin/ssh/Makefile
@@ -6,6 +6,7 @@ PROG= ssh
LINKS= ${BINDIR}/ssh ${BINDIR}/slogin
MAN= ssh.1 ssh_config.5
MLINKS= ssh.1 slogin.1
+PACKAGE= ssh
SRCS= ssh.c readconf.c clientloop.c sshtty.c \
sshconnect.c sshconnect1.c sshconnect2.c mux.c \
diff --git a/secure/usr.bin/tests/Makefile b/secure/usr.bin/tests/Makefile
index a0e63e5..609357e 100644
--- a/secure/usr.bin/tests/Makefile
+++ b/secure/usr.bin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/secure/usr.sbin/sshd/Makefile b/secure/usr.sbin/sshd/Makefile
index debe256..c9fd159 100644
--- a/secure/usr.sbin/sshd/Makefile
+++ b/secure/usr.sbin/sshd/Makefile
@@ -17,6 +17,7 @@ SRCS= sshd.c auth-rhosts.c auth-passwd.c auth-rsa.c auth-rh-rsa.c \
roaming_common.c roaming_serv.c \
sandbox-null.c sandbox-rlimit.c sandbox-systrace.c sandbox-darwin.c \
sandbox-seccomp-filter.c sandbox-capsicum.c
+PACKAGE= ssh
# gss-genr.c really belongs in libssh; see src/secure/lib/libssh/Makefile
SRCS+= gss-genr.c
diff --git a/secure/usr.sbin/tests/Makefile b/secure/usr.sbin/tests/Makefile
index a0e63e5..609357e 100644
--- a/secure/usr.sbin/tests/Makefile
+++ b/secure/usr.sbin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/share/examples/Makefile b/share/examples/Makefile
index 2484aff..c71604e 100644
--- a/share/examples/Makefile
+++ b/share/examples/Makefile
@@ -210,6 +210,7 @@ XFILES+= libusb20/Makefile \
.if ${MK_BHYVE} != "no"
LDIRS+= bhyve
XFILES+= bhyve/vmrun.sh
+PACKAGE_bhyve/vmrun.sh= bhyve
.endif
.endif
@@ -230,7 +231,7 @@ copies:
mtree -deU ${MTREE_FOLLOWS_SYMLINKS} \
-f ${.CURDIR}/../../etc/mtree/BSD.usr.dist -p ${DESTDIR}/usr
.for file in ${XFILES}
- ${INSTALL} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} \
+ ${INSTALL} -T package=${PACKAGE_${file}:Uruntime} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} \
${.CURDIR}/${file} ${DESTDIR}${BINDIR}/${file}
.endfor
diff --git a/share/examples/tests/Makefile b/share/examples/tests/Makefile
index a091b2d..c543aa3 100644
--- a/share/examples/tests/Makefile
+++ b/share/examples/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
SUBDIR= tests
.PATH: ${SRCTOP}/tests
diff --git a/share/examples/tests/tests/Makefile b/share/examples/tests/tests/Makefile
index 9f7b5a4..c417531 100644
--- a/share/examples/tests/tests/Makefile
+++ b/share/examples/tests/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
# Directory into which the Kyuafile provided by this directory will be
# installed.
#
diff --git a/share/examples/tests/tests/atf/Makefile b/share/examples/tests/tests/atf/Makefile
index c7bd46f..ef96dcb 100644
--- a/share/examples/tests/tests/atf/Makefile
+++ b/share/examples/tests/tests/atf/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
# Directory into which the Kyuafile provided by this directory will be
# installed.
#
diff --git a/share/examples/tests/tests/plain/Makefile b/share/examples/tests/tests/plain/Makefile
index 7348c5a..0b82397 100644
--- a/share/examples/tests/tests/plain/Makefile
+++ b/share/examples/tests/tests/plain/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
# Directory into which the Kyuafile provided by this directory will be
# installed.
#
diff --git a/share/man/man1/Makefile b/share/man/man1/Makefile
index 1b37c4b..ed75177 100644
--- a/share/man/man1/Makefile
+++ b/share/man/man1/Makefile
@@ -5,6 +5,8 @@
MAN= builtin.1 intro.1
+PACKAGE=runtime-manuals
+
.if ${MK_TESTS} != "no"
ATF= ${.CURDIR}/../../../contrib/atf
.PATH: ${ATF}/doc
diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile
index 3735870..2a3c12a 100644
--- a/share/man/man3/Makefile
+++ b/share/man/man3/Makefile
@@ -3,6 +3,8 @@
.include <src.opts.mk>
+PACKAGE=runtime-manuals
+
MAN= assert.3 \
ATOMIC_VAR_INIT.3 \
bitstring.3 \
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 2508da0..3d87773 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -3,6 +3,8 @@
.include <src.opts.mk>
+PACKAGE=runtime-manuals
+
MAN= aac.4 \
aacraid.4 \
acpi.4 \
diff --git a/share/man/man4/man4.arm/Makefile b/share/man/man4/man4.arm/Makefile
index 0e5b576..696d2c1 100644
--- a/share/man/man4/man4.arm/Makefile
+++ b/share/man/man4/man4.arm/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+PACKAGE=runtime-manuals
+
MAN= cgem.4 \
devcfg.4 \
mge.4 \
diff --git a/share/man/man4/man4.i386/Makefile b/share/man/man4/man4.i386/Makefile
index 974eec0..7b25eca 100644
--- a/share/man/man4/man4.i386/Makefile
+++ b/share/man/man4/man4.i386/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+PACKAGE=runtime-manuals
+
MAN= aic.4 \
apm.4 \
ce.4 \
diff --git a/share/man/man4/man4.powerpc/Makefile b/share/man/man4/man4.powerpc/Makefile
index 2b5ec8e..01d5a46 100644
--- a/share/man/man4/man4.powerpc/Makefile
+++ b/share/man/man4/man4.powerpc/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+PACKAGE=runtime-manuals
+
MAN= adb.4 \
akbd.4 \
abtn.4 \
diff --git a/share/man/man4/man4.sparc64/Makefile b/share/man/man4/man4.sparc64/Makefile
index 06d99c0..39ae515 100644
--- a/share/man/man4/man4.sparc64/Makefile
+++ b/share/man/man4/man4.sparc64/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+PACKAGE=runtime-manuals
+
MAN= auxio.4 \
central.4 \
clkbrd.4 \
diff --git a/share/man/man5/Makefile b/share/man/man5/Makefile
index 1ead7c6..108397d 100644
--- a/share/man/man5/Makefile
+++ b/share/man/man5/Makefile
@@ -3,6 +3,8 @@
.include <src.opts.mk>
+PACKAGE=runtime-manuals
+
#MISSING: dump.5 plot.5
MAN= acct.5 \
ar.5 \
diff --git a/share/man/man6/Makefile b/share/man/man6/Makefile
index be6547e..dbf4b14 100644
--- a/share/man/man6/Makefile
+++ b/share/man/man6/Makefile
@@ -2,4 +2,6 @@
MAN= intro.6
+PACKAGE=runtime-manuals
+
.include <bsd.prog.mk>
diff --git a/share/man/man7/Makefile b/share/man/man7/Makefile
index 22d29ae..54f14f5 100644
--- a/share/man/man7/Makefile
+++ b/share/man/man7/Makefile
@@ -3,6 +3,8 @@
.include <src.opts.mk>
+PACKAGE=runtime-manuals
+
#MISSING: eqnchar.7 ms.7 term.7
MAN= adding_user.7 \
ascii.7 \
diff --git a/share/man/man8/Makefile b/share/man/man8/Makefile
index dc119b5..54b1314 100644
--- a/share/man/man8/Makefile
+++ b/share/man/man8/Makefile
@@ -1,6 +1,8 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# $FreeBSD$
+PACKAGE=runtime-manuals
+
MAN= crash.8 \
diskless.8 \
intro.8 \
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index 66c16d7..fa768f5 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -2,6 +2,8 @@
.include <src.opts.mk>
+PACKAGE=runtime-manuals
+
MAN= accept_filter.9 \
accf_data.9 \
accf_dns.9 \
diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk
index ddf7130..5b88ae5 100644
--- a/share/mk/bsd.doc.mk
+++ b/share/mk/bsd.doc.mk
@@ -81,6 +81,13 @@ TRFLAGS+= -I${.CURDIR}
TRFLAGS+= -t
.endif
+.if defined(NO_ROOT)
+.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
+TAGS+= package=${PACKAGE:Uruntime}
+.endif
+TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
+.endif
+
DCOMPRESS_EXT?= ${COMPRESS_EXT}
DCOMPRESS_CMD?= ${COMPRESS_CMD}
.for _dev in ${PRINTERDEVICE:Mhtml}
@@ -137,11 +144,11 @@ CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \
realinstall:
.if ${PRINTERDEVICE:Mhtml}
cd ${SRCDIR}; \
- ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}/
.endif
.for _dev in ${PRINTERDEVICE:Nhtml}
- ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}/
.endfor
diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk
index d22f196..d4fd509 100644
--- a/share/mk/bsd.files.mk
+++ b/share/mk/bsd.files.mk
@@ -35,6 +35,14 @@ STAGE_SETS+= ${group}
.endif
STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
+.if defined(NO_ROOT)
+.if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
+${group}TAGS+= package=${${group}PACKAGE:Uruntime}
+.endif
+${group}TAG_ARGS= -T ${${group}TAGS:[*]:S/ /,/g}
+.endif
+
+
_${group}FILES=
.for file in ${${group}}
.if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
@@ -59,7 +67,7 @@ stage_as.${file:T}: ${file}
installfiles-${group}: _${group}INS_${file:T}
_${group}INS_${file:T}: ${file}
- ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${.ALLSRC:T}} \
-g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
${.ALLSRC} \
${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
@@ -73,11 +81,11 @@ stage_files.${group}: ${_${group}FILES}
installfiles-${group}: _${group}INS
_${group}INS: ${_${group}FILES}
.if defined(${group}NAME)
- ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
-m ${${group}MODE} ${.ALLSRC} \
${DESTDIR}${${group}DIR}/${${group}NAME}
.else
- ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
-m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}/
.endif
.endif
diff --git a/share/mk/bsd.incs.mk b/share/mk/bsd.incs.mk
index 42b9e42..c5c852a 100644
--- a/share/mk/bsd.incs.mk
+++ b/share/mk/bsd.incs.mk
@@ -10,6 +10,13 @@ INCSGROUPS?= INCS
_INCSGROUPS= ${INCSGROUPS:C,[/*],_,g}
+.if defined(NO_ROOT)
+.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
+TAGS+= package=${PACKAGE:Uruntime}
+.endif
+TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
+.endif
+
.if !target(buildincludes)
.for group in ${_INCSGROUPS}
buildincludes: ${${group}}
@@ -70,10 +77,10 @@ stage_includes: stage_files.${group}
installincludes: _${group}INS
_${group}INS: ${_${group}INCS}
.if defined(${group}NAME)
- ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
.else
- ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
${.ALLSRC} ${DESTDIR}${${group}DIR}/
.endif
.endif
@@ -84,7 +91,8 @@ _${group}INS: ${_${group}INCS}
.if defined(INCSLINKS) && !empty(INCSLINKS)
installincludes:
.for s t in ${INCSLINKS}
- ${INSTALL_SYMLINK} ${s} ${DESTDIR}${t}
+ @${ECHO} "${DESTDIR}${t} -> ${s}" ; \
+ ${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${s} ${DESTDIR}${t}
.endfor
.endif
.endif # !target(installincludes)
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 51fb828..29a95e5 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -51,6 +51,17 @@ CTFFLAGS+= -g
STRIP?= -s
.endif
+.if ${SHLIBDIR:M*lib32*}
+TAGS+= lib32
+.endif
+
+.if defined(NO_ROOT)
+.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
+TAGS+= package=${PACKAGE:Uruntime}
+.endif
+TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
+.endif
+
.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \
empty(DEBUG_FLAGS:M-gdwarf*)
SHARED_CFLAGS+= -g
@@ -248,7 +259,7 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
@${ECHO} building shared library ${SHLIB_NAME}
@rm -f ${SHLIB_NAME} ${SHLIB_LINK}
.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld)
- @${INSTALL_SYMLINK} ${SHLIB_NAME} ${SHLIB_LINK}
+ @${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${SHLIB_LINK}
.endif
${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
-o ${.TARGET} -Wl,-soname,${SONAME} \
@@ -341,28 +352,28 @@ realinstall: _libinstall
.ORDER: beforeinstall _libinstall
_libinstall:
.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
- ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}/
.endif
.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
- ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},profile} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}_p.a ${DESTDIR}${_LIBDIR}/
.endif
.if defined(SHLIB_NAME)
- ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/
.if ${MK_DEBUG_FILES} != "no"
.if defined(DEBUGMKDIR)
- ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR}/
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -d ${DESTDIR}${DEBUGFILEDIR}/
.endif
- ${INSTALL} -T debug -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \
${_INSTALLFLAGS} \
${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}/
.endif
.if defined(SHLIB_LINK)
.if commands(${SHLIB_LINK:R}.ld)
- ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \
${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
.for _SHLIB_LINK_LINK in ${SHLIB_LDSCRIPT_LINKS}
@@ -370,10 +381,20 @@ _libinstall:
.endfor
.else
.if ${_SHLIBDIR} == ${_LIBDIR}
- ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
+.if ${SHLIB_LINK:Mlib*}
+ ${INSTALL_RSYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
.else
- ${INSTALL_RSYMLINK} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
+ ${INSTALL_RSYMLINK} ${TAG_ARGS} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
+.endif
+.else
+.if ${SHLIB_LINK:Mlib*}
+ ${INSTALL_RSYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
+ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
+.else
+ ${INSTALL_RSYMLINK} ${TAG_ARGS} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
+ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
+.endif
.if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME})
-chflags noschg ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
@@ -383,11 +404,11 @@ _libinstall:
.endif # SHLIB_LINK
.endif # SHIB_NAME
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
- ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/
.endif
.if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
- ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}/
.endif
.endif # !defined(INTERNALLIB)
diff --git a/share/mk/bsd.links.mk b/share/mk/bsd.links.mk
index 9e24af8..e69f3a0 100644
--- a/share/mk/bsd.links.mk
+++ b/share/mk/bsd.links.mk
@@ -4,12 +4,21 @@
.error bsd.links.mk cannot be included directly.
.endif
+.if defined(NO_ROOT)
+.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
+TAGS+= package=${PACKAGE}
+.endif
+TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
+.endif
+
afterinstall: _installlinks
.ORDER: realinstall _installlinks
_installlinks:
.for s t in ${LINKS}
- ${INSTALL_LINK} ${DESTDIR}${s} ${DESTDIR}${t}
+ @${ECHO} "${t} -> ${s}" ;\
+ ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${s} ${DESTDIR}${t}
.endfor
.for s t in ${SYMLINKS}
- ${INSTALL_SYMLINK} ${s} ${DESTDIR}${t}
+ @${ECHO} "${t} -> ${s}" ;\
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ${s} ${DESTDIR}/${t}
.endfor
diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
index 6d91545..eca0139 100644
--- a/share/mk/bsd.man.mk
+++ b/share/mk/bsd.man.mk
@@ -50,7 +50,7 @@
.error bsd.man.mk cannot be included directly.
.endif
-MINSTALL?= ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
+MINSTALL?= ${INSTALL} ${TAG_ARGS} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
CATDIR= ${MANDIR:H:S/$/\/cat/}
CATEXT= .cat
@@ -62,6 +62,7 @@ MCOMPRESS_EXT?= ${COMPRESS_EXT}
SECTIONS= 1 2 3 4 5 6 7 8 9
.SUFFIXES: ${SECTIONS:S/^/./g}
+
# Backwards compatibility.
.if !defined(MAN)
.for __sect in ${SECTIONS}
@@ -226,7 +227,7 @@ maninstall: ${MAN}
.endif
.for l t in ${_MANLINKS}
rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \
- ${INSTALL_LINK} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT}
+ ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT}
.endfor
manlint:
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index 4287ff3..30c37ca 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -47,6 +47,13 @@ CTFFLAGS+= -g
STRIP?= -s
.endif
+.if defined(NO_ROOT)
+.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
+TAGS+= package=${PACKAGE:Uruntime}
+.endif
+TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
+.endif
+
.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
LDFLAGS+= -static
.endif
@@ -206,13 +213,13 @@ realinstall: _proginstall
.ORDER: beforeinstall _proginstall
_proginstall:
.if defined(PROG)
- ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
.if ${MK_DEBUG_FILES} != "no"
.if defined(DEBUGMKDIR)
- ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR}/
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -d ${DESTDIR}${DEBUGFILEDIR}/
.endif
- ${INSTALL} -T debug -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \
${PROGNAME}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME}.debug
.endif
.endif
@@ -244,7 +251,7 @@ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
STAGE_AS_${script:T}= ${SCRIPTSDIR_${script:T}}/${SCRIPTSNAME_${script:T}}
_scriptsinstall: _SCRIPTSINS_${script:T}
_SCRIPTSINS_${script:T}: ${script}
- ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ ${INSTALL} ${TAG_ARGS} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
-g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
${.ALLSRC} \
${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk
index f87f5dc..97240cc 100644
--- a/share/mk/bsd.test.mk
+++ b/share/mk/bsd.test.mk
@@ -15,6 +15,7 @@ LOCALBASE?= /usr/local
# Tests install directory
TESTSDIR?= ${TESTSBASE}/${RELDIR:H}
+PACKAGE= tests
# List of subdirectories containing tests into which to recurse. This has the
# same semantics as SUBDIR at build-time. However, the directories listed here
diff --git a/share/sendmail/Makefile b/share/sendmail/Makefile
index a548b63..0e1a27d 100644
--- a/share/sendmail/Makefile
+++ b/share/sendmail/Makefile
@@ -4,6 +4,7 @@
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
CFDIR= cf
+CFPACKAGE= sendmail
CFDIRS!= (cd ${SENDMAIL_DIR}; find -L ${CFDIR} \( \( -name CVS -o -name .svn \) -prune \) -o -type d -print)
CFFILES!= (cd ${SENDMAIL_DIR}; find -L ${CFDIR} \( \( -name CVS -o -name .svn \) -prune \) -o -type f -print)
diff --git a/share/syscons/Makefile.inc b/share/syscons/Makefile.inc
new file mode 100644
index 0000000..59bf625
--- /dev/null
+++ b/share/syscons/Makefile.inc
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+FILESPACKAGE= syscons
diff --git a/share/tests/Makefile b/share/tests/Makefile
index e070571..6448a41 100644
--- a/share/tests/Makefile
+++ b/share/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
TESTSDIR= ${TESTSBASE}/share
.PATH: ${SRCTOP}/tests
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 03ccc60..10b7ded 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -307,10 +307,10 @@ KERN_DEBUGDIR?= ${DEBUGDIR}
realinstall: _kmodinstall
.ORDER: beforeinstall _kmodinstall
_kmodinstall:
- ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
+ ${INSTALL} -T release -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}/
.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} != "no"
- ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
+ ${INSTALL} -T debug -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
${_INSTALLFLAGS} ${PROG}.debug ${DESTDIR}${KERN_DEBUGDIR}${KMODDIR}/
.endif
diff --git a/sys/modules/tests/callout_test/Makefile b/sys/modules/tests/callout_test/Makefile
index 4781488..eadcadc 100644
--- a/sys/modules/tests/callout_test/Makefile
+++ b/sys/modules/tests/callout_test/Makefile
@@ -2,6 +2,10 @@
# $FreeBSD$
#
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
.PATH: ${.CURDIR}/../../../tests/callout_test
KMOD= callout_test
diff --git a/sys/modules/tests/framework/Makefile b/sys/modules/tests/framework/Makefile
index f5f608f..c56838d 100644
--- a/sys/modules/tests/framework/Makefile
+++ b/sys/modules/tests/framework/Makefile
@@ -2,6 +2,10 @@
# $FreeBSD$
#
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
.PATH: ${.CURDIR}/../../../tests/framework
KMOD= kern_testfrwk
diff --git a/tests/Makefile b/tests/Makefile
index 30b9692..ba743ee 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
SUBDIR+= etc
SUBDIR+= sys
SUBDIR_PARALLEL=
diff --git a/tests/etc/Makefile b/tests/etc/Makefile
index 1e49666..7e73a48 100644
--- a/tests/etc/Makefile
+++ b/tests/etc/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
TESTSDIR= ${TESTSBASE}/etc
.PATH: ${SRCTOP}/tests
diff --git a/tests/etc/rc.d/Makefile b/tests/etc/rc.d/Makefile
index 368e8f4..3b946a3 100644
--- a/tests/etc/rc.d/Makefile
+++ b/tests/etc/rc.d/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/etc/rc.d
ATF_TESTS_SH+= routing_test
diff --git a/tests/sys/Makefile b/tests/sys/Makefile
index 36bdde0..40a5e64 100644
--- a/tests/sys/Makefile
+++ b/tests/sys/Makefile
@@ -2,6 +2,9 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys
TESTS_SUBDIRS+= acl
diff --git a/tests/sys/acl/Makefile b/tests/sys/acl/Makefile
index d101088..7db6682 100644
--- a/tests/sys/acl/Makefile
+++ b/tests/sys/acl/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/acl
BINDIR= ${TESTSDIR}
diff --git a/tests/sys/aio/Makefile b/tests/sys/aio/Makefile
index 766d9b0..0003b84 100644
--- a/tests/sys/aio/Makefile
+++ b/tests/sys/aio/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/aio
PLAIN_TESTS_C+= aio_kqueue_test
diff --git a/tests/sys/fifo/Makefile b/tests/sys/fifo/Makefile
index 602bf1e..750d5db 100644
--- a/tests/sys/fifo/Makefile
+++ b/tests/sys/fifo/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/fifo
PLAIN_TESTS_C+= fifo_create
diff --git a/tests/sys/file/Makefile b/tests/sys/file/Makefile
index ed2d2c4..0b3c0fc 100644
--- a/tests/sys/file/Makefile
+++ b/tests/sys/file/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/file
BINDIR= ${TESTSDIR}
diff --git a/tests/sys/geom/Makefile b/tests/sys/geom/Makefile
index bf8604d..e6ecc83 100644
--- a/tests/sys/geom/Makefile
+++ b/tests/sys/geom/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom
TESTS_SUBDIRS+= class
diff --git a/tests/sys/geom/class/Makefile b/tests/sys/geom/class/Makefile
index c705616..d4f6168 100644
--- a/tests/sys/geom/class/Makefile
+++ b/tests/sys/geom/class/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class
TESTS_SUBDIRS+= concat
diff --git a/tests/sys/geom/class/concat/Makefile b/tests/sys/geom/class/concat/Makefile
index 5659b5d..cd1eb61 100644
--- a/tests/sys/geom/class/concat/Makefile
+++ b/tests/sys/geom/class/concat/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
diff --git a/tests/sys/geom/class/eli/Makefile b/tests/sys/geom/class/eli/Makefile
index 8f4ca60..65ee192 100644
--- a/tests/sys/geom/class/eli/Makefile
+++ b/tests/sys/geom/class/eli/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= attach_d_test
TAP_TESTS_SH+= configure_b_B_test
diff --git a/tests/sys/geom/class/gate/Makefile b/tests/sys/geom/class/gate/Makefile
index 11ceb94..25bcc2a 100644
--- a/tests/sys/geom/class/gate/Makefile
+++ b/tests/sys/geom/class/gate/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
diff --git a/tests/sys/geom/class/mirror/Makefile b/tests/sys/geom/class/mirror/Makefile
index 931f7d0..c2f732c 100644
--- a/tests/sys/geom/class/mirror/Makefile
+++ b/tests/sys/geom/class/mirror/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
diff --git a/tests/sys/geom/class/nop/Makefile b/tests/sys/geom/class/nop/Makefile
index 5659b5d..cd1eb61 100644
--- a/tests/sys/geom/class/nop/Makefile
+++ b/tests/sys/geom/class/nop/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
diff --git a/tests/sys/geom/class/raid3/Makefile b/tests/sys/geom/class/raid3/Makefile
index 526c175..3981ec7 100644
--- a/tests/sys/geom/class/raid3/Makefile
+++ b/tests/sys/geom/class/raid3/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
diff --git a/tests/sys/geom/class/shsec/Makefile b/tests/sys/geom/class/shsec/Makefile
index 5659b5d..cd1eb61 100644
--- a/tests/sys/geom/class/shsec/Makefile
+++ b/tests/sys/geom/class/shsec/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
diff --git a/tests/sys/geom/class/stripe/Makefile b/tests/sys/geom/class/stripe/Makefile
index 5659b5d..cd1eb61 100644
--- a/tests/sys/geom/class/stripe/Makefile
+++ b/tests/sys/geom/class/stripe/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+TESTS+= ${FILES}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
diff --git a/tests/sys/geom/class/uzip/Makefile b/tests/sys/geom/class/uzip/Makefile
index b962406..91c874e 100644
--- a/tests/sys/geom/class/uzip/Makefile
+++ b/tests/sys/geom/class/uzip/Makefile
@@ -4,6 +4,9 @@
# Regression test for geom_uzip.
#
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
IMAGE= 1.img
@@ -29,9 +32,11 @@ FILESNAME_conf.sh= conf.sh
FILES+= ${UZIMAGE}
FILESDIR= ${TESTSDIR}
-FILESGROUPS= FILES etalon
+FILESGROUPS+= FILES etalon
etalon+= etalon/etalon.txt
etalonDIR= ${TESTSDIR}/etalon
+FILESPACKAGE= ${PACKAGE}
+etalonPACKAGE= ${PACKAGE}
TAP_TESTS_SH+= 1_test
diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile
index c9a7cfd..f38cc58 100644
--- a/tests/sys/kern/Makefile
+++ b/tests/sys/kern/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/kernel
TESTSDIR= ${TESTSBASE}/sys/kern
diff --git a/tests/sys/kern/acct/Makefile b/tests/sys/kern/acct/Makefile
index ca3df4c..3a9a7ec 100644
--- a/tests/sys/kern/acct/Makefile
+++ b/tests/sys/kern/acct/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/kern/acct
ATF_TESTS_C= acct_test
diff --git a/tests/sys/kern/execve/Makefile b/tests/sys/kern/execve/Makefile
index 82c5d4b..a029b8f 100644
--- a/tests/sys/kern/execve/Makefile
+++ b/tests/sys/kern/execve/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/kern/execve
BINDIR= ${TESTSDIR}
diff --git a/tests/sys/kern/pipe/Makefile b/tests/sys/kern/pipe/Makefile
index bcd2d07..bcc61b4 100644
--- a/tests/sys/kern/pipe/Makefile
+++ b/tests/sys/kern/pipe/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/kern/pipe
PLAIN_TESTS_C+= big_pipe_test
diff --git a/tests/sys/kqueue/Makefile b/tests/sys/kqueue/Makefile
index 43277ca..2ec462a 100644
--- a/tests/sys/kqueue/Makefile
+++ b/tests/sys/kqueue/Makefile
@@ -6,6 +6,9 @@
# libkqueue and test suite by Mark Heily <mark@heily.com>
#
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TAP_TESTS_SH= kqueue_test
TESTSDIR= ${TESTSBASE}/sys/kqueue
diff --git a/tests/sys/mac/Makefile b/tests/sys/mac/Makefile
index ae2c491..db91895 100644
--- a/tests/sys/mac/Makefile
+++ b/tests/sys/mac/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/mac
TESTS_SUBDIRS+= bsdextended
diff --git a/tests/sys/mac/bsdextended/Makefile b/tests/sys/mac/bsdextended/Makefile
index 9d0b6f6..8fdee52 100644
--- a/tests/sys/mac/bsdextended/Makefile
+++ b/tests/sys/mac/bsdextended/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/mac/bsdextended
TAP_TESTS_C+= ugidfw_test
diff --git a/tests/sys/mac/portacl/Makefile b/tests/sys/mac/portacl/Makefile
index 129d486..b894c8c 100644
--- a/tests/sys/mac/portacl/Makefile
+++ b/tests/sys/mac/portacl/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/mac/portacl
BINDIR= ${TESTSDIR}
diff --git a/tests/sys/mqueue/Makefile b/tests/sys/mqueue/Makefile
index ce5033c..6ccd275 100644
--- a/tests/sys/mqueue/Makefile
+++ b/tests/sys/mqueue/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/mqueue
ATF_TESTS_SH= mqueue_test
diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile
index 3f65fb6..4fe2922 100644
--- a/tests/sys/netinet/Makefile
+++ b/tests/sys/netinet/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/netinet
BINDIR= ${TESTSDIR}
diff --git a/tests/sys/opencrypto/Makefile b/tests/sys/opencrypto/Makefile
index 1696920..96cc86b 100644
--- a/tests/sys/opencrypto/Makefile
+++ b/tests/sys/opencrypto/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/opencrypto
BINDIR= ${TESTSDIR}
diff --git a/tests/sys/pjdfstest/Makefile b/tests/sys/pjdfstest/Makefile
index a398d39..65f562a 100644
--- a/tests/sys/pjdfstest/Makefile
+++ b/tests/sys/pjdfstest/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
SUBDIR+= pjdfstest
SUBDIR+= tests
SUBDIR_PARALLEL=
diff --git a/tests/sys/pjdfstest/pjdfstest/Makefile b/tests/sys/pjdfstest/pjdfstest/Makefile
index 29bee82..8ae74e7 100644
--- a/tests/sys/pjdfstest/pjdfstest/Makefile
+++ b/tests/sys/pjdfstest/pjdfstest/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TOP= ${.CURDIR:H:H:H:H}
.PATH: ${TOP}/contrib/pjdfstest
diff --git a/tests/sys/pjdfstest/tests/Makefile b/tests/sys/pjdfstest/tests/Makefile
index 95b4bbe..951ac9a 100644
--- a/tests/sys/pjdfstest/tests/Makefile
+++ b/tests/sys/pjdfstest/tests/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
PJDFSTEST_SRCDIR= ${SRCTOP}/contrib/pjdfstest
TESTSDIR= ${TESTSBASE}/sys/pjdfstest
diff --git a/tests/sys/pjdfstest/tests/chflags/Makefile b/tests/sys/pjdfstest/tests/chflags/Makefile
index 3b6a526..2865f9d 100644
--- a/tests/sys/pjdfstest/tests/chflags/Makefile
+++ b/tests/sys/pjdfstest/tests/chflags/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/chmod/Makefile b/tests/sys/pjdfstest/tests/chmod/Makefile
index cc0a3bb..10227c1 100644
--- a/tests/sys/pjdfstest/tests/chmod/Makefile
+++ b/tests/sys/pjdfstest/tests/chmod/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/chown/Makefile b/tests/sys/pjdfstest/tests/chown/Makefile
index 665b653..f8fa004 100644
--- a/tests/sys/pjdfstest/tests/chown/Makefile
+++ b/tests/sys/pjdfstest/tests/chown/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/ftruncate/Makefile b/tests/sys/pjdfstest/tests/ftruncate/Makefile
index da2ce58..67570a8 100644
--- a/tests/sys/pjdfstest/tests/ftruncate/Makefile
+++ b/tests/sys/pjdfstest/tests/ftruncate/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/granular/Makefile b/tests/sys/pjdfstest/tests/granular/Makefile
index 3f935e4..4f0d071 100644
--- a/tests/sys/pjdfstest/tests/granular/Makefile
+++ b/tests/sys/pjdfstest/tests/granular/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/link/Makefile b/tests/sys/pjdfstest/tests/link/Makefile
index 14c7525..af74c4a 100644
--- a/tests/sys/pjdfstest/tests/link/Makefile
+++ b/tests/sys/pjdfstest/tests/link/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/mkdir/Makefile b/tests/sys/pjdfstest/tests/mkdir/Makefile
index cc0a3bb..10227c1 100644
--- a/tests/sys/pjdfstest/tests/mkdir/Makefile
+++ b/tests/sys/pjdfstest/tests/mkdir/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/mkfifo/Makefile b/tests/sys/pjdfstest/tests/mkfifo/Makefile
index cc0a3bb..10227c1 100644
--- a/tests/sys/pjdfstest/tests/mkfifo/Makefile
+++ b/tests/sys/pjdfstest/tests/mkfifo/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/mknod/Makefile b/tests/sys/pjdfstest/tests/mknod/Makefile
index 1eaeaa0..fd41522 100644
--- a/tests/sys/pjdfstest/tests/mknod/Makefile
+++ b/tests/sys/pjdfstest/tests/mknod/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/open/Makefile b/tests/sys/pjdfstest/tests/open/Makefile
index bd2f7b5..c66cc3e 100644
--- a/tests/sys/pjdfstest/tests/open/Makefile
+++ b/tests/sys/pjdfstest/tests/open/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/rename/Makefile b/tests/sys/pjdfstest/tests/rename/Makefile
index 7eada04..86984d9 100644
--- a/tests/sys/pjdfstest/tests/rename/Makefile
+++ b/tests/sys/pjdfstest/tests/rename/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/rmdir/Makefile b/tests/sys/pjdfstest/tests/rmdir/Makefile
index 301e4e5..31fd8ba 100644
--- a/tests/sys/pjdfstest/tests/rmdir/Makefile
+++ b/tests/sys/pjdfstest/tests/rmdir/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/symlink/Makefile b/tests/sys/pjdfstest/tests/symlink/Makefile
index cc0a3bb..10227c1 100644
--- a/tests/sys/pjdfstest/tests/symlink/Makefile
+++ b/tests/sys/pjdfstest/tests/symlink/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/truncate/Makefile b/tests/sys/pjdfstest/tests/truncate/Makefile
index da2ce58..67570a8 100644
--- a/tests/sys/pjdfstest/tests/truncate/Makefile
+++ b/tests/sys/pjdfstest/tests/truncate/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/pjdfstest/tests/unlink/Makefile b/tests/sys/pjdfstest/tests/unlink/Makefile
index 3b6a526..2865f9d 100644
--- a/tests/sys/pjdfstest/tests/unlink/Makefile
+++ b/tests/sys/pjdfstest/tests/unlink/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= 00
TAP_TESTS_SH+= 01
TAP_TESTS_SH+= 02
diff --git a/tests/sys/posixshm/Makefile b/tests/sys/posixshm/Makefile
index 2acdfa4..aab71d1 100644
--- a/tests/sys/posixshm/Makefile
+++ b/tests/sys/posixshm/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/posixshm
ATF_TESTS_C+= posixshm_test
diff --git a/tests/sys/vfs/Makefile b/tests/sys/vfs/Makefile
index 48f5226..09e4518 100644
--- a/tests/sys/vfs/Makefile
+++ b/tests/sys/vfs/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/vfs
PLAIN_TESTS_SH+= trailing_slash
diff --git a/tests/sys/vm/Makefile b/tests/sys/vm/Makefile
index 08fbb21..9d1be8b 100644
--- a/tests/sys/vm/Makefile
+++ b/tests/sys/vm/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/sys/vm
ATF_TESTS_C+= mmap_test
diff --git a/usr.bin/apply/tests/Makefile b/usr.bin/apply/tests/Makefile
index 5ff6c28..6348f89 100644
--- a/usr.bin/apply/tests/Makefile
+++ b/usr.bin/apply/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/at/Makefile.inc b/usr.bin/at/Makefile.inc
index 2dab559..3bd4373 100644
--- a/usr.bin/at/Makefile.inc
+++ b/usr.bin/at/Makefile.inc
@@ -10,6 +10,7 @@ DAEMON_UID=1
DEFAULT_BATCH_QUEUE=E
DEFAULT_AT_QUEUE=c
PERM_PATH=/var/at
+PACKAGE= at
CFLAGS += -DATJOB_DIR=\"$(ATJOB_DIR)/\" \
-DLFILE=\"$(ATJOB_DIR)/$(LOCKFILE)\" \
diff --git a/usr.bin/basename/tests/Makefile b/usr.bin/basename/tests/Makefile
index bad7b28..cada2f7 100644
--- a/usr.bin/basename/tests/Makefile
+++ b/usr.bin/basename/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= basename_test
.include <netbsd-tests.test.mk>
diff --git a/usr.bin/bmake/tests/Makefile b/usr.bin/bmake/tests/Makefile
index e225034..ee3dcf2 100644
--- a/usr.bin/bmake/tests/Makefile
+++ b/usr.bin/bmake/tests/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/bmake/tests/archives/Makefile b/usr.bin/bmake/tests/archives/Makefile
index f80ffc2..c8914b9 100644
--- a/usr.bin/bmake/tests/archives/Makefile
+++ b/usr.bin/bmake/tests/archives/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/archives
TESTS_SUBDIRS= fmt_44bsd fmt_44bsd_mod fmt_oldbsd
diff --git a/usr.bin/bmake/tests/archives/fmt_44bsd/Makefile b/usr.bin/bmake/tests/archives/fmt_44bsd/Makefile
index 15389c8..5ef093f 100644
--- a/usr.bin/bmake/tests/archives/fmt_44bsd/Makefile
+++ b/usr.bin/bmake/tests/archives/fmt_44bsd/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/archives/fmt_44bsd
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/archives/fmt_44bsd_mod/Makefile b/usr.bin/bmake/tests/archives/fmt_44bsd_mod/Makefile
index 1d2f6e2..0b9db19 100644
--- a/usr.bin/bmake/tests/archives/fmt_44bsd_mod/Makefile
+++ b/usr.bin/bmake/tests/archives/fmt_44bsd_mod/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/archives/fmt_44bsd_mod
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/archives/fmt_oldbsd/Makefile b/usr.bin/bmake/tests/archives/fmt_oldbsd/Makefile
index 2a96124..b76bdc1 100644
--- a/usr.bin/bmake/tests/archives/fmt_oldbsd/Makefile
+++ b/usr.bin/bmake/tests/archives/fmt_oldbsd/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/archives/fmt_oldbsd
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/basic/Makefile b/usr.bin/bmake/tests/basic/Makefile
index 56dfb33..1164a44 100644
--- a/usr.bin/bmake/tests/basic/Makefile
+++ b/usr.bin/bmake/tests/basic/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/basic
TESTS_SUBDIRS= t0 t1 t2 t3
diff --git a/usr.bin/bmake/tests/basic/t0/Makefile b/usr.bin/bmake/tests/basic/t0/Makefile
index 1235659..d1ee84d 100644
--- a/usr.bin/bmake/tests/basic/t0/Makefile
+++ b/usr.bin/bmake/tests/basic/t0/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/basic/t0
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/basic/t1/Makefile b/usr.bin/bmake/tests/basic/t1/Makefile
index 732dc65..3faeffa 100644
--- a/usr.bin/bmake/tests/basic/t1/Makefile
+++ b/usr.bin/bmake/tests/basic/t1/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/basic/t1
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/basic/t2/Makefile b/usr.bin/bmake/tests/basic/t2/Makefile
index 58c36ff..6d7b6b4 100644
--- a/usr.bin/bmake/tests/basic/t2/Makefile
+++ b/usr.bin/bmake/tests/basic/t2/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/basic/t2
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/basic/t3/Makefile b/usr.bin/bmake/tests/basic/t3/Makefile
index a173414..2b268e9 100644
--- a/usr.bin/bmake/tests/basic/t3/Makefile
+++ b/usr.bin/bmake/tests/basic/t3/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/basic/t3
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/execution/Makefile b/usr.bin/bmake/tests/execution/Makefile
index 2c91bbb..5b3bab7 100644
--- a/usr.bin/bmake/tests/execution/Makefile
+++ b/usr.bin/bmake/tests/execution/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/execution
TESTS_SUBDIRS= ellipsis empty joberr plus
diff --git a/usr.bin/bmake/tests/execution/ellipsis/Makefile b/usr.bin/bmake/tests/execution/ellipsis/Makefile
index 5629b4b..abc8b9e 100644
--- a/usr.bin/bmake/tests/execution/ellipsis/Makefile
+++ b/usr.bin/bmake/tests/execution/ellipsis/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/execution/ellipsis
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/execution/empty/Makefile b/usr.bin/bmake/tests/execution/empty/Makefile
index 6421b96..2828140 100644
--- a/usr.bin/bmake/tests/execution/empty/Makefile
+++ b/usr.bin/bmake/tests/execution/empty/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/execution/empty
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/execution/joberr/Makefile b/usr.bin/bmake/tests/execution/joberr/Makefile
index d183eb1..7056afd 100644
--- a/usr.bin/bmake/tests/execution/joberr/Makefile
+++ b/usr.bin/bmake/tests/execution/joberr/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/execution/joberr
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/execution/plus/Makefile b/usr.bin/bmake/tests/execution/plus/Makefile
index 8b489d5..c5e42bd 100644
--- a/usr.bin/bmake/tests/execution/plus/Makefile
+++ b/usr.bin/bmake/tests/execution/plus/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/execution/plus
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/shell/Makefile b/usr.bin/bmake/tests/shell/Makefile
index 13b570e..ca0c99f 100644
--- a/usr.bin/bmake/tests/shell/Makefile
+++ b/usr.bin/bmake/tests/shell/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/shell
TESTS_SUBDIRS= builtin meta path path_select replace select
diff --git a/usr.bin/bmake/tests/shell/builtin/Makefile b/usr.bin/bmake/tests/shell/builtin/Makefile
index cd458a9..713e825 100644
--- a/usr.bin/bmake/tests/shell/builtin/Makefile
+++ b/usr.bin/bmake/tests/shell/builtin/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/shell/builtin
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/shell/meta/Makefile b/usr.bin/bmake/tests/shell/meta/Makefile
index b342e79..4b14289 100644
--- a/usr.bin/bmake/tests/shell/meta/Makefile
+++ b/usr.bin/bmake/tests/shell/meta/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/shell/meta
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/shell/path/Makefile b/usr.bin/bmake/tests/shell/path/Makefile
index 5a83a1f..8b1ce86 100644
--- a/usr.bin/bmake/tests/shell/path/Makefile
+++ b/usr.bin/bmake/tests/shell/path/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/shell/path
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/shell/path_select/Makefile b/usr.bin/bmake/tests/shell/path_select/Makefile
index 1819f91..acc6339 100644
--- a/usr.bin/bmake/tests/shell/path_select/Makefile
+++ b/usr.bin/bmake/tests/shell/path_select/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/shell/path_select
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/shell/replace/Makefile b/usr.bin/bmake/tests/shell/replace/Makefile
index 0dae915..b0f21ab 100644
--- a/usr.bin/bmake/tests/shell/replace/Makefile
+++ b/usr.bin/bmake/tests/shell/replace/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/shell/replace
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/shell/select/Makefile b/usr.bin/bmake/tests/shell/select/Makefile
index 45e6d72..e627010 100644
--- a/usr.bin/bmake/tests/shell/select/Makefile
+++ b/usr.bin/bmake/tests/shell/select/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/shell/select
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/suffixes/Makefile b/usr.bin/bmake/tests/suffixes/Makefile
index 60ec86e..0839dfa 100644
--- a/usr.bin/bmake/tests/suffixes/Makefile
+++ b/usr.bin/bmake/tests/suffixes/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/suffixes
TESTS_SUBDIRS= basic src_wild1 src_wild2
diff --git a/usr.bin/bmake/tests/suffixes/basic/Makefile b/usr.bin/bmake/tests/suffixes/basic/Makefile
index 9ae720e..d917de0 100644
--- a/usr.bin/bmake/tests/suffixes/basic/Makefile
+++ b/usr.bin/bmake/tests/suffixes/basic/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/suffixes/basic
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/suffixes/src_wild1/Makefile b/usr.bin/bmake/tests/suffixes/src_wild1/Makefile
index 00be930..621ec60 100644
--- a/usr.bin/bmake/tests/suffixes/src_wild1/Makefile
+++ b/usr.bin/bmake/tests/suffixes/src_wild1/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/suffixes/src_wild1
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/suffixes/src_wild2/Makefile b/usr.bin/bmake/tests/suffixes/src_wild2/Makefile
index 34aad07..a1c6535 100644
--- a/usr.bin/bmake/tests/suffixes/src_wild2/Makefile
+++ b/usr.bin/bmake/tests/suffixes/src_wild2/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/suffixes/src_wild2
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/syntax/Makefile b/usr.bin/bmake/tests/syntax/Makefile
index 3cd89f8..2dd0df5 100644
--- a/usr.bin/bmake/tests/syntax/Makefile
+++ b/usr.bin/bmake/tests/syntax/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/syntax
TESTS_SUBDIRS= directive-t0 enl funny-targets semi
diff --git a/usr.bin/bmake/tests/syntax/directive-t0/Makefile b/usr.bin/bmake/tests/syntax/directive-t0/Makefile
index 66e1f32..e790b94 100644
--- a/usr.bin/bmake/tests/syntax/directive-t0/Makefile
+++ b/usr.bin/bmake/tests/syntax/directive-t0/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/syntax/directive-t0
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/syntax/enl/Makefile b/usr.bin/bmake/tests/syntax/enl/Makefile
index 743e88f..0ba16a7 100644
--- a/usr.bin/bmake/tests/syntax/enl/Makefile
+++ b/usr.bin/bmake/tests/syntax/enl/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/syntax/enl
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/syntax/funny-targets/Makefile b/usr.bin/bmake/tests/syntax/funny-targets/Makefile
index 53a3e4d..3e56b2b 100644
--- a/usr.bin/bmake/tests/syntax/funny-targets/Makefile
+++ b/usr.bin/bmake/tests/syntax/funny-targets/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/syntax/funny-targets
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/syntax/semi/Makefile b/usr.bin/bmake/tests/syntax/semi/Makefile
index 00a7f1e..cb57bbc 100644
--- a/usr.bin/bmake/tests/syntax/semi/Makefile
+++ b/usr.bin/bmake/tests/syntax/semi/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/syntax/semi
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/sysmk/Makefile b/usr.bin/bmake/tests/sysmk/Makefile
index 90d90f1..8dccb03 100644
--- a/usr.bin/bmake/tests/sysmk/Makefile
+++ b/usr.bin/bmake/tests/sysmk/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk
TESTS_SUBDIRS= t0 t1 t2
diff --git a/usr.bin/bmake/tests/sysmk/t0/2/1/Makefile b/usr.bin/bmake/tests/sysmk/t0/2/1/Makefile
index 5578a9b..87e6827 100644
--- a/usr.bin/bmake/tests/sysmk/t0/2/1/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t0/2/1/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t0/2/1
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/sysmk/t0/2/Makefile b/usr.bin/bmake/tests/sysmk/t0/2/Makefile
index 2204807..2a6fc75 100644
--- a/usr.bin/bmake/tests/sysmk/t0/2/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t0/2/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t0/2
TESTS_SUBDIRS= 1
diff --git a/usr.bin/bmake/tests/sysmk/t0/Makefile b/usr.bin/bmake/tests/sysmk/t0/Makefile
index f38383c..d31d561 100644
--- a/usr.bin/bmake/tests/sysmk/t0/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t0/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t0
TESTS_SUBDIRS= 2
diff --git a/usr.bin/bmake/tests/sysmk/t0/mk/Makefile b/usr.bin/bmake/tests/sysmk/t0/mk/Makefile
index be1bd5a..e7620a5 100644
--- a/usr.bin/bmake/tests/sysmk/t0/mk/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t0/mk/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t0/mk
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/bmake/tests/sysmk/t1/2/1/Makefile b/usr.bin/bmake/tests/sysmk/t1/2/1/Makefile
index c5e2889..a66fb25 100644
--- a/usr.bin/bmake/tests/sysmk/t1/2/1/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t1/2/1/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t1/2/1
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/sysmk/t1/2/Makefile b/usr.bin/bmake/tests/sysmk/t1/2/Makefile
index 7c2e619..bf3991a 100644
--- a/usr.bin/bmake/tests/sysmk/t1/2/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t1/2/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t1/2
TESTS_SUBDIRS= 1
diff --git a/usr.bin/bmake/tests/sysmk/t1/Makefile b/usr.bin/bmake/tests/sysmk/t1/Makefile
index 4d32823..fac186f 100644
--- a/usr.bin/bmake/tests/sysmk/t1/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t1/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t1
TESTS_SUBDIRS= 2
diff --git a/usr.bin/bmake/tests/sysmk/t1/mk/Makefile b/usr.bin/bmake/tests/sysmk/t1/mk/Makefile
index ccfd1b6..dc46dd8 100644
--- a/usr.bin/bmake/tests/sysmk/t1/mk/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t1/mk/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t1/mk
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/bmake/tests/sysmk/t2/2/1/Makefile b/usr.bin/bmake/tests/sysmk/t2/2/1/Makefile
index e06539a..5ce3194 100644
--- a/usr.bin/bmake/tests/sysmk/t2/2/1/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t2/2/1/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t2/2/1
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/sysmk/t2/2/Makefile b/usr.bin/bmake/tests/sysmk/t2/2/Makefile
index 7d1c68e..9b0526f 100644
--- a/usr.bin/bmake/tests/sysmk/t2/2/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t2/2/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t2/2
TESTS_SUBDIRS= 1
diff --git a/usr.bin/bmake/tests/sysmk/t2/Makefile b/usr.bin/bmake/tests/sysmk/t2/Makefile
index 734c7d8..1c6bad0 100644
--- a/usr.bin/bmake/tests/sysmk/t2/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t2/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t2
TESTS_SUBDIRS= 2
diff --git a/usr.bin/bmake/tests/sysmk/t2/mk/Makefile b/usr.bin/bmake/tests/sysmk/t2/mk/Makefile
index 29460dc..7aec656 100644
--- a/usr.bin/bmake/tests/sysmk/t2/mk/Makefile
+++ b/usr.bin/bmake/tests/sysmk/t2/mk/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/sysmk/t2/mk
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/bmake/tests/variables/Makefile b/usr.bin/bmake/tests/variables/Makefile
index e010718..56615df 100644
--- a/usr.bin/bmake/tests/variables/Makefile
+++ b/usr.bin/bmake/tests/variables/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/variables
TESTS_SUBDIRS= modifier_M modifier_t opt_V t0
diff --git a/usr.bin/bmake/tests/variables/modifier_M/Makefile b/usr.bin/bmake/tests/variables/modifier_M/Makefile
index 2490382..5841047 100644
--- a/usr.bin/bmake/tests/variables/modifier_M/Makefile
+++ b/usr.bin/bmake/tests/variables/modifier_M/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/variables/modifier_M
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/variables/modifier_t/Makefile b/usr.bin/bmake/tests/variables/modifier_t/Makefile
index d108da4..b35881a 100644
--- a/usr.bin/bmake/tests/variables/modifier_t/Makefile
+++ b/usr.bin/bmake/tests/variables/modifier_t/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/variables/modifier_t
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/variables/opt_V/Makefile b/usr.bin/bmake/tests/variables/opt_V/Makefile
index 94a6aff..f52507f 100644
--- a/usr.bin/bmake/tests/variables/opt_V/Makefile
+++ b/usr.bin/bmake/tests/variables/opt_V/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/variables/opt_V
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/bmake/tests/variables/t0/Makefile b/usr.bin/bmake/tests/variables/t0/Makefile
index c4b98e6..4b845d7 100644
--- a/usr.bin/bmake/tests/variables/t0/Makefile
+++ b/usr.bin/bmake/tests/variables/t0/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/bmake/variables/t0
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/calendar/tests/Makefile b/usr.bin/calendar/tests/Makefile
index b9b0607..a3bdada 100644
--- a/usr.bin/calendar/tests/Makefile
+++ b/usr.bin/calendar/tests/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/chpass/Makefile b/usr.bin/chpass/Makefile
index 9b3e878..16974e2 100644
--- a/usr.bin/chpass/Makefile
+++ b/usr.bin/chpass/Makefile
@@ -9,6 +9,7 @@ PROG= chpass
SRCS= chpass.c edit.c field.c pw_scan.c table.c util.c
BINOWN= root
BINMODE=4555
+PRECIOUSPROG=
.if ${MK_NIS} != "no"
CFLAGS+= -DYP
.endif
@@ -21,12 +22,12 @@ LIBADD= crypt util
LIBADD+= ypclnt
.endif
-LINKS= ${BINDIR}/chpass ${BINDIR}/chfn
-LINKS+= ${BINDIR}/chpass ${BINDIR}/chsh
+SYMLINKS= ${BINDIR}/chpass ${BINDIR}/chfn
+SYMLINKS+= ${BINDIR}/chpass ${BINDIR}/chsh
.if ${MK_NIS} != "no"
-LINKS+= ${BINDIR}/chpass ${BINDIR}/ypchpass
-LINKS+= ${BINDIR}/chpass ${BINDIR}/ypchfn
-LINKS+= ${BINDIR}/chpass ${BINDIR}/ypchsh
+SYMLINKS+= ${BINDIR}/chpass ${BINDIR}/ypchpass
+SYMLINKS+= ${BINDIR}/chpass ${BINDIR}/ypchfn
+SYMLINKS+= ${BINDIR}/chpass ${BINDIR}/ypchsh
.endif
MLINKS= chpass.1 chfn.1 chpass.1 chsh.1
@@ -41,9 +42,4 @@ beforeinstall:
.endif
.endfor
-.if !defined(NO_FSCHG)
-afterinstall:
- -chflags schg ${DESTDIR}${BINDIR}/chpass
-.endif
-
.include <bsd.prog.mk>
diff --git a/usr.bin/clang/clang.prog.mk b/usr.bin/clang/clang.prog.mk
index 912f678..b1dd7c1 100644
--- a/usr.bin/clang/clang.prog.mk
+++ b/usr.bin/clang/clang.prog.mk
@@ -9,6 +9,8 @@ DPADD+= ${.OBJDIR}/../../../lib/clang/lib${lib}/lib${lib}.a
LDADD+= ${.OBJDIR}/../../../lib/clang/lib${lib}/lib${lib}.a
.endfor
+PACKAGE= clang
+
LIBADD+= ncursesw pthread
BINDIR?= /usr/bin
diff --git a/usr.bin/cmp/tests/Makefile b/usr.bin/cmp/tests/Makefile
index bfae46c..3e58b00 100644
--- a/usr.bin/cmp/tests/Makefile
+++ b/usr.bin/cmp/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= cmp_test
.include <netbsd-tests.test.mk>
diff --git a/usr.bin/col/tests/Makefile b/usr.bin/col/tests/Makefile
index cf02083..b9fc67b 100644
--- a/usr.bin/col/tests/Makefile
+++ b/usr.bin/col/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= col
FILES= rlf.in \
diff --git a/usr.bin/comm/tests/Makefile b/usr.bin/comm/tests/Makefile
index 065b3b4..90c34c0 100644
--- a/usr.bin/comm/tests/Makefile
+++ b/usr.bin/comm/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/cpio/tests/Makefile b/usr.bin/cpio/tests/Makefile
index 532e2ec..c65878f 100644
--- a/usr.bin/cpio/tests/Makefile
+++ b/usr.bin/cpio/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
ATF_TESTS_SH+= functional_test
diff --git a/usr.bin/cut/tests/Makefile b/usr.bin/cut/tests/Makefile
index 7d8707d..2491418 100644
--- a/usr.bin/cut/tests/Makefile
+++ b/usr.bin/cut/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= cut_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/dirname/tests/Makefile b/usr.bin/dirname/tests/Makefile
index 6688e0d..28119f9 100644
--- a/usr.bin/dirname/tests/Makefile
+++ b/usr.bin/dirname/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= dirname_test
.include <netbsd-tests.test.mk>
diff --git a/usr.bin/ee/Makefile b/usr.bin/ee/Makefile
index 7423fa7..ee43707 100644
--- a/usr.bin/ee/Makefile
+++ b/usr.bin/ee/Makefile
@@ -5,6 +5,7 @@
CFLAGS+= -DHAS_NCURSES -DHAS_UNISTD -DHAS_STDARG -DHAS_STDLIB \
-DHAS_SYS_WAIT
+PACKAGE=ee
PROG= ee
LINKS= ${BINDIR}/ee ${BINDIR}/ree ${BINDIR}/ee ${BINDIR}/edit
MLINKS= ee.1 ree.1 ee.1 edit.1
diff --git a/usr.bin/file2c/tests/Makefile b/usr.bin/file2c/tests/Makefile
index 50267f0..83feec2 100644
--- a/usr.bin/file2c/tests/Makefile
+++ b/usr.bin/file2c/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/grep/tests/Makefile b/usr.bin/grep/tests/Makefile
index 7744fcb..945af13 100644
--- a/usr.bin/grep/tests/Makefile
+++ b/usr.bin/grep/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= grep_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/gzip/tests/Makefile b/usr.bin/gzip/tests/Makefile
index 03a5852..96acbd2 100644
--- a/usr.bin/gzip/tests/Makefile
+++ b/usr.bin/gzip/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
NETBSD_ATF_TESTS_SH= gzip_test
.include <netbsd-tests.test.mk>
diff --git a/usr.bin/ident/tests/Makefile b/usr.bin/ident/tests/Makefile
index 2ae27cf..e38eb10 100644
--- a/usr.bin/ident/tests/Makefile
+++ b/usr.bin/ident/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= ident
FILES= test.in \
test.out \
diff --git a/usr.bin/iscsictl/Makefile b/usr.bin/iscsictl/Makefile
index 4437e2d..72eae15 100644
--- a/usr.bin/iscsictl/Makefile
+++ b/usr.bin/iscsictl/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= iscsi
PROG= iscsictl
SRCS= iscsictl.c periphs.c parse.y token.l y.tab.h
CFLAGS+= -I${.CURDIR}
diff --git a/usr.bin/join/tests/Makefile b/usr.bin/join/tests/Makefile
index 16f522f..369be0a 100644
--- a/usr.bin/join/tests/Makefile
+++ b/usr.bin/join/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/jot/tests/Makefile b/usr.bin/jot/tests/Makefile
index 63f7631..c85b4a1 100644
--- a/usr.bin/jot/tests/Makefile
+++ b/usr.bin/jot/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/lastcomm/Makefile b/usr.bin/lastcomm/Makefile
index 54341ca..238551b 100644
--- a/usr.bin/lastcomm/Makefile
+++ b/usr.bin/lastcomm/Makefile
@@ -3,6 +3,8 @@
.include <src.opts.mk>
+PACKAGE=acct
+
PROG= lastcomm
SRCS= lastcomm.c readrec.c
diff --git a/usr.bin/lastcomm/tests/Makefile b/usr.bin/lastcomm/tests/Makefile
index 55ce574..71fe66e 100644
--- a/usr.bin/lastcomm/tests/Makefile
+++ b/usr.bin/lastcomm/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/limits/tests/Makefile b/usr.bin/limits/tests/Makefile
index 54bf892..e57fe60 100644
--- a/usr.bin/limits/tests/Makefile
+++ b/usr.bin/limits/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH+= limits_test
.include <bsd.test.mk>
diff --git a/usr.bin/m4/tests/Makefile b/usr.bin/m4/tests/Makefile
index 6a48677..24b453a 100644
--- a/usr.bin/m4/tests/Makefile
+++ b/usr.bin/m4/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/mkimg/tests/Makefile b/usr.bin/mkimg/tests/Makefile
index c2c6d51..b98da39 100644
--- a/usr.bin/mkimg/tests/Makefile
+++ b/usr.bin/mkimg/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= mkimg
SOURCES!= cd ${.CURDIR}; echo *.uu
diff --git a/usr.bin/ncal/tests/Makefile b/usr.bin/ncal/tests/Makefile
index 23b235f..8752f77 100644
--- a/usr.bin/ncal/tests/Makefile
+++ b/usr.bin/ncal/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/passwd/Makefile b/usr.bin/passwd/Makefile
index f1fff46..fac1bb1 100644
--- a/usr.bin/passwd/Makefile
+++ b/usr.bin/passwd/Makefile
@@ -6,9 +6,10 @@
PROG = passwd
BINOWN = root
BINMODE = 4555
+PRECIOUSPROG=
LIBADD = pam
.if ${MK_NIS} != "no"
-LINKS = ${BINDIR}/passwd ${BINDIR}/yppasswd
+SYMLINKS = ${BINDIR}/passwd ${BINDIR}/yppasswd
MLINKS = passwd.1 yppasswd.1
.endif
@@ -18,9 +19,4 @@ beforeinstall:
chflags noschg ${DESTDIR}${BINDIR}/$i || true
.endfor
-.if !defined(NO_FSCHG)
-afterinstall:
- -chflags schg ${DESTDIR}${BINDIR}/passwd
-.endif
-
.include <bsd.prog.mk>
diff --git a/usr.bin/printf/tests/Makefile b/usr.bin/printf/tests/Makefile
index 58c80c7..9217881 100644
--- a/usr.bin/printf/tests/Makefile
+++ b/usr.bin/printf/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/rlogin/Makefile b/usr.bin/rlogin/Makefile
index e41417d..74ab15b 100644
--- a/usr.bin/rlogin/Makefile
+++ b/usr.bin/rlogin/Makefile
@@ -3,6 +3,8 @@
PROG= rlogin
+PACKAGE=rcmds
+
BINOWN= root
BINMODE=4555
diff --git a/usr.bin/rsh/Makefile b/usr.bin/rsh/Makefile
index 2005f23..66638cc 100644
--- a/usr.bin/rsh/Makefile
+++ b/usr.bin/rsh/Makefile
@@ -4,6 +4,8 @@
PROG= rsh
CFLAGS+=-I${.CURDIR}/../../libexec/rlogind
+PACKAGE=rcmds
+
BINOWN= root
BINMODE=4555
diff --git a/usr.bin/ruptime/Makefile b/usr.bin/ruptime/Makefile
index f7fba3a..d181c9c 100644
--- a/usr.bin/ruptime/Makefile
+++ b/usr.bin/ruptime/Makefile
@@ -3,4 +3,6 @@
PROG= ruptime
+PACKAGE=rcmds
+
.include <bsd.prog.mk>
diff --git a/usr.bin/rwho/Makefile b/usr.bin/rwho/Makefile
index 3fdc05d..701817b 100644
--- a/usr.bin/rwho/Makefile
+++ b/usr.bin/rwho/Makefile
@@ -3,4 +3,6 @@
PROG= rwho
+PACKAGE=rcmds
+
.include <bsd.prog.mk>
diff --git a/usr.bin/sed/tests/Makefile b/usr.bin/sed/tests/Makefile
index a23d4a9..eaeaa43 100644
--- a/usr.bin/sed/tests/Makefile
+++ b/usr.bin/sed/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
TAP_TESTS_SH+= multi_test
TEST_METADATA.multi_test+= required_files="/usr/share/dict/words"
diff --git a/usr.bin/sed/tests/regress.multitest.out/Makefile b/usr.bin/sed/tests/regress.multitest.out/Makefile
index 0b2d0ba..f3fb038 100644
--- a/usr.bin/sed/tests/regress.multitest.out/Makefile
+++ b/usr.bin/sed/tests/regress.multitest.out/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/sed/regress.multitest.out
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/soelim/tests/Makefile b/usr.bin/soelim/tests/Makefile
index 7c44d08..09f5395 100644
--- a/usr.bin/soelim/tests/Makefile
+++ b/usr.bin/soelim/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= soelim
FILES= nonexisting.in \
diff --git a/usr.bin/ssh-copy-id/Makefile b/usr.bin/ssh-copy-id/Makefile
index 033c435..93f5ec4 100644
--- a/usr.bin/ssh-copy-id/Makefile
+++ b/usr.bin/ssh-copy-id/Makefile
@@ -2,5 +2,6 @@
SCRIPTS= ssh-copy-id.sh
MAN= ssh-copy-id.1
+PACKAGE= ssh
.include <bsd.prog.mk>
diff --git a/usr.bin/svn/Makefile.inc b/usr.bin/svn/Makefile.inc
index 330e201..2621238 100644
--- a/usr.bin/svn/Makefile.inc
+++ b/usr.bin/svn/Makefile.inc
@@ -8,6 +8,8 @@ SVNLITE?=
SVNLITE?= lite
.endif
+PACKAGE= svn
+
.if !defined(SVNDIR)
SVNDIR= ${.CURDIR}/../../../contrib/subversion/subversion
diff --git a/usr.bin/tar/tests/Makefile b/usr.bin/tar/tests/Makefile
index 96800a5..6c52066 100644
--- a/usr.bin/tar/tests/Makefile
+++ b/usr.bin/tar/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
ATF_TESTS_SH+= functional_test
diff --git a/usr.bin/tests/Makefile b/usr.bin/tests/Makefile
index 08b47bc..e8e8e80 100644
--- a/usr.bin/tests/Makefile
+++ b/usr.bin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/usr.bin/timeout/tests/Makefile b/usr.bin/timeout/tests/Makefile
index 6303718..ec528b57 100644
--- a/usr.bin/timeout/tests/Makefile
+++ b/usr.bin/timeout/tests/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/timeout
ATF_TESTS_SH= timeout
diff --git a/usr.bin/tr/tests/Makefile b/usr.bin/tr/tests/Makefile
index 58e4fadc..4411183 100644
--- a/usr.bin/tr/tests/Makefile
+++ b/usr.bin/tr/tests/Makefile
@@ -1,5 +1,8 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSDIR= ${TESTSBASE}/usr.bin/tr
TAP_TESTS_SH= legacy_test
diff --git a/usr.bin/truncate/tests/Makefile b/usr.bin/truncate/tests/Makefile
index 82cd606..76f6aeb 100644
--- a/usr.bin/truncate/tests/Makefile
+++ b/usr.bin/truncate/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= truncate_test
.include <bsd.test.mk>
diff --git a/usr.bin/units/tests/Makefile b/usr.bin/units/tests/Makefile
index 5b135f7..471fa4b 100644
--- a/usr.bin/units/tests/Makefile
+++ b/usr.bin/units/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= basics_test
.include <bsd.test.mk>
diff --git a/usr.bin/uudecode/tests/Makefile b/usr.bin/uudecode/tests/Makefile
index efd3f92..df865c2 100644
--- a/usr.bin/uudecode/tests/Makefile
+++ b/usr.bin/uudecode/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/uuencode/tests/Makefile b/usr.bin/uuencode/tests/Makefile
index a36ef6c..4df5886 100644
--- a/usr.bin/uuencode/tests/Makefile
+++ b/usr.bin/uuencode/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/vi/Makefile b/usr.bin/vi/Makefile
index 3a0fd47..ae9814d 100644
--- a/usr.bin/vi/Makefile
+++ b/usr.bin/vi/Makefile
@@ -4,6 +4,7 @@
.include <src.opts.mk>
+PACKAGE= vi
SRCDIR= ${.CURDIR}/../../contrib/nvi
SUBDIR+= catalog
diff --git a/usr.bin/vi/catalog/Makefile b/usr.bin/vi/catalog/Makefile
index e2ca579..97ab09e 100644
--- a/usr.bin/vi/catalog/Makefile
+++ b/usr.bin/vi/catalog/Makefile
@@ -3,10 +3,15 @@
.include <bsd.own.mk>
+PACKAGE=vi
V= ${.CURDIR}/../../../contrib/nvi
+FILESGROUPS+=VICAT
CAT= dutch english french german polish ru_RU.KOI8-R spanish swedish \
uk_UA.KOI8-U zh_CN.GB2312
+VICAT= ${CAT}
+VICATDIR= ${FILESDIR}
+VICATPACKAGE= ${PACKAGE}
SCAN= ${V}/cl/*.c ${V}/common/*.c ${V}/ex/*.c ${V}/vi/*.c
diff --git a/usr.bin/xargs/tests/Makefile b/usr.bin/xargs/tests/Makefile
index c8ef2c9..edd5adf 100644
--- a/usr.bin/xargs/tests/Makefile
+++ b/usr.bin/xargs/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.bin/xo/tests/Makefile b/usr.bin/xo/tests/Makefile
index f22c005..c8d86d0 100644
--- a/usr.bin/xo/tests/Makefile
+++ b/usr.bin/xo/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
LIBXOSRC= ${SRCTOP}/contrib/libxo
.PATH: ${LIBXOSRC}/tests/xo ${LIBXOSRC}/tests/xo/saved
diff --git a/usr.bin/yacc/tests/Makefile b/usr.bin/yacc/tests/Makefile
index ad3abaa..576aa54 100644
--- a/usr.bin/yacc/tests/Makefile
+++ b/usr.bin/yacc/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+PACKAGE= tests
+
TEST_DIR= ${SRCTOP}/contrib/byacc/test
.PATH: ${TEST_DIR} ${TEST_DIR}/yacc
@@ -17,7 +22,10 @@ SCRIPTSDIR= ${TESTSDIR}
CLEANFILES= run_test
-FILESGROUPS= FILES FILEStest FILEStest_yacc
+FILESGROUPS+= FILES FILEStest FILEStest_yacc
+FILESPACKAGE= ${PACKAGE}
+FILEStestPACKAGE=${PACKAGE}
+FILEStest_yaccPACKAGE=${PACKAGE}
FILEStestDIR= ${TESTSDIR}
diff --git a/usr.sbin/accton/Makefile b/usr.sbin/accton/Makefile
index ea9b4f4..94c87ac 100644
--- a/usr.sbin/accton/Makefile
+++ b/usr.sbin/accton/Makefile
@@ -4,4 +4,6 @@
PROG= accton
MAN= accton.8
+PACKAGE=acct
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/acpi/Makefile.inc b/usr.sbin/acpi/Makefile.inc
index d6ce93b..9692f0a 100644
--- a/usr.sbin/acpi/Makefile.inc
+++ b/usr.sbin/acpi/Makefile.inc
@@ -4,6 +4,8 @@
ACPICA_DIR= ${.CURDIR}/../../../sys/contrib/dev/acpica
CFLAGS+= -I${.CURDIR}/../../../sys
+PACKAGE= acpi
+
.if exists(${.CURDIR}/../../Makefile.inc)
.include "${.CURDIR}/../../Makefile.inc"
.endif
diff --git a/usr.sbin/amd/Makefile.inc b/usr.sbin/amd/Makefile.inc
index 8c397cf..1b19acd 100644
--- a/usr.sbin/amd/Makefile.inc
+++ b/usr.sbin/amd/Makefile.inc
@@ -11,6 +11,8 @@
.include <src.opts.mk>
+PACKAGE= amd
+
CFLAGS+= -I. -I${.CURDIR}
CFLAGS+= -I${.CURDIR}/../include
.if exists(${.OBJDIR}/../include)
diff --git a/usr.sbin/apm/Makefile b/usr.sbin/apm/Makefile
index 3cc6f50..f52453c 100644
--- a/usr.sbin/apm/Makefile
+++ b/usr.sbin/apm/Makefile
@@ -5,4 +5,6 @@ MAN= apm.8
MLINKS= apm.8 apmconf.8
MANSUBDIR= /${MACHINE_CPUARCH}
+PACKAGE=apm
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/apmd/Makefile b/usr.sbin/apmd/Makefile
index b2afdfaf..20a4e56 100644
--- a/usr.sbin/apmd/Makefile
+++ b/usr.sbin/apmd/Makefile
@@ -5,6 +5,8 @@ MAN= apmd.8
MANSUBDIR= /i386
SRCS= apmd.c apmdlex.l apmdparse.y y.tab.h
+PACKAGE=apm
+
WARNS?= 3
LIBADD= l
diff --git a/usr.sbin/autofs/Makefile b/usr.sbin/autofs/Makefile
index 00c79dd..cc13bcc 100644
--- a/usr.sbin/autofs/Makefile
+++ b/usr.sbin/autofs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE=autofs
PROG= automountd
SRCS= automount.c
SRCS+= automountd.c
diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile
index 0e1a85e..e1992a7 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -3,6 +3,7 @@
#
PROG= bhyve
+PACKAGE= bhyve
DEBUG_FLAGS= -g -O0
diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile
index fe8f1d3..4f0ecdd 100644
--- a/usr.sbin/bhyvectl/Makefile
+++ b/usr.sbin/bhyvectl/Makefile
@@ -4,6 +4,7 @@
PROG= bhyvectl
SRCS= bhyvectl.c
+PACKAGE= bhyve
MAN= bhyvectl.8
diff --git a/usr.sbin/bhyveload/Makefile b/usr.sbin/bhyveload/Makefile
index fce0c1b..5fa692d 100644
--- a/usr.sbin/bhyveload/Makefile
+++ b/usr.sbin/bhyveload/Makefile
@@ -3,6 +3,7 @@
PROG= bhyveload
SRCS= bhyveload.c
MAN= bhyveload.8
+PACKAGE= bhyve
LIBADD= vmmapi
diff --git a/usr.sbin/bsdinstall/Makefile b/usr.sbin/bsdinstall/Makefile
index 4e3b7ef..88cb691 100644
--- a/usr.sbin/bsdinstall/Makefile
+++ b/usr.sbin/bsdinstall/Makefile
@@ -4,5 +4,6 @@ SUBDIR= distextract distfetch partedit scripts
SUBDIR_PARALLEL=
SCRIPTS= bsdinstall
MAN= bsdinstall.8
+PACKAGE= bsdinstall
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/Makefile.inc b/usr.sbin/bsdinstall/Makefile.inc
new file mode 100644
index 0000000..dc4e35b
--- /dev/null
+++ b/usr.sbin/bsdinstall/Makefile.inc
@@ -0,0 +1 @@
+PACKAGE=bsdinstall
diff --git a/usr.sbin/bsnmpd/Makefile.inc b/usr.sbin/bsnmpd/Makefile.inc
index 265f86d..3718a5a 100644
--- a/usr.sbin/bsnmpd/Makefile.inc
+++ b/usr.sbin/bsnmpd/Makefile.inc
@@ -1,3 +1,4 @@
# $FreeBSD$
+PACKAGE= bsnmp
.include "../Makefile.inc"
diff --git a/usr.sbin/bsnmpd/modules/Makefile.inc b/usr.sbin/bsnmpd/modules/Makefile.inc
index 357b441..bf63395 100644
--- a/usr.sbin/bsnmpd/modules/Makefile.inc
+++ b/usr.sbin/bsnmpd/modules/Makefile.inc
@@ -1,6 +1,7 @@
# $FreeBSD$
SHLIB_MAJOR= 6
+PACKAGE= bsnmp
MANFILTER= sed -e 's%@MODPATH@%${LIBDIR}/%g' \
-e 's%@DEFPATH@%${DEFSDIR}/%g' \
diff --git a/usr.sbin/bsnmpd/tools/Makefile.inc b/usr.sbin/bsnmpd/tools/Makefile.inc
index e08fe26..a0bf4a0 100644
--- a/usr.sbin/bsnmpd/tools/Makefile.inc
+++ b/usr.sbin/bsnmpd/tools/Makefile.inc
@@ -2,6 +2,7 @@
# Author: Shteryana Shopova <syrinx@FreeBSD.org>
BINDIR?= /usr/bin
+PACKAGE= bsnmp
CFLAGS+= -I. -I${.CURDIR}
diff --git a/usr.sbin/chown/tests/Makefile b/usr.sbin/chown/tests/Makefile
index fb13f3f..cdf872a 100644
--- a/usr.sbin/chown/tests/Makefile
+++ b/usr.sbin/chown/tests/Makefile
@@ -2,6 +2,10 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TESTSDIR= ${TESTSBASE}/bin/chown
TAP_TESTS_SH= chown-f_test
diff --git a/usr.sbin/etcupdate/tests/Makefile b/usr.sbin/etcupdate/tests/Makefile
index 45b12b7..1f09f1f 100644
--- a/usr.sbin/etcupdate/tests/Makefile
+++ b/usr.sbin/etcupdate/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
PLAIN_TESTS_SH=
.for test in always_test \
conflicts_test \
diff --git a/usr.sbin/fstyp/tests/Makefile b/usr.sbin/fstyp/tests/Makefile
index 01c9869..9be7d45 100644
--- a/usr.sbin/fstyp/tests/Makefile
+++ b/usr.sbin/fstyp/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= fstyp_test
FILES= ext2.img.bz2
diff --git a/usr.sbin/iscsid/Makefile b/usr.sbin/iscsid/Makefile
index ca71f31..1a88de4 100644
--- a/usr.sbin/iscsid/Makefile
+++ b/usr.sbin/iscsid/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+PACKAGE= iscsi
PROG= iscsid
SRCS= chap.c discovery.c iscsid.c keys.c log.c login.c pdu.c
CFLAGS+= -I${.CURDIR}
diff --git a/usr.sbin/jail/Makefile b/usr.sbin/jail/Makefile
index 9dfdee5..1fb905b 100644
--- a/usr.sbin/jail/Makefile
+++ b/usr.sbin/jail/Makefile
@@ -8,6 +8,8 @@ SRCS= jail.c command.c config.c state.c jailp.h jaillex.l jailparse.y y.tab.h
LIBADD= jail kvm util l
+PACKAGE=jail
+
NO_WMISSING_VARIABLE_DECLARATIONS=
YFLAGS+=-v
diff --git a/usr.sbin/jexec/Makefile b/usr.sbin/jexec/Makefile
index 700da97..3ecf567 100644
--- a/usr.sbin/jexec/Makefile
+++ b/usr.sbin/jexec/Makefile
@@ -4,4 +4,6 @@ PROG= jexec
MAN= jexec.8
LIBADD= jail util
+PACKAGE=jail
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/jls/Makefile b/usr.sbin/jls/Makefile
index 4c1de74..34a5023 100644
--- a/usr.sbin/jls/Makefile
+++ b/usr.sbin/jls/Makefile
@@ -6,6 +6,8 @@ PROG= jls
MAN= jls.8
LIBADD= jail xo
+PACKAGE=jail
+
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+= -DINET6
.endif
diff --git a/usr.sbin/makefs/tests/Makefile b/usr.sbin/makefs/tests/Makefile
index 8cd315a..87a4858 100644
--- a/usr.sbin/makefs/tests/Makefile
+++ b/usr.sbin/makefs/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH+= makefs_cd9660_tests
ATF_TESTS_SH+= makefs_ffs_tests
diff --git a/usr.sbin/newsyslog/tests/Makefile b/usr.sbin/newsyslog/tests/Makefile
index 802a44c..0b87442 100644
--- a/usr.sbin/newsyslog/tests/Makefile
+++ b/usr.sbin/newsyslog/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
.include <bsd.test.mk>
diff --git a/usr.sbin/nmtree/tests/Makefile b/usr.sbin/nmtree/tests/Makefile
index 0b63127..b4cc2f5 100644
--- a/usr.sbin/nmtree/tests/Makefile
+++ b/usr.sbin/nmtree/tests/Makefile
@@ -1,6 +1,10 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/usr.sbin/mtree
+
.PATH: ${TESTSRC}
ATF_TESTS_SH= nmtree_test
diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile
index 27f0ac4..66ab454 100644
--- a/usr.sbin/pw/tests/Makefile
+++ b/usr.sbin/pw/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
ATF_TESTS_SH= pw_etcdir \
pw_lock \
pw_config \
diff --git a/usr.sbin/rpcbind/tests/Makefile b/usr.sbin/rpcbind/tests/Makefile
index 4b0cf15..83b4522 100644
--- a/usr.sbin/rpcbind/tests/Makefile
+++ b/usr.sbin/rpcbind/tests/Makefile
@@ -2,6 +2,10 @@
.include <src.opts.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
.PATH: ${.CURDIR}/..
ATF_TESTS_C= addrmerge_test
diff --git a/usr.sbin/rwhod/Makefile b/usr.sbin/rwhod/Makefile
index f1b5d99..554f6be 100644
--- a/usr.sbin/rwhod/Makefile
+++ b/usr.sbin/rwhod/Makefile
@@ -4,6 +4,8 @@
PROG= rwhod
MAN= rwhod.8
+PACKAGE=rcmds
+
WARNS?= 3
.include <bsd.prog.mk>
diff --git a/usr.sbin/sa/Makefile b/usr.sbin/sa/Makefile
index c3c79b0..314e341 100644
--- a/usr.sbin/sa/Makefile
+++ b/usr.sbin/sa/Makefile
@@ -8,6 +8,8 @@ PROG= sa
MAN= sa.8
SRCS= main.c db.c pdb.c usrdb.c readrec.c
+PACKAGE=acct
+
.if ${MK_TESTS} != "no"
SUBDIR+= tests
.endif
diff --git a/usr.sbin/sa/tests/Makefile b/usr.sbin/sa/tests/Makefile
index 3c74ba9..36bfcc0 100644
--- a/usr.sbin/sa/tests/Makefile
+++ b/usr.sbin/sa/tests/Makefile
@@ -1,5 +1,9 @@
# $FreeBSD$
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+
TAP_TESTS_SH= legacy_test
FILESDIR= ${TESTSDIR}
diff --git a/usr.sbin/sendmail/Makefile b/usr.sbin/sendmail/Makefile
index f9641c1..d7246cb 100644
--- a/usr.sbin/sendmail/Makefile
+++ b/usr.sbin/sendmail/Makefile
@@ -3,6 +3,7 @@
.include <src.opts.mk>
+PACKAGE=sendmail
SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
SMDIR= ${SENDMAIL_DIR}/src
.PATH: ${SMDIR}
diff --git a/usr.sbin/tests/Makefile b/usr.sbin/tests/Makefile
index a0e63e5..609357e 100644
--- a/usr.sbin/tests/Makefile
+++ b/usr.sbin/tests/Makefile
@@ -2,6 +2,11 @@
.include <bsd.own.mk>
+PACKAGE= tests
+FILESGROUPS= TESTS
+TESTSPACKAGE= ${PACKAGE}
+TESTS+= Kyuafile
+
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/usr.sbin/unbound/Makefile.inc b/usr.sbin/unbound/Makefile.inc
index 425d719..20cac57 100644
--- a/usr.sbin/unbound/Makefile.inc
+++ b/usr.sbin/unbound/Makefile.inc
@@ -1,5 +1,6 @@
# $FreeBSD$
NO_WERROR= true
+PACKAGE= unbound
.include "../Makefile.inc"
OpenPOWER on IntegriCloud