Skip to content

Commit 0514229

Browse files
abitrollymxcl
authored andcommitted
Move overrides inside _install_pre_reqs
This code is only used here. Also makes "ensure ..." message appear for non-apt OS
1 parent d8f1f84 commit 0514229

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

installer.sh

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,40 @@ elif test -d /usr -a ! -w /usr; then
1414
SUDO="sudo"
1515
fi
1616

17+
_is_ci() {
18+
[ -n "$CI" ] && [ $CI != 0 ]
19+
}
20+
1721
_install_pre_reqs() {
22+
if _is_ci; then
23+
apt() {
24+
# we should use apt-get not apt in CI
25+
# weird shit ref: https://askubuntu.com/a/668859
26+
export DEBIAN_FRONTEND=noninteractive
27+
cmd=$1
28+
shift
29+
$SUDO apt-get $cmd -qq -o=Dpkg::Use-Pty=0 $@
30+
}
31+
else
32+
echo "ensure you have the `pkgx` pre-requisites installed:" >&2
33+
apt() {
34+
case "$1" in
35+
update)
36+
echo >&2
37+
;;
38+
install)
39+
echo " apt-get" "$@" >&2
40+
;;
41+
esac
42+
}
43+
yum() {
44+
echo " yum" "$@" >&2
45+
}
46+
pacman() {
47+
echo " pacman" "$@" >&2
48+
}
49+
fi
50+
1851
if test -f /etc/debian_version; then
1952
apt update --yes
2053

@@ -45,10 +78,6 @@ _install_pre_reqs() {
4578
fi
4679
}
4780

48-
_is_ci() {
49-
[ -n "$CI" ] && [ $CI != 0 ]
50-
}
51-
5281
_install_pkgx() {
5382
if _is_ci; then
5483
progress="--no-progress-meter"
@@ -123,36 +152,6 @@ elif [ $# -eq 0 ]; then
123152
echo "$(pkgx --version) already installed" >&2
124153
fi
125154

126-
if _is_ci; then
127-
apt() {
128-
# we should use apt-get not apt in CI
129-
# weird shit ref: https://askubuntu.com/a/668859
130-
export DEBIAN_FRONTEND=noninteractive
131-
cmd=$1
132-
shift
133-
$SUDO apt-get $cmd -qq -o=Dpkg::Use-Pty=0 $@
134-
}
135-
else
136-
apt() {
137-
case "$1" in
138-
update)
139-
echo "ensure you have the `pkgx` pre-requisites installed:" >&2
140-
echo >&2
141-
;;
142-
install)
143-
echo " apt-get" "$@" >&2
144-
;;
145-
esac
146-
}
147-
yum() {
148-
echo " yum" "$@" >&2
149-
}
150-
pacman() {
151-
echo " pacman" "$@" >&2
152-
}
153-
unset SUDO
154-
fi
155-
156155
_install_pre_reqs
157156

158157
if [ $# -gt 0 ]; then

0 commit comments

Comments
 (0)