generate-release.sh revision 261706
1219508Snwhitehorn#!/bin/sh 2251650Snwhitehorn#- 3251650Snwhitehorn# Copyright (c) 2011 Nathan Whitehorn 4251650Snwhitehorn# All rights reserved. 5251650Snwhitehorn# 6251650Snwhitehorn# Redistribution and use in source and binary forms, with or without 7251650Snwhitehorn# modification, are permitted provided that the following conditions 8251650Snwhitehorn# are met: 9251650Snwhitehorn# 1. Redistributions of source code must retain the above copyright 10251650Snwhitehorn# notice, this list of conditions and the following disclaimer. 11251650Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright 12251650Snwhitehorn# notice, this list of conditions and the following disclaimer in the 13251650Snwhitehorn# documentation and/or other materials provided with the distribution. 14251650Snwhitehorn# 15251650Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16251650Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17251650Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18251650Snwhitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19251650Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20251650Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21251650Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22251650Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23251650Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24251650Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25251650Snwhitehorn# SUCH DAMAGE. 26251650Snwhitehorn# 27251650Snwhitehorn# $FreeBSD: stable/10/release/generate-release.sh 261706 2014-02-10 07:16:46Z gjb $ 28251650Snwhitehorn# 29219508Snwhitehorn 30219508Snwhitehorn# generate-release.sh: check out source trees, and build release components with 31219610Snwhitehorn# totally clean, fresh trees. 32219508Snwhitehorn# 33246283Shrs# Usage: generate-release.sh svn-branch[@revision] scratch-dir 34219508Snwhitehorn# 35219508Snwhitehorn# Environment variables: 36246283Shrs# SVNROOTBASE: SVN base URL to FreeBSD repository (svn://svn.freebsd.org) 37246283Shrs# SVNROOTSRC: URL to FreeBSD src tree (${SVNROOTBASE}/base) 38246283Shrs# SVNROOTDOC: URL to FreeBSD doc tree (${SVNROOTBASE}/doc) 39246283Shrs# SVNROOTPORTS:URL to FreeBSD ports tree (${SVNROOTBASE}/ports) 40246283Shrs# BRANCHSRC: branch name of src (svn-branch[@revision]) 41246283Shrs# BRANCHDOC: branch name of doc (head) 42246283Shrs# BRANCHPORTS: branch name of ports (head) 43246283Shrs# WORLD_FLAGS: optional flags to pass to buildworld (e.g. -j) 44246283Shrs# KERNEL_FLAGS: optional flags to pass to buildkernel (e.g. -j) 45219508Snwhitehorn# 46219508Snwhitehorn 47230106Sglebiususage() 48230106Sglebius{ 49246283Shrs echo "Usage: $0 svn-branch[@revision] scratch-dir" 2>&1 50230106Sglebius exit 1 51230106Sglebius} 52230106Sglebius 53230106Sglebiusif [ $# -lt 2 ]; then 54230106Sglebius usage 55230106Sglebiusfi 56230106Sglebius 57246283Shrs: ${SVNROOTBASE:=svn://svn.freebsd.org} 58246283Shrs: ${SVNROOTSRC:=${SVNROOTBASE}/base} 59246283Shrs: ${SVNROOTDOC:=${SVNROOTBASE}/doc} 60246283Shrs: ${SVNROOTPORTS:=${SVNROOTBASE}/ports} 61246283Shrs: ${SVNROOT:=${SVNROOTSRC}} # for backward compatibility 62246283Shrs: ${SVN_CMD:=/usr/local/bin/svn} 63246283ShrsBRANCHSRC=$1 64246283Shrs: ${BRANCHDOC:=head} 65246283Shrs: ${BRANCHPORTS:=head} 66246283Shrs: ${WORLD_FLAGS:=${MAKE_FLAGS}} 67246283Shrs: ${KERNEL_FLAGS:=${MAKE_FLAGS}} 68246283Shrs: ${CHROOTDIR:=$2} 69246283Shrs 70246283Shrsif [ ! -r "${CHROOTDIR}" ]; then 71246283Shrs echo "${CHROOTDIR}: scratch dir not found." 72246283Shrs exit 1 73246283Shrsfi 74246283Shrs 75246283ShrsCHROOT_CMD="/usr/sbin/chroot ${CHROOTDIR}" 76246283Shrscase ${TARGET} in 77246283Shrs"") ;; 78246283Shrs*) SETENV_TARGET="TARGET=$TARGET" ;; 79246283Shrsesac 80246283Shrscase ${TARGET_ARCH} in 81246283Shrs"") ;; 82246283Shrs*) SETENV_TARGET_ARCH="TARGET_ARCH=$TARGET_ARCH" ;; 83246283Shrsesac 84246283ShrsSETENV="env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin" 85246283ShrsCROSSENV="${SETENV_TARGET} ${SETENV_TARGET_ARCH}" 86246283ShrsWMAKE="make -C /usr/src ${WORLD_FLAGS}" 87246283ShrsNWMAKE="${WMAKE} __MAKE_CONF=/dev/null SRCCONF=/dev/null" 88246283ShrsKMAKE="make -C /usr/src ${KERNEL_FLAGS}" 89246283ShrsRMAKE="make -C /usr/src/release" 90246283Shrs 91240967Sgjbif [ $(id -u) -ne 0 ]; then 92240967Sgjb echo "Needs to be run as root." 93240967Sgjb exit 1 94240967Sgjbfi 95240967Sgjb 96221510Snwhitehornset -e # Everything must succeed 97221510Snwhitehorn 98246283Shrsmkdir -p ${CHROOTDIR}/usr/src 99246283Shrs${SVN_CMD} co ${SVNROOT}/${BRANCHSRC} ${CHROOTDIR}/usr/src 100246283Shrs${SVN_CMD} co ${SVNROOTDOC}/${BRANCHDOC} ${CHROOTDIR}/usr/doc 101246283Shrs${SVN_CMD} co ${SVNROOTPORTS}/${BRANCHPORTS} ${CHROOTDIR}/usr/ports 102230107Sglebius 103246283Shrs${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src ${WORLD_FLAGS} buildworld 104246283Shrs${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src installworld distribution DESTDIR=${CHROOTDIR} 105246283Shrsmount -t devfs devfs ${CHROOTDIR}/dev 106246283Shrstrap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit 107230107Sglebius 108246283Shrsif [ -d ${CHROOTDIR}/usr/doc ]; then 109246283Shrs cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf 110219508Snwhitehorn 111240586Sgjb # Install docproj to build release documentation 112261706Sgjb ${CHROOT_CMD} /etc/rc.d/ldconfig forcerestart 113246283Shrs ${CHROOT_CMD} /bin/sh -c \ 114246283Shrs 'make -C /usr/ports/textproc/docproj \ 115246283Shrs BATCH=yes \ 116246283Shrs WITHOUT_SVN=yes \ 117246283Shrs WITHOUT_JADETEX=yes \ 118246283Shrs WITHOUT_X11=yes \ 119246283Shrs WITHOUT_PYTHON=yes \ 120246283Shrs install' 121219508Snwhitehornfi 122219610Snwhitehorn 123246283Shrs${CHROOT_CMD} ${SETENV} ${CROSSENV} ${WMAKE} buildworld 124246283Shrs${CHROOT_CMD} ${SETENV} ${CROSSENV} ${KMAKE} buildkernel 125246283Shrs${CHROOT_CMD} ${SETENV} ${CROSSENV} ${RMAKE} release 126246283Shrs${CHROOT_CMD} ${SETENV} ${CROSSENV} ${RMAKE} install DESTDIR=/R 127