buildxenocararelease.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #! /bin/sh
  2. set -e
  3. usage() {
  4. _exit_code=${1-1}
  5. echo "usage: $0 [-d DEST_MOUTPOINT] [-o RELEASEDIR]"
  6. exit ${_exit_code}
  7. }
  8. unset DESTDIR RELEASEDIR
  9. while getopts "d:ho:" c; do
  10. case "$c" in
  11. d) DESTDIR=$OPTARG
  12. ;;
  13. h) usage 0
  14. ;;
  15. o) RELEASEDIR=$OPTARG
  16. ;;
  17. esac
  18. done
  19. _setup_destdir() {
  20. mount | cut -d ' ' -f 3 | grep -q "^${1}$" && {
  21. echo "Mountpoint ${1} already mounted..." >&2
  22. exit 1
  23. }
  24. test -d "${1}" || {
  25. echo "Mountpoint ${1} does not exist..." >&2
  26. exit 1
  27. }
  28. mount_mfs -o noperm -s $((812 * 512 * 4)) swap "${1}"
  29. chown build "${1}"
  30. chmod 700 "${1}"
  31. }
  32. _cleanup_destdir() {
  33. local _mp_destdir=$1
  34. test -n "${_mp_destdir}" && umount "${_mp_destdir}"
  35. }
  36. # Only root
  37. _uid=$(id -u)
  38. if [ ${_uid} -ne 0 ]; then
  39. echo "Requires root credentials to go on..." >&2
  40. exit 1
  41. fi
  42. # Find the xenocara sources
  43. if [ -e /etc/mk.conf ]; then
  44. XSRCDIR=${XSRCDIR:-`make -f /etc/mk.conf -V XSRCDIR`}
  45. fi
  46. XSRCDIR=${XSRCDIR:=/usr/xenocara}
  47. # Find out which release directory we are going to use
  48. _release=$(uname -r)
  49. # Must be on a snapshot if no Tag file exists in CVS
  50. if [ \! -e "${XSRCDIR}/CVS/Tag" ]; then
  51. _release=snapshots
  52. fi
  53. _arch=$(uname -m)
  54. DESTDIR=${DESTDIR-/release}
  55. RELEASEDIR=${RELEASEDIR-/var/www/htdocs/pub/OpenBSD/${_release}/${_arch}}
  56. export DESTDIR
  57. export RELEASEDIR
  58. mkdir -p "${RELEASEDIR}"
  59. chown build.wheel "${RELEASEDIR}"
  60. _setup_destdir "${DESTDIR}"
  61. trap "_cleanup_destdir '${DESTDIR}'" EXIT
  62. cd "${XSRCDIR}" && nice make release checkdist
  63. RESULT=$?
  64. if [ -f ${RELEASEDIR}/SHA256 ]; then
  65. cp ${RELEASEDIR}/SHA256{,.xenocara}
  66. if [ -f ${RELEASEDIR}/SHA256.base ]; then
  67. cat ${RELEASEDIR}/SHA256.{base,xenocara} > ${RELEASEDIR}/SHA256
  68. fi
  69. fi
  70. unset RELEASEDIR DESTDIR
  71. exit ${RESULT}