1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. . "$MKIT_DIR/include/build.sh" || die "cannot import build.sh"
  3. . "$MKIT_DIR/include/deploy.sh" || die "cannot import deploy.sh"
  4. . "$MKIT_DIR/include/release.sh" || die "cannot import release.sh"
  5. . "$MKIT_DIR/include/ini.sh" || die "cannot import ini.sh"
  6. debug() {
  7. #
  8. # Print debug message
  9. #
  10. $MKIT_DEBUG || return 0
  11. echo "MKIT_DEBUG: ${FUNCNAME[1]}()" "$@" >&2
  12. }
  13. debug_var() {
  14. #
  15. # Print debug message
  16. #
  17. $MKIT_DEBUG || return 0
  18. local __mkit_debug_var_name__
  19. for __mkit_debug_var_name__ in "$@";
  20. do
  21. {
  22. echo -n "MKIT_DEBUG: ${FUNCNAME[1]}():"
  23. echo -n " $__mkit_debug_var_name__"
  24. echo -n "='${!__mkit_debug_var_name__}'"
  25. echo
  26. } >&2
  27. done
  28. }
  29. MKIT_INI=${MKIT_INI:-mkit.ini}
  30. MKIT_INI_EXPAND=2
  31. MKIT_PKGNAME=$(ini 1value "ENV:PKGNAME")
  32. MKIT_PROJNAME=$(ini 1value "ENV:PROJNAME")
  33. MKIT_DEFAULT_MODE="644"
  34. mkit_init() {
  35. #
  36. # Do basic initialization
  37. #
  38. # Check for ini file, load variables from config.mk
  39. #
  40. test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
  41. tmp=$(mktemp)
  42. sed -e 's/ = /=/' < config.mk > "$tmp"
  43. . "$tmp"
  44. rm -f "$tmp"
  45. test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
  46. || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
  47. }
  48. die() {
  49. #
  50. # Exit with message and non-zero exit status
  51. #
  52. echo "fatal: $*" >&2
  53. exit 4
  54. }
  55. warn() {
  56. #
  57. # Print warning message
  58. #
  59. echo "$@" >&2
  60. }
  61. route() {
  62. #
  63. # Call correct function based on $1
  64. #
  65. case $1 in
  66. build|build_manpages|clean|dist|rpmstuff|install|release_?|uninstall|vbump_?)
  67. $1
  68. ;;
  69. *)
  70. echo "usage: $(basename "$0") build|clean|dist|rpmstuff|install|uninstall" >&2
  71. esac
  72. }