release: Improve logging
This commit is contained in:
parent
379150b7ac
commit
136077842e
4 changed files with 68 additions and 42 deletions
|
|
@ -171,22 +171,25 @@ main() {
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
install_d2
|
install_d2
|
||||||
if [ "${TALA-}" ]; then
|
if [ -n "${TALA-}" ]; then
|
||||||
# Run in subshell to avoid overwriting VERSION.
|
# Run in subshell to avoid overwriting VERSION.
|
||||||
( install_tala )
|
TALA_VERSION="$( install_tala && echo "$VERSION" )"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COLOR=2 header success
|
COLOR=2 header success
|
||||||
log "d2-$VERSION-$OS-$ARCH has been successfully installed into $PREFIX"
|
log "d2-$VERSION-$OS-$ARCH has been successfully installed into $PREFIX"
|
||||||
|
if [ -n "${TALA-}" ]; then
|
||||||
|
log "tala-$TALA_VERSION-$OS-$ARCH has been successfully installed into $PREFIX"
|
||||||
|
fi
|
||||||
if ! echo "$PATH" | grep -qF "$PREFIX/bin"; then
|
if ! echo "$PATH" | grep -qF "$PREFIX/bin"; then
|
||||||
logcat >&2 <<EOF
|
logcat >&2 <<EOF
|
||||||
Extend your path to use d2:
|
Extend your \$PATH to use d2:
|
||||||
export PATH=$PREFIX/bin:\$PATH
|
export PATH=$PREFIX/bin:\$PATH
|
||||||
Then run:
|
Then run:
|
||||||
d2 --help
|
${TALA+D2_LAYOUT=tala }d2 --help
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
log "Run d2 --help for usage."
|
log " Run ${TALA+D2_LAYOUT=tala }d2 --help for usage."
|
||||||
fi
|
fi
|
||||||
if ! manpath | grep -qF "$PREFIX/share/man"; then
|
if ! manpath | grep -qF "$PREFIX/share/man"; then
|
||||||
logcat >&2 <<EOF
|
logcat >&2 <<EOF
|
||||||
|
|
@ -195,9 +198,16 @@ Extend your \$MANPATH to view d2's manpages:
|
||||||
Then run:
|
Then run:
|
||||||
man d2
|
man d2
|
||||||
EOF
|
EOF
|
||||||
else
|
if [ -n "${TALA-}" ]; then
|
||||||
log "Run man d2 for the manpage."
|
log " man d2plugin-tala"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
log " Run man d2 for detailed docs."
|
||||||
|
if [ -n "${TALA-}" ]; then
|
||||||
|
log " Run man d2plugin-tala for detailed docs."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log "Rerun the install script with --uninstall to uninstall"
|
log "Rerun the install script with --uninstall to uninstall"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,15 +247,15 @@ install_standalone_d2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
install_tala() {
|
install_tala() {
|
||||||
install_standalone_tala
|
|
||||||
}
|
|
||||||
|
|
||||||
install_standalone_tala() {
|
|
||||||
REPO="${REPO_TALA:-terrastruct/TALA}"
|
REPO="${REPO_TALA:-terrastruct/TALA}"
|
||||||
VERSION=$TALA
|
VERSION=$TALA
|
||||||
RELEASE_INFO=
|
RELEASE_INFO=
|
||||||
fetch_release_info
|
fetch_release_info
|
||||||
|
header "installing tala-$VERSION"
|
||||||
|
install_standalone_tala
|
||||||
|
}
|
||||||
|
|
||||||
|
install_standalone_tala() {
|
||||||
ARCHIVE="tala-$VERSION-$OS-$ARCH.tar.gz"
|
ARCHIVE="tala-$VERSION-$OS-$ARCH.tar.gz"
|
||||||
log "installing standalone release $ARCHIVE from github"
|
log "installing standalone release $ARCHIVE from github"
|
||||||
|
|
||||||
|
|
@ -265,8 +275,8 @@ install_standalone_tala() {
|
||||||
|
|
||||||
uninstall() {
|
uninstall() {
|
||||||
if ! command -v d2 >/dev/null; then
|
if ! command -v d2 >/dev/null; then
|
||||||
echoerr "no version of d2 installed"
|
warn "no version of d2 installed"
|
||||||
return 1
|
return 0
|
||||||
fi
|
fi
|
||||||
INSTALLED_VERSION="$(d2 --version)"
|
INSTALLED_VERSION="$(d2 --version)"
|
||||||
if ! uninstall_d2; then
|
if ! uninstall_d2; then
|
||||||
|
|
@ -275,8 +285,8 @@ uninstall() {
|
||||||
fi
|
fi
|
||||||
if [ "${TALA-}" ]; then
|
if [ "${TALA-}" ]; then
|
||||||
if ! command -v d2plugin-tala >/dev/null; then
|
if ! command -v d2plugin-tala >/dev/null; then
|
||||||
echoerr "no version of tala installed"
|
warn "no version of tala installed"
|
||||||
return 1
|
return 0
|
||||||
fi
|
fi
|
||||||
INSTALLED_VERSION="$(d2plugin-tala --version)"
|
INSTALLED_VERSION="$(d2plugin-tala --version)"
|
||||||
if ! uninstall_tala; then
|
if ! uninstall_tala; then
|
||||||
|
|
@ -296,7 +306,8 @@ uninstall_standalone_d2() {
|
||||||
log "uninstalling standalone release of d2-$INSTALLED_VERSION"
|
log "uninstalling standalone release of d2-$INSTALLED_VERSION"
|
||||||
|
|
||||||
if [ ! -e "$INSTALL_DIR/d2-$INSTALLED_VERSION" ]; then
|
if [ ! -e "$INSTALL_DIR/d2-$INSTALLED_VERSION" ]; then
|
||||||
echoerr "missing standalone install release directory $INSTALL_DIR/d2-$INSTALLED_VERSION"
|
warn "missing standalone install release directory $INSTALL_DIR/d2-$INSTALLED_VERSION"
|
||||||
|
warn "d2 have been installed via some other installation method."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -310,14 +321,16 @@ uninstall_standalone_d2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall_tala() {
|
uninstall_tala() {
|
||||||
uninstall_standalone_tala
|
header "uninstalling tala-$INSTALLED_VERSION"
|
||||||
|
uninstall_standalone_tala
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall_standalone_tala() {
|
uninstall_standalone_tala() {
|
||||||
log "uninstalling standalone release tala-$INSTALLED_VERSION"
|
log "uninstalling standalone release tala-$INSTALLED_VERSION"
|
||||||
|
|
||||||
if [ ! -e "$INSTALL_DIR/tala-$INSTALLED_VERSION" ]; then
|
if [ ! -e "$INSTALL_DIR/tala-$INSTALLED_VERSION" ]; then
|
||||||
echoerr "missing standalone install release directory $INSTALL_DIR/tala-$INSTALLED_VERSION"
|
warn "missing standalone install release directory $INSTALL_DIR/tala-$INSTALLED_VERSION"
|
||||||
|
warn "tala have been installed via some other installation method."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -332,10 +345,10 @@ uninstall_standalone_tala() {
|
||||||
|
|
||||||
is_prefix_writable() {
|
is_prefix_writable() {
|
||||||
sh_c "mkdir -p '$INSTALL_DIR' 2>/dev/null" || true
|
sh_c "mkdir -p '$INSTALL_DIR' 2>/dev/null" || true
|
||||||
# The reason for checking whether bin is writable specifically is that on macOS you have
|
# The reason for checking whether $INSTALL_DIR is writable is that on macOS you have
|
||||||
# /usr/local owned by root but you don't need root to write to its subdirectories which
|
# /usr/local owned by root but you don't need root to write to its subdirectories which
|
||||||
# is all we want to do.
|
# is all we want to do.
|
||||||
if [ ! -w "$PREFIX/bin" ]; then
|
if [ ! -w "$INSTALL_DIR" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sh_c rm -f "$PREFIX/bin/d2"
|
sh_c rm -f "$PREFIX/bin/d2"
|
||||||
sh_c rm -f "$PREFIX/share/man/man1"
|
sh_c rm -f "$PREFIX/share/man/man1/d2.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
|
||||||
2
ci/sub
2
ci/sub
|
|
@ -1 +1 @@
|
||||||
Subproject commit a2da81bcbc12c9ce4f53d8e74385d0d93184484d
|
Subproject commit 9271a707dc1d1fdca60599269c81e1ecdd6623e7
|
||||||
53
install.sh
53
install.sh
|
|
@ -605,22 +605,25 @@ main() {
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
install_d2
|
install_d2
|
||||||
if [ "${TALA-}" ]; then
|
if [ -n "${TALA-}" ]; then
|
||||||
# Run in subshell to avoid overwriting VERSION.
|
# Run in subshell to avoid overwriting VERSION.
|
||||||
( install_tala )
|
TALA_VERSION="$( install_tala && echo "$VERSION" )"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COLOR=2 header success
|
COLOR=2 header success
|
||||||
log "d2-$VERSION-$OS-$ARCH has been successfully installed into $PREFIX"
|
log "d2-$VERSION-$OS-$ARCH has been successfully installed into $PREFIX"
|
||||||
|
if [ -n "${TALA-}" ]; then
|
||||||
|
log "tala-$TALA_VERSION-$OS-$ARCH has been successfully installed into $PREFIX"
|
||||||
|
fi
|
||||||
if ! echo "$PATH" | grep -qF "$PREFIX/bin"; then
|
if ! echo "$PATH" | grep -qF "$PREFIX/bin"; then
|
||||||
logcat >&2 <<EOF
|
logcat >&2 <<EOF
|
||||||
Extend your path to use d2:
|
Extend your \$PATH to use d2:
|
||||||
export PATH=$PREFIX/bin:\$PATH
|
export PATH=$PREFIX/bin:\$PATH
|
||||||
Then run:
|
Then run:
|
||||||
d2 --help
|
${TALA+D2_LAYOUT=tala }d2 --help
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
log "Run d2 --help for usage."
|
log " Run ${TALA+D2_LAYOUT=tala }d2 --help for usage."
|
||||||
fi
|
fi
|
||||||
if ! manpath | grep -qF "$PREFIX/share/man"; then
|
if ! manpath | grep -qF "$PREFIX/share/man"; then
|
||||||
logcat >&2 <<EOF
|
logcat >&2 <<EOF
|
||||||
|
|
@ -629,9 +632,16 @@ Extend your \$MANPATH to view d2's manpages:
|
||||||
Then run:
|
Then run:
|
||||||
man d2
|
man d2
|
||||||
EOF
|
EOF
|
||||||
else
|
if [ -n "${TALA-}" ]; then
|
||||||
log "Run man d2 for the manpage."
|
log " man d2plugin-tala"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
log " Run man d2 for detailed docs."
|
||||||
|
if [ -n "${TALA-}" ]; then
|
||||||
|
log " Run man d2plugin-tala for detailed docs."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log "Rerun the install script with --uninstall to uninstall"
|
log "Rerun the install script with --uninstall to uninstall"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -671,15 +681,15 @@ install_standalone_d2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
install_tala() {
|
install_tala() {
|
||||||
install_standalone_tala
|
|
||||||
}
|
|
||||||
|
|
||||||
install_standalone_tala() {
|
|
||||||
REPO="${REPO_TALA:-terrastruct/TALA}"
|
REPO="${REPO_TALA:-terrastruct/TALA}"
|
||||||
VERSION=$TALA
|
VERSION=$TALA
|
||||||
RELEASE_INFO=
|
RELEASE_INFO=
|
||||||
fetch_release_info
|
fetch_release_info
|
||||||
|
header "installing tala-$VERSION"
|
||||||
|
install_standalone_tala
|
||||||
|
}
|
||||||
|
|
||||||
|
install_standalone_tala() {
|
||||||
ARCHIVE="tala-$VERSION-$OS-$ARCH.tar.gz"
|
ARCHIVE="tala-$VERSION-$OS-$ARCH.tar.gz"
|
||||||
log "installing standalone release $ARCHIVE from github"
|
log "installing standalone release $ARCHIVE from github"
|
||||||
|
|
||||||
|
|
@ -699,8 +709,8 @@ install_standalone_tala() {
|
||||||
|
|
||||||
uninstall() {
|
uninstall() {
|
||||||
if ! command -v d2 >/dev/null; then
|
if ! command -v d2 >/dev/null; then
|
||||||
echoerr "no version of d2 installed"
|
warn "no version of d2 installed"
|
||||||
return 1
|
return 0
|
||||||
fi
|
fi
|
||||||
INSTALLED_VERSION="$(d2 --version)"
|
INSTALLED_VERSION="$(d2 --version)"
|
||||||
if ! uninstall_d2; then
|
if ! uninstall_d2; then
|
||||||
|
|
@ -709,8 +719,8 @@ uninstall() {
|
||||||
fi
|
fi
|
||||||
if [ "${TALA-}" ]; then
|
if [ "${TALA-}" ]; then
|
||||||
if ! command -v d2plugin-tala >/dev/null; then
|
if ! command -v d2plugin-tala >/dev/null; then
|
||||||
echoerr "no version of tala installed"
|
warn "no version of tala installed"
|
||||||
return 1
|
return 0
|
||||||
fi
|
fi
|
||||||
INSTALLED_VERSION="$(d2plugin-tala --version)"
|
INSTALLED_VERSION="$(d2plugin-tala --version)"
|
||||||
if ! uninstall_tala; then
|
if ! uninstall_tala; then
|
||||||
|
|
@ -730,7 +740,8 @@ uninstall_standalone_d2() {
|
||||||
log "uninstalling standalone release of d2-$INSTALLED_VERSION"
|
log "uninstalling standalone release of d2-$INSTALLED_VERSION"
|
||||||
|
|
||||||
if [ ! -e "$INSTALL_DIR/d2-$INSTALLED_VERSION" ]; then
|
if [ ! -e "$INSTALL_DIR/d2-$INSTALLED_VERSION" ]; then
|
||||||
echoerr "missing standalone install release directory $INSTALL_DIR/d2-$INSTALLED_VERSION"
|
warn "missing standalone install release directory $INSTALL_DIR/d2-$INSTALLED_VERSION"
|
||||||
|
warn "d2 have been installed via some other installation method."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -744,14 +755,16 @@ uninstall_standalone_d2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall_tala() {
|
uninstall_tala() {
|
||||||
uninstall_standalone_tala
|
header "uninstalling tala-$INSTALLED_VERSION"
|
||||||
|
uninstall_standalone_tala
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall_standalone_tala() {
|
uninstall_standalone_tala() {
|
||||||
log "uninstalling standalone release tala-$INSTALLED_VERSION"
|
log "uninstalling standalone release tala-$INSTALLED_VERSION"
|
||||||
|
|
||||||
if [ ! -e "$INSTALL_DIR/tala-$INSTALLED_VERSION" ]; then
|
if [ ! -e "$INSTALL_DIR/tala-$INSTALLED_VERSION" ]; then
|
||||||
echoerr "missing standalone install release directory $INSTALL_DIR/tala-$INSTALLED_VERSION"
|
warn "missing standalone install release directory $INSTALL_DIR/tala-$INSTALLED_VERSION"
|
||||||
|
warn "tala have been installed via some other installation method."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -766,10 +779,10 @@ uninstall_standalone_tala() {
|
||||||
|
|
||||||
is_prefix_writable() {
|
is_prefix_writable() {
|
||||||
sh_c "mkdir -p '$INSTALL_DIR' 2>/dev/null" || true
|
sh_c "mkdir -p '$INSTALL_DIR' 2>/dev/null" || true
|
||||||
# The reason for checking whether bin is writable specifically is that on macOS you have
|
# The reason for checking whether $INSTALL_DIR is writable is that on macOS you have
|
||||||
# /usr/local owned by root but you don't need root to write to its subdirectories which
|
# /usr/local owned by root but you don't need root to write to its subdirectories which
|
||||||
# is all we want to do.
|
# is all we want to do.
|
||||||
if [ ! -w "$PREFIX/bin" ]; then
|
if [ ! -w "$INSTALL_DIR" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue