# Overrides to FreeBSD Update build subroutines for FreeBSD 9.0. # Download and verify a release ISO image. fetchiso () { log "Starting fetch" # Figure out where the disc1 ISO image is RELNUM=${REL%-*} # ISO=${FTP}/${TARGET}/ISO-IMAGES/${RELNUM}/${REL}-${TARGET}-disc1.iso ISO=${FTP}/FreeBSD-${REL}-${TARGET}-disc1.iso # Fetch the ISO image. We consider the ISO image to be # the One True Release and don't look at the files used # for FTP installs. The FreeBSD 4.7-RELEASE ISO and FTP # files were not identical, but this should never happen # again. fetch -o ${WORKDIR}/iso.img -rR ${ISO} 2>&1 log "Verifying dvd1 hash" # Check that the downloaded ISO has the correct hash. if ! [ "`sha256 -q ${WORKDIR}/iso.img`" = "${RELH}" ]; then echo "FreeBSD ${REL}-${TARGET}-dvd1.iso has incorrect hash." rm ${WORKDIR}/iso.img return 1 fi } # Extract the released trees and, if appropriate, construct a world (base # plus source code) in which to perform builds. extractiso () { # Create and mount a md(4) attached to the ISO image. ISOMD=`mdconfig -a -t vnode -f ${WORKDIR}/iso.img -n` mkdir -p ${WORKDIR}/iso mount -t cd9660 -o ro,nosuid /dev/md${ISOMD} ${WORKDIR}/iso # Extract the various components into different directories log "Extracting components" for C in ${WORLDPARTS}; do mkdir -p ${WORKDIR}/release/R/trees/world/${C} cat ${WORKDIR}/iso/usr/freebsd-dist/${C}.txz | tar -xpzf - -C ${WORKDIR}/release/R/trees/world/${C} done for C in ${KERNELPARTS}; do mkdir -p ${WORKDIR}/release/R/trees/kernel/${C} cat ${WORKDIR}/iso/usr/freebsd-dist/${C}.txz | tar -xpzf - -C ${WORKDIR}/release/R/trees/kernel/${C} done for C in ${SOURCEPARTS}; do mkdir -p ${WORKDIR}/release/R/trees/src/${C} cat ${WORKDIR}/iso/usr/freebsd-dist/${C}.txz | tar -xpzf - -C ${WORKDIR}/release/R/trees/src/${C} done # If the release ISO we're handling belongs to the platform # we're running right now, create a world image for future use. if [ ${TARGET} = ${HOSTPLATFORM} ]; then log "Constructing world+src image" # Create directory for world mkdir ${WORKDIR}/world/ # Extract world and source distributions for C in ${WORLDPARTS}; do cat ${WORKDIR}/iso/usr/freebsd-dist/${C}.txz | tar -xpzf - -C ${WORKDIR}/world/ done for C in ${SOURCEPARTS}; do cat ${WORKDIR}/iso/usr/freebsd-dist/${C}.txz | tar -xpzf - -C ${WORKDIR}/world/ done # build a single tarball of them. tar -czf ${WORKDIR}/../world.tgz -C ${WORKDIR}/world . # clean up nuke world fi # Unmount and detach the ISO image md(4). umount ${WORKDIR}/iso rmdir ${WORKDIR}/iso mdconfig -d -u ${ISOMD} } # Perform a build in ${WORKDIR}/$1 with BRANCH_OVERRIDE set to $2 buildworld () { # We need a devfs inside the jail. Note that we are using a # jail here in order to keep the environment as "clean" as # possible, not for security reasons; we assume that the # original source code plus patches we add personally will # not do anything evil. mount -t devfs devfs ${WORKDIR}/$1/dev # We need to be able to set file flags sysctl security.jail.chflags_allowed=1 >/dev/null # Build stuff. jail ${WORKDIR}/$1 ${BUILDHOSTNAME} 127.1.2.3 \ /usr/bin/env -i PATH=${PATH} RELP=${RELP} \ BRANCH_OVERRIDE=$2 VERSION="FreeBSD 9.1-RELEASE amd64 902001" \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ /bin/sh -e <<-"EOF" 2>&1 >${WORKDIR}/$1-build.log # Function for logging what we're doing log () { echo "`date` $1 for FreeBSD/${TARGET} ${RELP}" 1>&2 } # Build the world log "Building world" cd /usr/src && make buildworld -j17 2>&1 # Build and kernel log "Building kernel" cd /usr/src && make buildkernel -j17 2>&1 # Build and install release images log "Building release" cd /usr/src/release && make release 2>&1 && make install DESTDIR=/R 2>&1 EOF # Put all the components into the right places. log "Moving components into staging area" jail ${WORKDIR}/$1 ${BUILDHOSTNAME} 127.1.2.3 \ /usr/bin/env -i PATH=${PATH} \ WORLDPARTS="${WORLDPARTS}" \ KERNELPARTS="${KERNELPARTS}" \ SOURCEPARTS="${SOURCEPARTS}" \ /bin/sh -e <<-"EOF" 2>&1 >>${WORKDIR}/$1-build.log # Create area for uncompressed components mkdir -p /R/trees # Move world components into place for C in ${WORLDPARTS}; do mkdir -p /R/trees/world/${C} cat /R/ftp/${C}.txz | tar -xpzf - -C /R/trees/world/${C} done # Move kernel components into place for C in ${KERNELPARTS}; do mkdir -p /R/trees/kernel/${C} cat /R/ftp/${C}.txz | tar -xpzf - -C /R/trees/kernel/${C} done # Extract src components into place for C in ${SOURCEPARTS}; do mkdir -p /R/trees/src/${C} cat /R/ftp/${C}.txz | tar -xpzf - -C /R/trees/src/${C} done EOF # Get rid of the devfs we no longer need. umount ${WORKDIR}/$1/dev } # Perform a build in ${WORKDIR}/$1, but with the date set 400 days # into the future. Turn off NTP before we change the date and # turn it back on afterwards. futurebuildworld () { # Turn off ntpd if necessary if /etc/rc.d/ntpd status | grep -q 'is running'; then ntpd_was_running=1 log "Turning off NTP" /etc/rc.d/ntpd stop >/dev/null else ntpd_was_running=0 fi date -n `date -j -v+400d "+%y%m%d%H%M.%S"` >/dev/null buildworld $1 FUTUREBUILD date -n `date -j -v-400d "+%y%m%d%H%M.%S"` >/dev/null # Turn ntpd back on, if appropriate if [ ${ntpd_was_running} = 1 ]; then log "Turning NTP back on" /etc/rc.d/ntpd start >/dev/null fi } # Add extra docs to ${WORKDIR}/$1 addextradocs () { log "Extracting extra docs" # 8.0 doesn't have any extra docs } # Fixup: the "kernel" kernel is really the "generic" kernel. indexpublish () { sed -E 's,kernel\|kernel,kernel|generic,' }