1#!/bin/sh
2#
3# $FreeBSD: stable/10/release/scripts/pkg-stage.sh 338859 2018-09-21 15:58:08Z gjb $
4#
5
6set -e
7
8export ASSUME_ALWAYS_YES="YES"
9export PKG_DBDIR="/tmp/pkg"
10export PERMISSIVE="YES"
11export REPO_AUTOUPDATE="NO"
12export PKGCMD="/usr/sbin/pkg -d"
13export PORTSDIR="${PORTSDIR:-/usr/ports}"
14
15_DVD_PACKAGES="archivers/unzip
16devel/subversion
17devel/subversion-static
18emulators/linux_base-f10
19misc/freebsd-doc-all
20net/mpd5
21net/rsync
22ports-mgmt/pkg
23ports-mgmt/portmaster
24shells/bash
25shells/zsh
26security/sudo
27sysutils/screen
28www/firefox
29www/links
30x11-drivers/xf86-video-vmware
31x11/gnome3
32x11/kde5
33x11/xorg"
34
35# If NOPORTS is set for the release, do not attempt to build pkg(8).
36if [ ! -f ${PORTSDIR}/Makefile ]; then
37	echo "*** ${PORTSDIR} is missing!    ***"
38	echo "*** Skipping pkg-stage.sh     ***"
39	echo "*** Unset NOPORTS to fix this ***"
40	exit 0
41fi
42
43if [ ! -x /usr/local/sbin/pkg ]; then
44	/etc/rc.d/ldconfig restart
45	/usr/bin/make -C ${PORTSDIR}/ports-mgmt/pkg install clean
46fi
47
48export DVD_DIR="dvd/packages"
49export PKG_ABI=$(pkg config ABI)
50export PKG_ALTABI=$(pkg config ALTABI 2>/dev/null)
51export PKG_REPODIR="${DVD_DIR}/${PKG_ABI}"
52
53/bin/mkdir -p ${PKG_REPODIR}
54if [ ! -z "${PKG_ALTABI}" ]; then
55	(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