123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. MKIT_INI=${MKIT_INI:-mkit.ini}
  7. MKIT_INI_EXPAND=2
  8. MKIT_PROJ_PKGNAME=""
  9. MKIT_DEFAULT_MODE="644"
  10. _valid_targets() {
  11. #
  12. # List valid routes
  13. #
  14. echo build
  15. echo build_manpages
  16. echo clean
  17. echo debstuff
  18. echo dist
  19. echo install
  20. echo release_x
  21. echo release_y
  22. echo release_z
  23. echo rpmstuff
  24. echo uninstall
  25. echo vbump_x
  26. echo vbump_y
  27. echo vbump_z
  28. }
  29. debug() {
  30. #
  31. # Print debug message
  32. #
  33. $MKIT_DEBUG || return 0
  34. echo "MKIT_DEBUG: ${FUNCNAME[1]}()" "$@" >&2
  35. }
  36. debug_var() {
  37. #
  38. # Print debug message
  39. #
  40. $MKIT_DEBUG || return 0
  41. local __mkit_debug_var_name__
  42. for __mkit_debug_var_name__ in "$@";
  43. do
  44. {
  45. echo -n "MKIT_DEBUG: ${FUNCNAME[1]}():"
  46. echo -n " $__mkit_debug_var_name__"
  47. echo -n "='${!__mkit_debug_var_name__}'"
  48. echo
  49. } >&2
  50. done
  51. }
  52. die() {
  53. #
  54. # Exit with message and non-zero exit status
  55. #
  56. echo "fatal: $*" >&2
  57. exit 4
  58. }
  59. mkit_init() {
  60. #
  61. # Do basic initialization
  62. #
  63. # Check for ini file and some variables
  64. #
  65. MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
  66. test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
  67. test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
  68. || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
  69. }
  70. route() {
  71. #
  72. # Call correct function based on $1
  73. #
  74. if _valid_targets | grep -qwx "^$1";
  75. then
  76. "$1"
  77. else
  78. {
  79. echo "usage: $(basename "$0") TARGET"
  80. echo
  81. echo "valid targets:"
  82. _valid_targets | sed 's/^/ /'
  83. } >&2
  84. fi
  85. }
  86. warn() {
  87. #
  88. # Print warning message
  89. #
  90. echo "$@" >&2
  91. }