From owner-svn-src-head@FreeBSD.ORG Wed Sep 26 18:04:17 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7EC421065672; Wed, 26 Sep 2012 18:04:17 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5EEC08FC0C; Wed, 26 Sep 2012 18:04:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8QI4Hot069206; Wed, 26 Sep 2012 18:04:17 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8QI4H9P069204; Wed, 26 Sep 2012 18:04:17 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201209261804.q8QI4H9P069204@svn.freebsd.org> From: Glen Barber Date: Wed, 26 Sep 2012 18:04:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240967 - head/release X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2012 18:04:17 -0000 Author: gjb (doc,ports committer) Date: Wed Sep 26 18:04:16 2012 New Revision: 240967 URL: http://svn.freebsd.org/changeset/base/240967 Log: - Allow cross-architecture builds with 'generate-release.sh', which is set by specifying '-a '. (Only supported for i386 on amd64 and powerpc on powerpc64 currently). - Change how textproc/docproj is installed: o Attempt to install from pkg(8); o Fall back to pkg_add(1) if pkg(8) installation is not successful; o Fall back to installing from ports as last resort. - Ensure the script is run by root[1]. - Get OSVERSION from param.h[1]. Provided by: glebius [1] Reviewed by: nwhitehorn, kensmith Approved by: kensmith MFC After: 2 weeks X-Needs-MFC: r240586, r240587, r240588 Modified: head/release/generate-release.sh Modified: head/release/generate-release.sh ============================================================================== --- head/release/generate-release.sh Wed Sep 26 17:25:15 2012 (r240966) +++ head/release/generate-release.sh Wed Sep 26 18:04:16 2012 (r240967) @@ -17,17 +17,47 @@ # $FreeBSD$ # +unset B_ARCH +unset ARCH +unset MACHINE_ARCH + +HOST_ARCH=`uname -p` + usage() { - echo "Usage: $0 [-r revision] [-d docrevision] [-p portsrevision] svn-branch scratch-dir" + echo "Usage: $0 [-a arch] [-r revision] [-d docrevision] [-p portsrevision] svn-branch scratch-dir" + exit 1 +} + +arch_error () +{ + echo "Architecture ${OPTARG} cannot be built on host architecture ${HOST_ARCH}" exit 1 } REVISION= DOCREVISION= PORTSREVISION= -while getopts d:r:p: opt; do +while getopts a:d:r:p: opt; do case $opt in + a) + case "${OPTARG}" in + i386|amd64) + if [ "${HOST_ARCH}" != "amd64" ]; then + arch_error "${OPTARG}" + fi + ;; + powerpc|powerpc64) + if [ "${HOST_ARCH}" != "powerpc64" ]; then + arch_error "${OPTARG}" + fi + ;; + *) + arch_error "${OPTARG}" + ;; + esac + B_ARCH="$OPTARG" + ;; d) DOCREVISION="-r $OPTARG" ;; @@ -44,10 +74,21 @@ while getopts d:r:p: opt; do done shift $(($OPTIND - 1)) +# If target architecture is not specified, use hw.machine_arch +if [ "x${B_ARCH}" == "x" ]; then + B_ARCH="${HOST_ARCH}" +fi +ARCH_FLAGS="ARCH=${B_ARCH} TARGET_ARCH=${B_ARCH}" + if [ $# -lt 2 ]; then usage fi +if [ $(id -u) -ne 0 ]; then + echo "Needs to be run as root." + exit 1 +fi + set -e # Everything must succeed case $MAKE_FLAGS in @@ -65,23 +106,83 @@ svn co ${SVNROOT:-svn://svn.freebsd.org/ svn co ${SVNROOT:-svn://svn.freebsd.org/ports}/head $2/usr/ports $PORTSREVISION cd $2/usr/src -make $MAKE_FLAGS buildworld -make installworld distribution DESTDIR=$2 +make $MAKE_FLAGS ${ARCH_FLAGS} buildworld +make $ARCH_FLAGS installworld distribution DESTDIR=$2 mount -t devfs devfs $2/dev trap "umount $2/dev" EXIT # Clean up devfs mount on exit +# Most commands below are run in chroot, so fake getosreldate(3) right now +OSVERSION=$(grep '#define __FreeBSD_version' $2/usr/include/sys/param.h | awk '{print $3}') +export OSVERSION +BRANCH=$(grep '^BRANCH=' $2/usr/src/sys/conf/newvers.sh | awk -F\= '{print $2}') +BRANCH=`echo ${BRANCH} | sed -e 's,",,g'` +REVISION=$(grep '^REVISION=' $2/usr/src/sys/conf/newvers.sh | awk -F\= '{print $2}') +REVISION=`echo ${REVISION} | sed -e 's,",,g'` +OSRELEASE="${REVISION}-${BRANCH}" + +pkgng_install_docports () +{ + # Attempt to install docproj port from pkgng package. + chroot ${CHROOTDIR} /bin/sh -c 'env ASSUME_ALWAYS_YES=1 /usr/sbin/pkg install -y docproj-nojadetex' + # Check if docproj was installed, since pkg(8) returns '0' if unable + # to install a package from the repository. If it is not installed, + # fallback to installing using pkg_add(1). + chroot ${CHROOTDIR} /bin/sh -c '/usr/sbin/pkg info -q docproj-nojadetex' || \ + pkgadd_install_docports +} + +build_compat9_port () +{ + chroot ${CHROOTDIR} /bin/sh -c 'make -C /usr/ports/misc/compat9x BATCH=yes install clean' +} + +pkgadd_install_docports () +{ + # Attempt to install docproj package with pkg_add(1). + # If not successful, build the docproj port. + if [ "${REVISION}" == "10.0" ]; then + # Packages for 10-CURRENT are still located in the 9-CURRENT + # directory. Override environment to use correct package + # location if building for 10-CURRENT. + PACKAGESITE="ftp://ftp.freebsd.org/pub/FreeBSD/ports/${B_ARCH}/packages-9-current/Latest/" + export PACKAGESITE + PACKAGEROOT="ftp://ftp.freebsd.org/pub/FreeBSD/ports/${B_ARCH}/packages-9-current/" + export PACKAGEROOT + PKG_PATH="ftp://ftp.freebsd.org/pub/FreeBSD/ports/${B_ARCH}/packages-9-current/All/" + export PKG_PATH + build_compat9_port + fi + chroot ${CHROOTDIR} /bin/sh -c '/usr/sbin/pkg_add -r docproj-nojadetex' || \ + build_docports +} + +build_docports() +{ + # Could not install textproc/docproj from pkg(8) or pkg_add(1). Build + # the port as final fallback. + chroot ${CHROOTDIR} /bin/sh -c 'make -C /usr/ports/textproc/docproj BATCH=yes WITH_JADETEX=no WITHOUT_X11=yes WITHOUT_PYTHON=yes install clean' || \ + { echo "*** Could not build the textproj/docproj port. Exiting."; exit 2; } +} + if [ -d $2/usr/doc ]; then cp /etc/resolv.conf $2/etc/resolv.conf # Install docproj to build release documentation - chroot $2 /bin/sh -c '(export ASSUME_ALWAYS_YES=1 && /usr/sbin/pkg install -y docproj) || (cd /usr/ports/textproc/docproj && make install clean BATCH=yes WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes)' + CHROOTDIR="$2" + set +e + pkgng_install_docports "${CHROOTDIR}" + set -e fi -chroot $2 make -C /usr/src $MAKE_FLAGS buildworld buildkernel -chroot $2 make -C /usr/src/release release +chroot $2 make -C /usr/src $MAKE_FLAGS ${ARCH_FLAGS} buildworld buildkernel +chroot $2 make -C /usr/src/release ${ARCH_FLAGS} release chroot $2 make -C /usr/src/release install DESTDIR=/R -: ${RELSTRING=`chroot $2 uname -s`-`chroot $2 uname -r`-`chroot $2 uname -p`} +if [ "x${OSVERSION}" == "x" ]; then + OSRELEASE=`chroot $2 uname -r` +fi + +: ${RELSTRING=`chroot $2 uname -s`-${OSRELEASE}-${B_ARCH}} cd $2/R for i in release.iso bootonly.iso memstick; do