sign_release.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. set -e
  3. usage() {
  4. _exit_code=${1-1}
  5. echo "usage: $0 [-o RELEASEDIR] -s SECKEY"
  6. exit ${_exit_code}
  7. }
  8. unset DESTDIR RELEASEDIR
  9. while getopts "ho:s:" c; do
  10. case "$c" in
  11. h) usage 0
  12. ;;
  13. o) RELEASEDIR=$OPTARG
  14. ;;
  15. s) SECKEY=$OPTARG
  16. ;;
  17. esac
  18. done
  19. # Only root
  20. _uid=$(id -u)
  21. if [ ${_uid} -ne 0 ]; then
  22. echo "Requires root credentials to go on..." >&2
  23. exit 1
  24. fi
  25. # Find system sources
  26. if [ -e /etc/mk.conf ]; then
  27. BSDSRCDIR=$(make -f /etc/mk.conf -V BSDSRCDIR)
  28. fi
  29. BSDSRCDIR=${BSDSRCDIR:=/usr/src}
  30. # Find out which release directory we are going to use
  31. _release=$(uname -r)
  32. # Must be on a snapshot if no Tag file exists in CVS
  33. if [ \! -e "${BSDSRCDIR}/CVS/Tag" ]; then
  34. _release=snapshots
  35. fi
  36. _arch=$(uname -m)
  37. RELEASEDIR=${RELEASEDIR-/var/www/htdocs/pub/OpenBSD/${_release}/${_arch}}
  38. test -f "${SECKEY}" || {
  39. echo "Private key ${SECKEY} not found";
  40. exit 1;
  41. }
  42. test -f "${RELEASEDIR}"/SHA256.base || {
  43. echo "SHA256.base not found in ${RELEASEDIR}";
  44. exit 1;
  45. }
  46. test -f "${RELEASEDIR}"/SHA256.xenocara || {
  47. echo "SHA256.xenocara not found in ${RELEASEDIR}";
  48. exit 1;
  49. }
  50. cat ${RELEASEDIR}/SHA256.{base,xenocara} > ${RELEASEDIR}/SHA256
  51. signify -S -s "${SECKEY}" -e -x "${RELEASEDIR}"/SHA256.sig -m "${RELEASEDIR}"/SHA256