12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #!/bin/bash
-
- . "$MKIT_DIR/include/build.sh" || die "cannot import build.sh"
- . "$MKIT_DIR/include/deploy.sh" || die "cannot import deploy.sh"
- . "$MKIT_DIR/include/release.sh" || die "cannot import release.sh"
- . "$MKIT_DIR/include/ini.sh" || die "cannot import ini.sh"
-
- debug() {
- #
- # Print debug message
- #
- $MKIT_DEBUG || return 0
- echo "MKIT_DEBUG: ${FUNCNAME[1]}()" "$@" >&2
- }
-
- debug_var() {
- #
- # Print debug message
- #
- $MKIT_DEBUG || return 0
- local __mkit_debug_var_name__
- for __mkit_debug_var_name__ in "$@";
- do
- {
- echo -n "MKIT_DEBUG: ${FUNCNAME[1]}():"
- echo -n " $__mkit_debug_var_name__"
- echo -n "='${!__mkit_debug_var_name__}'"
- echo
- } >&2
- done
- }
-
- MKIT_INI=${MKIT_INI:-mkit.ini}
- MKIT_INI_EXPAND=2
- MKIT_PROJ_NAME=$(ini 1value "project:name")
- MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
- MKIT_DEFAULT_MODE="644"
-
- mkit_init() {
- #
- # Do basic initialization
- #
- # Check for ini file and some variables
- #
- test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
- test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
- || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
- }
-
- die() {
- #
- # Exit with message and non-zero exit status
- #
- echo "fatal: $*" >&2
- exit 4
- }
-
- warn() {
- #
- # Print warning message
- #
- echo "$@" >&2
- }
-
- update_version() {
- #
- # Change project.version in mkit.ini at path $2 to version $1
- #
- local version="$1"
- local inifile="$2"
- local tmp=$(mktemp -t mkit.update_version.XXXXXXXX)
- <"$inifile" perl -e '
- my $hit = 0;
- my $done = 0;
- foreach (<STDIN>) {
- if ($done) { print; next; }
- elsif (m/\[project\]/) { $hit++; print; next; }
- elsif (m/\[/) { $hit = 0; print; next; }
- elsif ($hit) { s/\bversion\b *=.*/version = $ARGV[0]/ and $done++; print; }
- else { print; next; }
- }
- ' "$version" >"$tmp" || die "failed to update version in mkit.ini"
- mv "$tmp" "$inifile"
- }
-
- route() {
- #
- # Call correct function based on $1
- #
- case $1 in
- build|build_manpages|clean|dist|rpmstuff|install|release_?|uninstall|vbump_?)
- $1
- ;;
- *)
- echo "usage: $(basename "$0") build|clean|dist|rpmstuff|install|uninstall" >&2
- esac
- }
|