Skip to content

Commit

Permalink
Move overrides inside _install_pre_reqs
Browse files Browse the repository at this point in the history
This code is only used here.

Also makes "ensure ..." message appear for non-apt OS
  • Loading branch information
abitrolly authored and mxcl committed Jan 14, 2025
1 parent d8f1f84 commit 0514229
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -45,10 +78,6 @@ _install_pre_reqs() {
fi
}

_is_ci() {
[ -n "$CI" ] && [ $CI != 0 ]
}

_install_pkgx() {
if _is_ci; then
progress="--no-progress-meter"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0514229

Please sign in to comment.