From owner-svn-src-stable@FreeBSD.ORG Wed Aug 26 20:57:21 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DDC491065691; Wed, 26 Aug 2009 20:57:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB3018FC2C; Wed, 26 Aug 2009 20:57:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7QKvLun073740; Wed, 26 Aug 2009 20:57:21 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7QKvLKP073739; Wed, 26 Aug 2009 20:57:21 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <200908262057.n7QKvLKP073739@svn.freebsd.org> From: Doug Barton Date: Wed, 26 Aug 2009 20:57:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196564 - in stable/8/release: . doc scripts X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 20:57:22 -0000 Author: dougb Date: Wed Aug 26 20:57:21 2009 New Revision: 196564 URL: http://svn.freebsd.org/changeset/base/196564 Log: MFC 196434: Add a script to create the /var/db/mergemaster.mtree file for new releases so that when users subsequently update their source trees they can make use of mergemaster's -U option. Approved by: re (kib) Added: stable/8/release/scripts/mm-mtree.sh - copied unchanged from r196434, head/release/scripts/mm-mtree.sh Modified: stable/8/release/ (props changed) stable/8/release/doc/ (props changed) Copied: stable/8/release/scripts/mm-mtree.sh (from r196434, head/release/scripts/mm-mtree.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/release/scripts/mm-mtree.sh Wed Aug 26 20:57:21 2009 (r196564, copy of r196434, head/release/scripts/mm-mtree.sh) @@ -0,0 +1,155 @@ +#!/bin/sh + +# mergemaster mtree database generator + +# This script is intended to be used as part of the release building +# process to generate the /var/db/mergemaster.mtree file relevant to +# the source tree used to create the release so that users can make +# use of mergemaster's -U option to update their files after csup'ing +# to -stable. + +# Copyright 2009 Douglas Barton +# dougb@FreeBSD.org + +# $FreeBSD$ + +PATH=/bin:/usr/bin:/usr/sbin + +display_usage () { + VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` + echo "${0##*/} version ${VERSION_NUMBER}" + echo "Usage: ${0##*/} [-m /path] [-t /path] [-A arch] [-F ] [-D /path]" + echo "Options:" + echo " -m /path/directory Specify location of source to do the make in" + echo " -t /path/directory Specify temp root directory" + echo " -A architecture Alternative architecture name to pass to make" + echo " -F Specify what to put on the make command line" + echo ' -D /path/directory Specify the destination directory to install files to' + echo '' +} + +# Set the default path for the temporary root environment +# +TEMPROOT='/var/tmp/temproot' + +# Assign the location of the mtree database +# +MTREEDB=${MTREEDB:-/var/db} +MTREEFILE="${MTREEDB}/mergemaster.mtree" + +# Check the command line options +# +while getopts "m:t:A:F:D:h" COMMAND_LINE_ARGUMENT ; do + case "${COMMAND_LINE_ARGUMENT}" in + m) + SOURCEDIR=${OPTARG} + ;; + t) + TEMPROOT=${OPTARG} + ;; + A) + ARCHSTRING='TARGET_ARCH='${OPTARG} + ;; + F) + MM_MAKE_ARGS="${OPTARG}" + ;; + D) + DESTDIR=${OPTARG} + ;; + h) + display_usage + exit 0 + ;; + *) + echo '' + display_usage + exit 1 + ;; + esac +done + +# Assign the source directory +# +SOURCEDIR=${SOURCEDIR:-/usr/src} +if [ ! -f ${SOURCEDIR}/Makefile.inc1 -a \ + -f ${SOURCEDIR}/../Makefile.inc1 ]; then + echo " *** The source directory you specified (${SOURCEDIR})" + echo " will be reset to ${SOURCEDIR}/.." + echo '' + sleep 3 + SOURCEDIR=${SOURCEDIR}/.. +fi + +# Setup make to use system files from SOURCEDIR +MM_MAKE="make ${ARCHSTRING} ${MM_MAKE_ARGS} -m ${SOURCEDIR}/share/mk" + +delete_temproot () { + rm -rf "${TEMPROOT}" 2>/dev/null + chflags -R 0 "${TEMPROOT}" 2>/dev/null + rm -rf "${TEMPROOT}" || exit 1 +} + +[ -d "${TEMPROOT}" ] && delete_temproot + +echo "*** Creating the temporary root environment in ${TEMPROOT}" + +if mkdir -p "${TEMPROOT}"; then + echo " *** ${TEMPROOT} ready for use" +fi + +if [ ! -d "${TEMPROOT}" ]; then + echo '' + echo " *** FATAL ERROR: Cannot create ${TEMPROOT}" + echo '' + exit 1 +fi + +echo " *** Creating and populating directory structure in ${TEMPROOT}" +echo '' + +{ cd ${SOURCEDIR} || { echo "*** Cannot cd to ${SOURCEDIR}" ; exit 1;} + case "${DESTDIR}" in + '') ;; + *) + ${MM_MAKE} DESTDIR=${DESTDIR} distrib-dirs + ;; + esac + od=${TEMPROOT}/usr/obj + ${MM_MAKE} DESTDIR=${TEMPROOT} distrib-dirs && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} _obj SUBDIR_OVERRIDE=etc && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} everything SUBDIR_OVERRIDE=etc && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} DESTDIR=${TEMPROOT} distribution;} || + { echo ''; + echo " *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to"; + echo " the temproot environment"; + echo ''; + exit 1;} + +# We really don't want to have to deal with files like login.conf.db, pwd.db, +# or spwd.db. Instead, we want to compare the text versions, and run *_mkdb. +# Prompt the user to do so below, as needed. +# +rm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd + +# We only need to compare things like freebsd.cf once +find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null + +# Delete stuff we do not need to keep the mtree database small, +# and to make the actual comparison faster. +find ${TEMPROOT}/usr -type l -delete 2>/dev/null +find ${TEMPROOT} -type f -size 0 -delete 2>/dev/null +find -d ${TEMPROOT} -type d -empty -delete 2>/dev/null + +# Build the mtree database in a temporary location. +MTREENEW=`mktemp -t mergemaster.mtree` +mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null + +if [ -s "${MTREENEW}" ]; then + echo "*** Saving mtree database for future upgrades" + test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE} + mv ${MTREENEW} ${DESTDIR}${MTREEFILE} +fi + +delete_temproot + +exit 0