mirror of
https://github.com/elitak/nixos-infect.git
synced 2024-12-22 08:08:29 +03:00
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:
parent
565204bc21
commit
f5da2577dd
1 changed files with 12 additions and 6 deletions
18
nixos-infect
18
nixos-infect
|
@ -163,8 +163,15 @@ prepareEnv() {
|
|||
export USER="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
|
||||
which curl || { \
|
||||
which wget && { \
|
||||
curl() {
|
||||
eval "wget $(
|
||||
(local isStdout=1
|
||||
|
@ -188,11 +195,6 @@ prepareEnv() {
|
|||
)| tr '\n' ' '
|
||||
)"
|
||||
}; 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() {
|
||||
|
@ -201,10 +203,14 @@ req() {
|
|||
|
||||
checkEnv() {
|
||||
# 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 bzcat || (which yum && yum install -y bzip2) \
|
||||
|| (which apt-get && apt-get update && apt-get install -y bzip2) \
|
||||
|| 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; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue