1258307Sgjb#!/bin/sh
2258307Sgjb#
3258307Sgjb# $FreeBSD: stable/11/release/scripts/pkg-stage.sh 338859 2018-09-21 15:58:08Z gjb $
4258307Sgjb#
5258307Sgjb
6258307Sgjbset -e
7258307Sgjb
8266553Sgjbexport ASSUME_ALWAYS_YES="YES"
9260772Sgjbexport PKG_DBDIR="/tmp/pkg"
10260772Sgjbexport PERMISSIVE="YES"
11260772Sgjbexport REPO_AUTOUPDATE="NO"
12260772Sgjbexport PKGCMD="/usr/sbin/pkg -d"
13318853Sgjbexport PORTSDIR="${PORTSDIR:-/usr/ports}"
14258307Sgjb
15276827Sgjb_DVD_PACKAGES="archivers/unzip
16260772Sgjbdevel/subversion
17260772Sgjbdevel/subversion-static
18300860Sgjbemulators/linux_base-c6
19260772Sgjbmisc/freebsd-doc-all
20260772Sgjbnet/mpd5
21260772Sgjbnet/rsync
22260772Sgjbports-mgmt/pkg
23260772Sgjbports-mgmt/portmaster
24260772Sgjbshells/bash
25260772Sgjbshells/zsh
26260772Sgjbsecurity/sudo
27260772Sgjbsysutils/screen
28318291Semastesysutils/tmux
29260772Sgjbwww/firefox
30260772Sgjbwww/links
31260772Sgjbx11-drivers/xf86-video-vmware
32276828Sgjbx11/gnome3
33338859Sgjbx11/kde5
34260772Sgjbx11/xorg"
35258307Sgjb
36259246Sgjb# If NOPORTS is set for the release, do not attempt to build pkg(8).
37318853Sgjbif [ ! -f ${PORTSDIR}/Makefile ]; then
38318853Sgjb	echo "*** ${PORTSDIR} is missing!    ***"
39276820Sgjb	echo "*** Skipping pkg-stage.sh     ***"
40276820Sgjb	echo "*** Unset NOPORTS to fix this ***"
41259246Sgjb	exit 0
42259246Sgjbfi
43259246Sgjb
44258307Sgjbif [ ! -x /usr/local/sbin/pkg ]; then
45276822Sgjb	/etc/rc.d/ldconfig restart
46318853Sgjb	/usr/bin/make -C ${PORTSDIR}/ports-mgmt/pkg install clean
47258307Sgjbfi
48258307Sgjb
49276765Sgjbexport DVD_DIR="dvd/packages"
50271491Sgjbexport PKG_ABI=$(pkg config ABI)
51276765Sgjbexport PKG_ALTABI=$(pkg config ALTABI 2>/dev/null)
52276765Sgjbexport PKG_REPODIR="${DVD_DIR}/${PKG_ABI}"
53260772Sgjb
54271491Sgjb/bin/mkdir -p ${PKG_REPODIR}
55276765Sgjbif [ ! -z "${PKG_ALTABI}" ]; then
56276766Sgjb	(cd ${DVD_DIR} && ln -s ${PKG_ABI} ${PKG_ALTABI})
57276765Sgjbfi
58258307Sgjb
59276827Sgjb# Ensure the ports listed in _DVD_PACKAGES exist to sanitize the
60276827Sgjb# final list.
61276827Sgjbfor _P in ${_DVD_PACKAGES}; do
62318853Sgjb	if [ -d "${PORTSDIR}/${_P}" ]; then
63276827Sgjb		DVD_PACKAGES="${DVD_PACKAGES} ${_P}"
64276827Sgjb	else
65276827Sgjb		echo "*** Skipping nonexistent port: ${_P}"
66276827Sgjb	fi
67276827Sgjbdone
68276827Sgjb
69276827Sgjb# Make sure the package list is not empty.
70276827Sgjbif [ -z "${DVD_PACKAGES}" ]; then
71276827Sgjb	echo "*** The package list is empty."
72276827Sgjb	echo "*** Something is very wrong."
73276827Sgjb	# Exit '0' so the rest of the build process continues
74276827Sgjb	# so other issues (if any) can be addressed as well.
75276827Sgjb	exit 0
76276827Sgjbfi
77276827Sgjb
78260772Sgjb# Print pkg(8) information to make debugging easier.
79260772Sgjb${PKGCMD} -vv
80258307Sgjb${PKGCMD} update -f
81271491Sgjb${PKGCMD} fetch -o ${PKG_REPODIR} -d ${DVD_PACKAGES}
82258307Sgjb
83271876Sgjb# Create the 'Latest/pkg.txz' symlink so 'pkg bootstrap' works
84271876Sgjb# using the on-disc packages.
85271876Sgjbmkdir -p ${PKG_REPODIR}/Latest
86271876Sgjb(cd ${PKG_REPODIR}/Latest && \
87271876Sgjb	ln -s ../All/$(${PKGCMD} rquery %n-%v pkg).txz pkg.txz)
88271876Sgjb
89271480Sgjb${PKGCMD} repo ${PKG_REPODIR}
90258307Sgjb
91258307Sgjb# Always exit '0', even if pkg(8) complains about conflicts.
92258307Sgjbexit 0
93