1#!/bin/sh
2#
3#
4
5set -e
6
7export ASSUME_ALWAYS_YES="YES"
8export PKG_DBDIR="/tmp/pkg"
9export PERMISSIVE="YES"
10export REPO_AUTOUPDATE="NO"
11export ROOTDIR="$PWD/dvd"
12export PKGCMD="/usr/sbin/pkg -d --rootdir ${ROOTDIR}"
13export PORTSDIR="${PORTSDIR:-/usr/ports}"
14
15_DVD_PACKAGES="devel/git@lite
16graphics/drm-kmod
17graphics/drm-510-kmod
18graphics/drm-515-kmod
19misc/freebsd-doc-all
20net/mpd5
21net/rsync
22net/wifi-firmware-rtw88-kmod
23ports-mgmt/pkg
24shells/bash
25shells/zsh
26security/sudo
27sysutils/screen
28sysutils/seatd
29sysutils/tmux
30www/firefox
31www/links
32x11/gnome
33x11/kde5
34x11/sddm
35x11/xorg
36x11-wm/sway"
37
38# If NOPORTS is set for the release, do not attempt to build pkg(8).
39if [ ! -f ${PORTSDIR}/Makefile ]; then
40	echo "*** ${PORTSDIR} is missing!    ***"
41	echo "*** Skipping pkg-stage.sh     ***"
42	echo "*** Unset NOPORTS to fix this ***"
43	exit 0
44fi
45
46if [ ! -x /usr/local/sbin/pkg ]; then
47	/etc/rc.d/ldconfig restart
48	/usr/bin/make -C ${PORTSDIR}/ports-mgmt/pkg install clean
49fi
50
51export PKG_ABI=$(pkg --rootdir ${ROOTDIR} config ABI)
52export PKG_ALTABI=$(pkg --rootdir ${ROOTDIR} config ALTABI 2>/dev/null)
53export PKG_REPODIR="packages/${PKG_ABI}"
54
55/bin/mkdir -p ${ROOTDIR}/${PKG_REPODIR}
56if [ ! -z "${PKG_ALTABI}" ]; then
57	ln -s ${PKG_ABI} ${ROOTDIR}/packages/${PKG_ALTABI}
58fi
59
60# Ensure the ports listed in _DVD_PACKAGES exist to sanitize the
61# final list.
62for _P in ${_DVD_PACKAGES}; do
63	if [ -d "${PORTSDIR}/${_P%%@*}" ]; then
64		DVD_PACKAGES="${DVD_PACKAGES} ${_P}"
65	else
66		echo "*** Skipping nonexistent port: ${_P%%@*}"
67	fi
68done
69
70# Make sure the package list is not empty.
71if [ -z "${DVD_PACKAGES}" ]; then
72	echo "*** The package list is empty."
73	echo "*** Something is very wrong."
74	# Exit '0' so the rest of the build process continues
75	# so other issues (if any) can be addressed as well.
76	exit 0
77fi
78
79# Print pkg(8) information to make debugging easier.
80${PKGCMD} -vv
81${PKGCMD} update -f
82${PKGCMD} fetch -o ${PKG_REPODIR} -d ${DVD_PACKAGES}
83
84# Create the 'Latest/pkg.txz' symlink so 'pkg bootstrap' works
85# using the on-disc packages.
86export LATEST_DIR="${ROOTDIR}/${PKG_REPODIR}/Latest"
87mkdir -p ${LATEST_DIR}
88ln -s ../All/$(${PKGCMD} rquery %n-%v pkg).pkg ${LATEST_DIR}/pkg.pkg
89ln -sf pkg.pkg ${LATEST_DIR}/pkg.txz
90
91${PKGCMD} repo ${PKG_REPODIR}
92
93# Always exit '0', even if pkg(8) complains about conflicts.
94exit 0
95