xref: /freebsd/release/scripts/pkg-stage.sh (revision 90eda629964cbe4c2472aa3f1b8a427e60e78834)
1#!/bin/sh
2#
3#
4
5set -e
6
7unset NO_ROOT
8
9export ASSUME_ALWAYS_YES="YES"
10export PKG_DBDIR="/tmp/pkg"
11export PERMISSIVE="YES"
12export REPO_AUTOUPDATE="NO"
13export ROOTDIR="$PWD/dvd"
14export PORTSDIR="${PORTSDIR:-/usr/ports}"
15
16_DVD_PACKAGES="
17comms/usbmuxd
18devel/git@lite
19editors/emacs@nox
20editors/vim
21misc/freebsd-doc-all
22net/mpd5
23net/rsync
24net/wifi-firmware-kmod@release
25ports-mgmt/pkg
26shells/bash
27shells/zsh
28security/sudo@default
29sysutils/screen
30sysutils/seatd
31sysutils/tmux
32www/firefox
33www/links
34x11/gnome
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
48usage()
49{
50	echo "usage: $0 [-N]"
51	exit 0
52}
53
54while getopts N opt; do
55	case "$opt" in
56	N)	NO_ROOT=1 ;;
57	*)	usage ;;
58	esac
59done
60
61PKG_ARGS="-d --rootdir ${ROOTDIR}"
62if [ $NO_ROOT ]; then
63	PKG_ARGS="$PKG_ARGS -o INSTALL_AS_USER=1"
64fi
65PKGCMD="/usr/sbin/pkg ${PKG_ARGS}"
66
67if [ ! -x /usr/local/sbin/pkg ]; then
68	/etc/rc.d/ldconfig restart
69	/usr/bin/make -C ${PORTSDIR}/ports-mgmt/pkg install clean
70fi
71
72export PKG_ABI=$(pkg --rootdir ${ROOTDIR} config ABI)
73export PKG_ALTABI=$(pkg --rootdir ${ROOTDIR} config ALTABI 2>/dev/null)
74export PKG_REPODIR="packages/${PKG_ABI}"
75
76/bin/mkdir -p ${ROOTDIR}/${PKG_REPODIR}
77if [ -n "${PKG_ALTABI}" ]; then
78	ln -s ${PKG_ABI} ${ROOTDIR}/packages/${PKG_ALTABI}
79fi
80
81# Ensure the ports listed in _DVD_PACKAGES exist to sanitize the
82# final list.
83for _P in ${_DVD_PACKAGES}; do
84	if [ -d "${PORTSDIR}/${_P%%@*}" ]; then
85		DVD_PACKAGES="${DVD_PACKAGES} ${_P}"
86	else
87		echo "*** Skipping nonexistent port: ${_P%%@*}"
88	fi
89done
90
91# Make sure the package list is not empty.
92if [ -z "${DVD_PACKAGES}" ]; then
93	echo "*** The package list is empty."
94	echo "*** Something is very wrong."
95	# Exit '0' so the rest of the build process continues
96	# so other issues (if any) can be addressed as well.
97	exit 0
98fi
99
100# Print pkg(8) information to make debugging easier.
101${PKGCMD} -vv
102${PKGCMD} update -f
103${PKGCMD} fetch -o ${PKG_REPODIR} -d ${DVD_PACKAGES}
104
105# Create the 'Latest/pkg.pkg' symlink so 'pkg bootstrap' works
106# using the on-disc packages.
107export LATEST_DIR="${ROOTDIR}/${PKG_REPODIR}/Latest"
108mkdir -p ${LATEST_DIR}
109ln -s ../All/$(${PKGCMD} rquery %n-%v pkg).pkg ${LATEST_DIR}/pkg.pkg
110
111${PKGCMD} repo ${PKG_REPODIR}
112
113if [ $NO_ROOT ]; then
114	mtree -c -p $ROOTDIR | mtree -C -k type,mode,link,size | \
115	    grep '^./packages[/ ]' >> $ROOTDIR/METALOG
116fi
117
118# Always exit '0', even if pkg(8) complains about conflicts.
119exit 0
120