138451Smsmith#!/bin/sh
238451Smsmith#
338451Smsmith# $FreeBSD: stable/10/release/scripts/pkg-stage.sh 338859 2018-09-21 15:58:08Z gjb $
438451Smsmith#
538451Smsmith
638451Smsmithset -e
738451Smsmith
838451Smsmithexport ASSUME_ALWAYS_YES="YES"
938451Smsmithexport PKG_DBDIR="/tmp/pkg"
1038451Smsmithexport PERMISSIVE="YES"
1138451Smsmithexport REPO_AUTOUPDATE="NO"
1238451Smsmithexport PKGCMD="/usr/sbin/pkg -d"
1338451Smsmithexport PORTSDIR="${PORTSDIR:-/usr/ports}"
1438451Smsmith
1538451Smsmith_DVD_PACKAGES="archivers/unzip
1638451Smsmithdevel/subversion
1738451Smsmithdevel/subversion-static
1838451Smsmithemulators/linux_base-f10
1938451Smsmithmisc/freebsd-doc-all
2038451Smsmithnet/mpd5
2138451Smsmithnet/rsync
2238451Smsmithports-mgmt/pkg
2338451Smsmithports-mgmt/portmaster
2438451Smsmithshells/bash
2538451Smsmithshells/zsh
2638451Smsmithsecurity/sudo
2738451Smsmithsysutils/screen
2838451Smsmithwww/firefox
2938451Smsmithwww/links
3084221Sdillonx11-drivers/xf86-video-vmware
3184221Sdillonx11/gnome3
3284221Sdillonx11/kde5
3338451Smsmithx11/xorg"
3438451Smsmith
3538451Smsmith# If NOPORTS is set for the release, do not attempt to build pkg(8).
3638451Smsmithif [ ! -f ${PORTSDIR}/Makefile ]; then
3738451Smsmith	echo "*** ${PORTSDIR} is missing!    ***"
3838451Smsmith	echo "*** Skipping pkg-stage.sh     ***"
3938451Smsmith	echo "*** Unset NOPORTS to fix this ***"
4038451Smsmith	exit 0
4138451Smsmithfi
4238451Smsmith
4338451Smsmithif [ ! -x /usr/local/sbin/pkg ]; then
4438451Smsmith	/etc/rc.d/ldconfig restart
4538451Smsmith	/usr/bin/make -C ${PORTSDIR}/ports-mgmt/pkg install clean
4638451Smsmithfi
4738451Smsmith
4838451Smsmithexport DVD_DIR="dvd/packages"
4938451Smsmithexport PKG_ABI=$(pkg config ABI)
5038451Smsmithexport PKG_ALTABI=$(pkg config ALTABI 2>/dev/null)
5138451Smsmithexport PKG_REPODIR="${DVD_DIR}/${PKG_ABI}"
5238451Smsmith
5338451Smsmith/bin/mkdir -p ${PKG_REPODIR}
5438451Smsmithif [ ! -z "${PKG_ALTABI}" ]; then
5538451Smsmith	(cd ${DVD_DIR} && ln -s ${PKG_ABI} ${PKG_ALTABI})
56fi
57
58# Ensure the ports listed in _DVD_PACKAGES exist to sanitize the
59# final list.
60for _P in ${_DVD_PACKAGES}; do
61	if [ -d "${PORTSDIR}/${_P}" ]; then
62		DVD_PACKAGES="${DVD_PACKAGES} ${_P}"
63	else
64		echo "*** Skipping nonexistent port: ${_P}"
65	fi
66done
67
68# Make sure the package list is not empty.
69if [ -z "${DVD_PACKAGES}" ]; then
70	echo "*** The package list is empty."
71	echo "*** Something is very wrong."
72	# Exit '0' so the rest of the build process continues
73	# so other issues (if any) can be addressed as well.
74	exit 0
75fi
76
77# Print pkg(8) information to make debugging easier.
78${PKGCMD} -vv
79${PKGCMD} update -f
80${PKGCMD} fetch -o ${PKG_REPODIR} -d ${DVD_PACKAGES}
81
82# Create the 'Latest/pkg.txz' symlink so 'pkg bootstrap' works
83# using the on-disc packages.
84mkdir -p ${PKG_REPODIR}/Latest
85(cd ${PKG_REPODIR}/Latest && \
86	ln -s ../All/$(${PKGCMD} rquery %n-%v pkg).txz pkg.txz)
87
88${PKGCMD} repo ${PKG_REPODIR}
89
90# Always exit '0', even if pkg(8) complains about conflicts.
91exit 0
92