build 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env sh
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. # Copyright (c) 2014-2015,2020-2024 Leah Rowe <leah@libreboot.org>
  4. # Copyright (c) 2015 Patrick "P. J." McDermott <pj@pehjota.net>
  5. # Copyright (c) 2015-2016 Klemens Nanni <contact@autoboot.org>
  6. # Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
  7. set -u -e
  8. if [ "./${0##*/}" != "${0}" ] || [ ! -f "build" ] || [ -L "build" ]; then
  9. printf "You must run this in the proper work directory.\n" 1>&2
  10. exit 1
  11. fi
  12. . "include/lib.sh"
  13. . "include/vendor.sh"
  14. . "include/mrc.sh"
  15. err="fail"
  16. main()
  17. {
  18. [ $# -lt 1 ] && $err "bad command"
  19. spath="script/$1"; shift 1
  20. [ "${spath#script/}" = "download" ] && vendor_download $@ && return 0
  21. [ -f "$spath" ] || $err "bad command"
  22. "$spath" $@ || $err "excmd: $spath $(echo "$@")"; set -u -e
  23. }
  24. fail()
  25. {
  26. tmp_cleanup || printf "WARNING: can't rm tmpfiles: %s\n" "$TMPDIR" 1>&2
  27. err_ "${1}"
  28. }
  29. tmp_cleanup()
  30. {
  31. [ "$xbmk_parent" = "y" ] || return 0
  32. [ "$TMPDIR" = "/tmp" ] || rm -Rf "$TMPDIR" || return 1
  33. rm -f lock || return 1
  34. }
  35. main $@
  36. tmp_cleanup || err_ "can't rm TMPDIR upon non-zero exit: $TMPDIR"