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