diff --git a/installer.sh b/installer.sh index ec2a51a6..2b2d5306 100755 --- a/installer.sh +++ b/installer.sh @@ -14,7 +14,40 @@ elif test -d /usr -a ! -w /usr; then SUDO="sudo" fi +_is_ci() { + [ -n "$CI" ] && [ $CI != 0 ] +} + _install_pre_reqs() { + if _is_ci; then + apt() { + # we should use apt-get not apt in CI + # weird shit ref: https://askubuntu.com/a/668859 + export DEBIAN_FRONTEND=noninteractive + cmd=$1 + shift + $SUDO apt-get $cmd -qq -o=Dpkg::Use-Pty=0 $@ + } + else + echo "ensure you have the `pkgx` pre-requisites installed:" >&2 + apt() { + case "$1" in + update) + echo >&2 + ;; + install) + echo " apt-get" "$@" >&2 + ;; + esac + } + yum() { + echo " yum" "$@" >&2 + } + pacman() { + echo " pacman" "$@" >&2 + } + fi + if test -f /etc/debian_version; then apt update --yes @@ -45,10 +78,6 @@ _install_pre_reqs() { fi } -_is_ci() { - [ -n "$CI" ] && [ $CI != 0 ] -} - _install_pkgx() { if _is_ci; then progress="--no-progress-meter" @@ -123,36 +152,6 @@ elif [ $# -eq 0 ]; then echo "$(pkgx --version) already installed" >&2 fi -if _is_ci; then - apt() { - # we should use apt-get not apt in CI - # weird shit ref: https://askubuntu.com/a/668859 - export DEBIAN_FRONTEND=noninteractive - cmd=$1 - shift - $SUDO apt-get $cmd -qq -o=Dpkg::Use-Pty=0 $@ - } -else - apt() { - case "$1" in - update) - echo "ensure you have the `pkgx` pre-requisites installed:" >&2 - echo >&2 - ;; - install) - echo " apt-get" "$@" >&2 - ;; - esac - } - yum() { - echo " yum" "$@" >&2 - } - pacman() { - echo " pacman" "$@" >&2 - } - unset SUDO -fi - _install_pre_reqs if [ $# -gt 0 ]; then