#!/bin/sh # # Update the master ports tree that is used by package builds # and other consumers pbc=${PORTBUILD_CHECKOUT:-/a/portbuild} . ${pbc}/admin/conf/admin.conf . ${pbc}/conf/server.conf base=${ZFS_MOUNTPOINT}/${SNAP_DIRECTORY} zbase=${ZFS_VOLUME}/${SNAP_DIRECTORY} head=${ZFS_MOUNTPOINT}/${SNAP_PORTS_DIRECTORY} zhead=${ZFS_VOLUME}/${SNAP_PORTS_DIRECTORY} VERBOSE=1 stamp() { fulldate=$1 date -j -f %+ "${fulldate}" +%Y%m%d%H%M%S } finish() { err=$1 end=$(date +%s) echo "Finished at $(date)" len=$((end-begin)) echo "Duration = $(date -j -f %s +%H:%M:%S ${len})" exit 1 } begin=$(date +%s) echo "Started at $(date)" uid=${PORTBUILD_USER} if [ ! -z "${PORTBUILD_GROUP}" ]; then gid=${PORTBUILD_GROUP} else gid=${uid} fi # create /a/snap/ if not already there if [ ! -d ${base} ]; then echo "creating new base directory using ${base}" zfs create ${zbase} || finish 1 chown -R ${uid}:${gid} ${base} chmod -R g+w ${base} fi # create /a/snap/ports-head/ if not already there if [ ! -d ${head} ]; then echo "creating new ports-head directory using ${head}" zfs create ${zhead} || finish 1 chown -R ${uid}:${gid} ${head} chmod -R g+w ${head} fi # create /a/snap/ports-head/ports/ if not already there if [ ! -d ${head}/ports ]; then echo "creating new ports-head/ports directory using ${head}/ports" zfs create ${zhead}/ports || finish 1 chown -R ${uid}:${gid} ${head}/ports chmod -R g+w ${head}/ports fi cd ${head} fulldate=$(date) if [ ! -d ${head}/ports/${VCS_SUBDIR} ]; then if [ $VERBOSE ]; then echo "${VCS_CHECKOUT_COMMAND} ${VCS_PORTS_REPOSITORY}/head ${head}/ports" fi ${VCS_CHECKOUT_COMMAND} ${VCS_PORTS_REPOSITORY}/head ${head}/ports || finish 1 else if [ $VERBOSE ]; then echo "${VCS_OVERWRITE_COMMAND} ${head}/ports" fi ${VCS_OVERWRITE_COMMAND} ${head}/ports || finish 1 fi # hack for zfs breakiness find . -group wheel | xargs chgrp ${gid} snapdate=$(stamp ${fulldate}) if [ $VERBOSE ]; then echo "zfs snapshot ${zhead}/ports@${snapdate}" fi zfs snapshot ${zhead}/ports@${snapdate} || finish 1 echo ${fulldate} > ports/.updated finish 0