Debian 10 fixes (#51)

* Fix missing curl/wget not being detected

If `which curl` failed, a function `curl` would always be created, whether or not `wget` is present.
So `req curl || req wget` (or even `req curl`) would never trigger `ERROR: Missing both curl and wget`.

* Install curl on Debian

In newer versions of Debian, wget is not installed by default and neither is curl.
So install curl if wget is missing and apt-get is present.
Behavior on other platforms should stay the same with this change.
This commit is contained in:
jleeuwes 2020-04-05 22:31:17 +02:00 committed by GitHub
parent 565204bc21
commit f5da2577dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -163,8 +163,15 @@ prepareEnv() {
export USER="root" export USER="root"
export HOME="/root" export HOME="/root"
# Nix installer tries to use sudo regardless of whether we're already uid 0
#which sudo || { sudo() { eval "$@"; }; export -f sudo; }
# shellcheck disable=SC2174
mkdir -p -m 0755 /nix
}
fakeCurlUsingWget() {
# Use adapted wget if curl is missing # Use adapted wget if curl is missing
which curl || { \ which wget && { \
curl() { curl() {
eval "wget $( eval "wget $(
(local isStdout=1 (local isStdout=1
@ -188,11 +195,6 @@ prepareEnv() {
)| tr '\n' ' ' )| tr '\n' ' '
)" )"
}; export -f curl; } }; export -f curl; }
# Nix installer tries to use sudo regardless of whether we're already uid 0
#which sudo || { sudo() { eval "$@"; }; export -f sudo; }
# shellcheck disable=SC2174
mkdir -p -m 0755 /nix
} }
req() { req() {
@ -201,10 +203,14 @@ req() {
checkEnv() { checkEnv() {
# Perform some easy fixups before checking # Perform some easy fixups before checking
# TODO prevent multiple calls to apt-get update
which dnf && dnf install -y perl-Digest-SHA # Fedora 24 which dnf && dnf install -y perl-Digest-SHA # Fedora 24
which bzcat || (which yum && yum install -y bzip2) \ which bzcat || (which yum && yum install -y bzip2) \
|| (which apt-get && apt-get update && apt-get install -y bzip2) \ || (which apt-get && apt-get update && apt-get install -y bzip2) \
|| true || true
which curl || fakeCurlUsingWget \
|| (which apt-get && apt-get update && apt-get install -y curl) \
|| true
[[ "$(whoami)" == "root" ]] || { echo "ERROR: Must run as root"; return 1; } [[ "$(whoami)" == "root" ]] || { echo "ERROR: Must run as root"; return 1; }