xref: /freebsd/release/scripts/pkg-stage.sh (revision f5dc2263ab1be8a35a7e27e82103f9ccd41ae584)
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
19filesystems/ext2
20filesystems/ntfs
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)	;;
57	*)	usage ;;
58	esac
59done
60
61PKG_ARGS="--rootdir ${ROOTDIR}"
62PKG_ARGS="$PKG_ARGS -o INSTALL_AS_USER=1"
63PKGCMD="/usr/sbin/pkg ${PKG_ARGS}"
64
65if [ ! -x /usr/local/sbin/pkg ]; then
66	/etc/rc.d/ldconfig restart
67	/usr/bin/make -C ${PORTSDIR}/ports-mgmt/pkg install clean
68fi
69
70export PKG_ABI=$(pkg --rootdir ${ROOTDIR} config ABI)
71export PKG_ALTABI=$(pkg --rootdir ${ROOTDIR} config ALTABI 2>/dev/null)
72export PKG_REPODIR="packages/${PKG_ABI}"
73
74/bin/mkdir -p ${ROOTDIR}/${PKG_REPODIR}
75if [ -n "${PKG_ALTABI}" ]; then
76	ln -nfs ${PKG_ABI} ${ROOTDIR}/packages/${PKG_ALTABI}
77fi
78
79# Ensure the ports listed in _DVD_PACKAGES exist to sanitize the
80# final list.
81for _P in ${_DVD_PACKAGES}; do
82	if [ -d "${PORTSDIR}/${_P%%@*}" ]; then
83		DVD_PACKAGES="${DVD_PACKAGES} ${_P}"
84	else
85		echo "*** Skipping nonexistent port: ${_P%%@*}"
86	fi
87done
88
89# Make sure the package list is not empty.
90if [ -z "${DVD_PACKAGES}" ]; then
91	echo "*** The package list is empty."
92	echo "*** Something is very wrong."
93	# Exit '0' so the rest of the build process continues
94	# so other issues (if any) can be addressed as well.
95	exit 0
96fi
97
98# Print pkg(8) information to make debugging easier.
99${PKGCMD} -vv
100${PKGCMD} update -f
101${PKGCMD} fetch -o ${PKG_REPODIR} -d ${DVD_PACKAGES}
102
103# Create the 'Latest/pkg.pkg' symlink so 'pkg bootstrap' works
104# using the on-disc packages.
105export LATEST_DIR="${ROOTDIR}/${PKG_REPODIR}/Latest"
106mkdir -p ${LATEST_DIR}
107ln -nfs ../All/$(${PKGCMD} rquery %n-%v pkg).pkg ${LATEST_DIR}/pkg.pkg
108
109${PKGCMD} repo ${PKG_REPODIR}
110
111mtree -c -p $ROOTDIR | mtree -C -k type,mode,link,size | \
112    grep '^./packages[/ ]' >> $ROOTDIR/METALOG
113
114# Always exit '0', even if pkg(8) complains about conflicts.
115exit 0
116