#! /bin/sh set -e usage() { _exit_code=${1-1} echo "usage: $0 [-d DEST_MOUTPOINT] [-o RELEASEDIR]" exit ${_exit_code} } unset DESTDIR RELEASEDIR while getopts "d:ho:" c; do case "$c" in d) DESTDIR=$OPTARG ;; h) usage 0 ;; o) RELEASEDIR=$OPTARG ;; esac done _setup_destdir() { mount | cut -d ' ' -f 3 | grep -q "^${1}$" && { echo "Mountpoint ${1} already mounted..." >&2 exit 1 } test -d "${1}" || { echo "Mountpoint ${1} does not exist..." >&2 exit 1 } mount_mfs -o noperm -s $((812 * 512 * 4)) swap "${1}" chown build "${1}" chmod 700 "${1}" } _cleanup_destdir() { local _mp_destdir=$1 test -n "${_mp_destdir}" && umount "${_mp_destdir}" } # Only root _uid=$(id -u) if [ ${_uid} -ne 0 ]; then echo "Requires root credentials to go on..." >&2 exit 1 fi # Find the xenocara sources if [ -e /etc/mk.conf ]; then XSRCDIR=${XSRCDIR:-`make -f /etc/mk.conf -V XSRCDIR`} fi XSRCDIR=${XSRCDIR:=/usr/xenocara} # Find out which release directory we are going to use _release=$(uname -r) # Must be on a snapshot if no Tag file exists in CVS if [ \! -e "${XSRCDIR}/CVS/Tag" ]; then _release=snapshots fi _arch=$(uname -m) DESTDIR=${DESTDIR-/release} RELEASEDIR=${RELEASEDIR-/var/www/htdocs/pub/OpenBSD/${_release}/${_arch}} export DESTDIR export RELEASEDIR mkdir -p "${RELEASEDIR}" chown build.wheel "${RELEASEDIR}" _setup_destdir "${DESTDIR}" trap "_cleanup_destdir '${DESTDIR}'" EXIT cd "${XSRCDIR}" && nice make release checkdist RESULT=$? if [ -f ${RELEASEDIR}/SHA256 ]; then cp ${RELEASEDIR}/SHA256{,.xenocara} if [ -f ${RELEASEDIR}/SHA256.base ]; then cat ${RELEASEDIR}/SHA256.{base,xenocara} > ${RELEASEDIR}/SHA256 fi fi unset RELEASEDIR DESTDIR exit ${RESULT}