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