123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #!/bin/sh
- set -e
- usage() {
- _exit_code=${1-1}
- echo "usage: $0 [-d DEST_MOUTPOINT] [-o RELEASEDIR]"
- exit ${_exit_code}
- }
- _check_packages() {
- local _arch=${1} _req_pkgs _pkg
- case "${_arch}" in
- arm | aarch64)
- set -A _req_pkgs sysutils/{dtb,u-boot\,${_arch}}
- ;;
- *)
- echo ${_arch}
- set -A _req_pkgs
- ;;
- esac
- echo "Checking for prerequisite packages..."
- for _pkg in ${_req_pkgs[@]} ; do
- pkg_info -q -e ${_pkg} || {
- echo "Missing package ${_pkg}, aborting..." >&2
- exit 1
- }
- echo "Found ${_pkg}"
- 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 $((712 * 512 * 4)) swap "${1}"
- chown build "${1}"
- chmod 700 "${1}"
- }
- _cleanup_destdir() {
- local _mp_destdir=$1
- test -n ${_mp_destdir} && umount "${_mp_destdir}"
- }
- unset DESTDIR RELEASEDIR
- while getopts "d:ho:" c; do
- case "$c" in
- d) DESTDIR=$OPTARG
- ;;
- h) usage 0
- ;;
- o) RELEASEDIR=$OPTARG
- ;;
- *) usage
- ;;
- esac
- done
- # Required packages for release building on arm64
- _uboot_arch=$(arch -s)
- _check_packages ${_uboot_arch}
- # Only root
- _uid=$(id -u)
- if [ ${_uid} -ne 0 ]; then
- echo "Requires root credentials to go on..." >&2
- exit 1
- fi
- # Find the system source tree, default to /usr/src
- if [ -e /etc/mk.conf ]; then
- BSDSRCDIR=$(make -f /etc/mk.conf -V BSDSRCDIR)
- fi
- BSDSRCDIR=${BSDSRCDIR:=/usr/src}
- # 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 "${BSDSRCDIR}/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 "${BSDSRCDIR}"/etc && nice make release
- if [ $? -ne 0 ]; then
- unset RELEASEDIR DESTDIR
- exit 1
- fi
- cd "${BSDSRCDIR}"/distrib/sets && sh checkflist
- RESULT=$?
- [[ -f ${RELEASEDIR}/SHA256 ]] && cp ${RELEASEDIR}/SHA256{,.base}
- unset RELEASEDIR DESTDIR
- exit ${RESULT}
|