287 lines
9.1 KiB
Bash
287 lines
9.1 KiB
Bash
#!/bin/sh
|
|
# $NetBSD: pre-build,v 1.76 2010/05/11 18:36:15 mbalmer Exp $
|
|
#
|
|
# Clean up system to be ready for bulk pkg build
|
|
#
|
|
# (c) 2000 Hubert Feyrer, All Rights Reserved.
|
|
#
|
|
|
|
#set -v # Debug
|
|
|
|
# Pull in USR_PKGSRC:
|
|
if [ -f "$BULK_BUILD_CONF" ]; then
|
|
. "$BULK_BUILD_CONF"
|
|
else
|
|
. `dirname $0`/build.conf
|
|
fi
|
|
|
|
PRUNEDISTFILES=${PRUNEDISTFILES:-"no"}
|
|
PRUNEPACKAGES=${PRUNEPACKAGES:-"yes"}
|
|
PRUNELINKS=${PRUNEPACKAGES:-"yes"}
|
|
PKG_ADMIN="pkg_admin"
|
|
PKG_INFO="pkg_info"
|
|
|
|
some_package_dir=${USR_PKGSRC}/pkgtools/lintpkgsrc
|
|
|
|
# Extract the name of the files used for the build log and broken build log.
|
|
# These have defaults set by bsd.bulk-pkg.mk and may be overridden in
|
|
# /etc/mk.conf
|
|
BULKFILESDIR=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BULKFILESDIR )`;
|
|
if [ "$BULKFILESDIR" = "" ]; then
|
|
echo "pre-build> Had problems determining the directory of .broken* files"
|
|
exit 1
|
|
fi
|
|
BROKENF=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BROKENFILE )`;
|
|
if [ "$BROKENF" = "" ]; then
|
|
echo "pre-build> Had problems determining the name of the .broken files"
|
|
exit 1
|
|
fi
|
|
NOTAVAILF=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=NOT_AVAILABLE_FILE )`;
|
|
if [ "$NOTAVAILF" = "" ]; then
|
|
echo "pre-build> Had problems determining the name of the .bulk-not_available files"
|
|
exit 1
|
|
fi
|
|
BRKWRKLOG=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BROKENWRKLOG )`;
|
|
if [ "$BRKWRKLOG" = "" ]; then
|
|
echo "pre-build> Had problems determining the name of the .broken.work files"
|
|
exit 1
|
|
fi
|
|
BLDLOG=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BUILDLOG )`;
|
|
if [ "$BLDLOG" = "" ]; then
|
|
echo "pre-build> Had problems determining the name of the .make files"
|
|
exit 1
|
|
fi
|
|
LINTPKGSRC_DB=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=LINTPKGSRC_DB )`;
|
|
if [ "$LINTPKGSRC_DB" = "" ]; then
|
|
echo "pre-build> Had problems determining the name of the .lintpkgsrc.db file"
|
|
exit 1
|
|
fi
|
|
STARTFILE=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=STARTFILE )`;
|
|
if [ "$STARTFILE" = "" ]; then
|
|
echo "pre-build> Had problems determining the name of the .start file"
|
|
exit 1
|
|
fi
|
|
|
|
LOCALBASE=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=LOCALBASE )`;
|
|
X11BASE=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=X11BASE )`;
|
|
DISTDIR=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=DISTDIR )`;
|
|
|
|
# Create ${BULKFILESDIR} if necessary
|
|
echo "pre-build> Creating ${BULKFILESDIR} if necessary"
|
|
mkdir -p "${BULKFILESDIR}"
|
|
|
|
# Make sure the pkg-vulnerabilities file is up to date
|
|
_INFO_VER=`${PKG_INFO} -V`;
|
|
echo "pre-build> Making sure vulnerability-list is up to date:"
|
|
if [ -z "$UPDATE_VULNERABILITY_LIST" -o "$UPDATE_VULNERABILITY_LIST" = yes ]; then
|
|
_PKGVULNDIR=`audit-packages ${AUDIT_PACKAGES_FLAGS} -Q PKGVULNDIR`
|
|
download-vulnerability-list ${DOWNLOAD_VULNERABILITY_LIST_FLAGS}
|
|
if [ "x${_PKGVULNDIR}" != "x${DISTDIR}" ]; then
|
|
cp ${_PKGVULNDIR}/pkg-vulnerabilities ${DISTDIR}
|
|
fi
|
|
echo 'pre-build> done.'
|
|
else
|
|
echo 'pre-build> (skipped)'
|
|
fi
|
|
|
|
# On non-NetBSD platforms we need to keep the bootstrap-files!
|
|
if [ x"$BMAKE" = x"bmake" ]; then
|
|
( cd "$LOCALBASE" && tar cf /tmp/$$.tar \
|
|
sbin/audit-packages sbin/download-vulnerability-list \
|
|
sbin/pkg_add sbin/pkg_admin sbin/pkg_create \
|
|
sbin/pkg_delete sbin/pkg_info \
|
|
share/mk/sys.mk share/mk/bsd.dep.mk share/mk/bsd.depall.mk \
|
|
share/mk/bsd.files.mk share/mk/bsd.hostprog.mk \
|
|
share/mk/bsd.doc.mk share/mk/bsd.inc.mk share/mk/bsd.info.mk \
|
|
share/mk/bsd.kernobj.mk share/mk/bsd.kinc.mk \
|
|
share/mk/bsd.kmod.mk share/mk/bsd.lib.mk \
|
|
share/mk/bsd.links.mk share/mk/bsd.man.mk \
|
|
share/mk/bsd.nls.mk share/mk/bsd.obj.mk \
|
|
share/mk/bsd.prog.mk share/mk/bsd.subdir.mk \
|
|
share/mk/bsd.sys.mk share/mk/bsd.own.mk share/mk/bsd.README \
|
|
bin/bmake bin/nawk bin/nbsed bin/pdksh bin/install-sh \
|
|
man/cat1/nbsed.0 man/cat1/pkg_add.0 man/cat1/pkg_admin.0 \
|
|
man/cat1/pkg_create.0 man/cat1/pkg_delete.0 \
|
|
man/cat1/pkg_info.0 man/cat5/pkg_install.conf.0 \
|
|
man/cat5/pkg_summary.0 man/cat7/pkgsrc.0 man/man1/bmake.1 \
|
|
man/man1/nawk.1 man/man1/nbsed.1 man/man1/pkg_add.1 \
|
|
man/man1/pkg_admin.1 man/man1/pkg_create.1 \
|
|
man/man1/pkg_delete.1 man/man1/pkg_info.1 man/man1/pdksh.1 \
|
|
man/man5/pkg_install.conf.5 man/man5/pkg_summary.5 \
|
|
man/man7/pkgsrc.7 etc/mk.conf )
|
|
fi
|
|
|
|
#
|
|
# Clean out everything and its mother
|
|
#
|
|
PKG_DBDIR=`(cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=PKG_DBDIR)`
|
|
DEPOTBASE=`(cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=DEPOTBASE)`
|
|
PKG_TOOLS_BIN=`(cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=PKG_TOOLS_BIN)`
|
|
|
|
for dbdir in "${PKG_DBDIR}" "${DEPOTBASE}"; do
|
|
echo "pre-build> Removing all installed packages in ${dbdir}"
|
|
|
|
# The Solaris /bin/sh requires the following weird-looking code.
|
|
if (cd "$dbdir" 1>/dev/null 2>&1); then
|
|
cd "$dbdir"
|
|
|
|
for pkg in *
|
|
do
|
|
if ${PKG_TOOLS_BIN}/pkg_info -K "$dbdir" -qe "$pkg"; then
|
|
echo "pre-build> ${PKG_TOOLS_BIN}/pkg_delete -r ${pkg}"
|
|
${PKG_TOOLS_BIN}/pkg_delete -K "$dbdir" -r "$pkg"
|
|
fi
|
|
done
|
|
#
|
|
# this should have removed everything.
|
|
# Now force any broken pkgs to deinstall.
|
|
#
|
|
for pkg in *
|
|
do
|
|
if ${PKG_TOOLS_BIN}/pkg_info -K "$dbdir" -qe "$pkg"; then
|
|
echo "pre-build> ${PKG_TOOLS_BIN}/pkg_delete -f ${pkg}"
|
|
${PKG_TOOLS_BIN}/pkg_delete -K "$dbdir" -f "$pkg"
|
|
fi
|
|
done
|
|
|
|
# We've tried our best to get rid of the pkgs, now do it
|
|
# the hard way. If it wasn't for stuff in $X11BASE, I
|
|
# wouldn't have hard feelings about this!
|
|
rm -fr *
|
|
fi
|
|
done
|
|
|
|
cd "$LOCALBASE" && rm -fr * && rm -fr .??*;
|
|
if [ x"$BMAKE" = x"bmake" ]; then
|
|
( cd "$LOCALBASE" && tar xf /tmp/$$.tar )
|
|
fi
|
|
|
|
# Stuff known to be broken
|
|
rm -fr "$X11BASE/share/gimp"
|
|
rm -fr "$X11BASE/share/gnome"
|
|
rm -fr "$X11BASE/share/kde"
|
|
rm -fr "$X11BASE/share/netscape"
|
|
rm -fr /var/tmp/inst*
|
|
rm -fr "$X11BASE/lib/libgimp"* # gimp doesn't build with old libs around
|
|
rm -fr /nonexistent # broken useradd on pop3d
|
|
rm -fr /home/majordom # mail/majordomo pkg
|
|
rm -fr /home/nut # sysutils/ups-net
|
|
rm -fr /var/wwwoffle # www/wwwoffle
|
|
rm -fr /tmp/config-guess-*
|
|
rm -fr /tmp/mod*
|
|
|
|
|
|
# Clean up state files
|
|
cd "${USR_PKGSRC}"
|
|
echo "pre-build> Cleaning up leftover state files from previous runs"
|
|
rm -f "${BULKFILESDIR}"/*/*/$BROKENF "${BULKFILESDIR}"/*/*/$BRKWRKLOG "${BULKFILESDIR}"/*/*/$BLDLOG
|
|
rm -f "${BULKFILESDIR}"/*/*/$NOTAVAILF
|
|
rm -f "${BULKFILESDIR}/$BROKENF" "${BULKFILESDIR}/$BRKWRKLOG" "${BULKFILESDIR}/$BLDLOG" "$STARTFILE"
|
|
|
|
|
|
#
|
|
# Remove old/broken distfiles and binary packages
|
|
#
|
|
PACKAGES=`( cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=PACKAGES )`
|
|
|
|
case "$LINTPKGSRC_CACHE$PRUNEDISTFILES$PRUNEPACKAGES" in
|
|
*yes*|*YES*)
|
|
# install lintpkgsrc to support any of these options
|
|
( cd "${USR_PKGSRC}/pkgtools/lintpkgsrc" && ${BMAKE} PRECLEAN=yes bulk-install )
|
|
;;
|
|
esac
|
|
|
|
case "$LINTPKGSRC_CACHE" in
|
|
yes|YES)
|
|
echo "pre-build> Creating lintpkgsrc cache database."
|
|
lintpkgsrc -K "$PACKAGES" -P "$USR_PKGSRC" -M "$DISTDIR" -E "$LINTPKGSRC_DB"
|
|
lintpkgsrc_cache="-I $LINTPKGSRC_DB"
|
|
echo "pre-build> done."
|
|
;;
|
|
*)
|
|
lintpkgsrc_cache=''
|
|
;;
|
|
esac
|
|
|
|
case "$PRUNEDISTFILES" in
|
|
yes|YES)
|
|
echo "pre-build> Removing old/broken distfiles"
|
|
lintpkgsrc $lintpkgsrc_cache -K "$PACKAGES" -P "$USR_PKGSRC" -M "$DISTDIR" -o -m -r
|
|
echo "pre-build> done."
|
|
;;
|
|
*)
|
|
echo "pre-build> Skipping distfile pruning."
|
|
;;
|
|
esac
|
|
|
|
case "$PRUNEPACKAGES" in
|
|
yes|YES)
|
|
echo "pre-build> Removing old (out of date) binary packages"
|
|
lintpkgsrc $lintpkgsrc_cache -K "$PACKAGES" -P "$USR_PKGSRC" -M "$DISTDIR" -p -r
|
|
echo "pre-build> done."
|
|
;;
|
|
*)
|
|
echo "pre-build> Skipping packages pruning."
|
|
;;
|
|
esac
|
|
|
|
case "$PRUNELINKS" in
|
|
yes|YES)
|
|
echo "pre-build> Checking for and removing orphaned packages links"
|
|
find "$PACKAGES" -type l -print | \
|
|
while read f
|
|
do
|
|
if [ ! -d "$f" -a ! -f "$f" ]; then
|
|
echo "pre-build> Removing orphaned link: \"$f\""
|
|
rm "$f"
|
|
fi
|
|
done
|
|
echo "pre-build> done."
|
|
;;
|
|
*)
|
|
echo "pre-build> Skipping pruning of packages links."
|
|
;;
|
|
esac
|
|
|
|
# Clean out the packages added above so that the real bulk build
|
|
# is started in a consistent state.
|
|
for dbdir in "${PKG_DBDIR}" "${DEPOTBASE}"; do
|
|
echo "pre-build> Removing all installed packages in ${dbdir}"
|
|
if [ -d "$dbdir" ]; then
|
|
cd "$dbdir"
|
|
for pkg in *
|
|
do
|
|
if ${PKG_TOOLS_BIN}/pkg_info -K "$dbdir" -qe "$pkg"; then
|
|
echo "pre-build> ${PKG_TOOLS_BIN}/pkg_delete -r ${pkg}"
|
|
${PKG_TOOLS_BIN}/pkg_delete -K "$dbdir" -r "$pkg"
|
|
fi
|
|
done
|
|
fi
|
|
done
|
|
|
|
# on non-NetBSD, we don't want these to build as they overwrite
|
|
# bootstrap-pkgsrc generated files and thus would break the following builds.
|
|
|
|
if [ x"$BMAKE" = x"bmake" ]; then
|
|
for pkg in devel/bmake devel/mk-files lang/nawk \
|
|
pkgtools/bootstrap-mk-files pkgtools/bootstrap-extras \
|
|
pkgtools/pkg_install \
|
|
shells/pdksh sysutils/install-sh textproc/nbsed; do
|
|
mkdir -p "${BULKFILESDIR}/${pkg}"
|
|
echo "Don't blow away bootstrap-pkgsrc stuff!" \
|
|
> "${BULKFILESDIR}/${pkg}/${BROKENF}"
|
|
done
|
|
fi
|
|
|
|
cd "${USR_PKGSRC}"
|
|
|
|
if [ -f mk/bulk/pre-build.local ]; then
|
|
export BROKENF
|
|
. mk/bulk/pre-build.local
|
|
fi
|
|
|
|
if [ ! -d "${PKG_DBDIR}" ]; then
|
|
mkdir -p "${PKG_DBDIR}"
|
|
fi
|
|
|
|
echo "This file marks the start time of the bulk build." > "$STARTFILE"
|