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