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