Skip 'sudo' in install.sh if you are already root user (#343)

This commit is contained in:
Mark Street 2021-07-27 12:17:51 +01:00 committed by GitHub
parent a1228bfad9
commit 2e66caf500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 32 deletions

View File

@ -6,7 +6,7 @@ COPY requirements.txt /
COPY requirements_extra.txt / COPY requirements_extra.txt /
COPY install.sh / COPY install.sh /
RUN apt-get update && apt-get install -y sudo && ./install.sh --extra RUN apt-get update && ./install.sh --extra
RUN mkdir /papermario RUN mkdir /papermario
WORKDIR /papermario WORKDIR /papermario

View File

@ -9,8 +9,7 @@ This repository supports:
If you encounter any issues setting up the repo, please feel free to [reach out to us on Discord](https://discord.gg/urUm3VG). If you encounter any issues setting up the repo, please feel free to [reach out to us on Discord](https://discord.gg/urUm3VG).
## Common
## Unix
Clone the repository: Clone the repository:
```sh ```sh
@ -18,6 +17,8 @@ git clone https://github.com/pmret/papermario
cd papermario cd papermario
``` ```
## Unix
Install build dependencies: Install build dependencies:
```sh ```sh
./install.sh ./install.sh
@ -64,4 +65,4 @@ docker build . -t pm
docker run --rm -ti -v $(pwd):/papermario pm docker run --rm -ti -v $(pwd):/papermario pm
``` ```
Then continue with [the instructions for Linux](#unix). Then continue with [the instructions for Linux](#unix), but you can skip the install.sh!

View File

@ -1,17 +1,23 @@
#!/bin/bash #!/bin/bash
if [[ "$UID" -eq "0" ]]; then
SUDO=""
else
SUDO=sudo
fi
# Debian and derivatives (apt) # Debian and derivatives (apt)
if cat /etc/os-release | grep -E 'ID=debian|ID_LIKE=debian' &> /dev/null; then if cat /etc/os-release | grep -E 'ID=debian|ID_LIKE=debian' &> /dev/null; then
echo "Installing packages for Debian or derivative (apt)" echo "Installing packages for Debian or derivative (apt)"
# Add i386 arch for wine32 # Add i386 arch for wine32
# sudo dpkg --add-architecture i386 # sudo dpkg --add-architecture i386
sudo apt install -y git python3 python3-pip python3-setuptools build-essential binutils-mips-linux-gnu zlib1g-dev libyaml-dev ninja-build || exit 1 ${SUDO} apt install -y git python3 python3-pip python3-setuptools build-essential binutils-mips-linux-gnu zlib1g-dev libyaml-dev ninja-build || exit 1
python3 -m pip install -U -r requirements.txt python3 -m pip install -U -r requirements.txt
if [[ $1 == "--extra" ]]; then if [[ $1 == "--extra" ]]; then
echo "Installing extra" echo "Installing extra"
sudo apt install -y clang-tidy astyle doxygen || exit 1 ${SUDO} apt install -y clang-tidy astyle doxygen || exit 1
python3 -m pip install -U -r requirements_extra.txt || exit 1 python3 -m pip install -U -r requirements_extra.txt || exit 1
fi fi
@ -24,21 +30,21 @@ if cat /etc/os-release | grep -E 'ID=arch|ID_LIKE=arch' &> /dev/null; then
echo "Installing packages for Arch Linux or derivative (pacman)" echo "Installing packages for Arch Linux or derivative (pacman)"
# Upgrade existing packages (note: no --noconfirm) # Upgrade existing packages (note: no --noconfirm)
sudo pacman -Syu || exit 1 ${SUDO} pacman -Syu || exit 1
# Install dependencies # Install dependencies
sudo pacman -S --noconfirm --needed git python python-pip python-setuptools base-devel zlib libyaml ninja || exit 1 ${SUDO} pacman -S --noconfirm --needed git python python-pip python-setuptools base-devel zlib libyaml ninja || exit 1
python3 -m pip install -U -r requirements.txt python3 -m pip install -U -r requirements.txt
# Install binutils if required # Install binutils if required
if ! command -v mips-linux-gnu-ar &> /dev/null; then if ! command -v mips-linux-gnu-ar &> /dev/null; then
PKG="mips-linux-gnu-binutils" PKG="mips-linux-gnu-binutils"
if command -v aura &> /dev/null; then if command -v aura &> /dev/null; then
sudo aura -A --noconfirm $PKG || exit 1 ${SUDO} aura -A --noconfirm $PKG || exit 1
elif command -v yay &> /dev/null; then elif command -v yay &> /dev/null; then
yay -S --noconfirm $PKG || exit 1 yay -S --noconfirm $PKG || exit 1
elif command -v yaourt &> /dev/null; then elif command -v yaourt &> /dev/null; then
sudo yaourt -S --noconfirm $PKG || exit 1 ${SUDO} yaourt -S --noconfirm $PKG || exit 1
else else
echo "AUR manager not found, installing $PKG without one" echo "AUR manager not found, installing $PKG without one"
@ -52,7 +58,7 @@ if cat /etc/os-release | grep -E 'ID=arch|ID_LIKE=arch' &> /dev/null; then
if [[ $1 == "--extra" ]]; then if [[ $1 == "--extra" ]]; then
echo "Installing extra" echo "Installing extra"
sudo pacman -S --noconfirm --needed clang astyle doxygen || exit 1 ${SUDO} pacman -S --noconfirm --needed clang astyle doxygen || exit 1
python3 -m pip install -U -r requirements_extra.txt || exit 1 python3 -m pip install -U -r requirements_extra.txt || exit 1
fi fi
@ -64,30 +70,30 @@ fi
if cat /etc/os-release | grep ID=opensuse &> /dev/null; then if cat /etc/os-release | grep ID=opensuse &> /dev/null; then
echo "Installing packages for openSUSE (zypper)" echo "Installing packages for openSUSE (zypper)"
sudo zypper -n install git python3 python3-devel python3-pip python3-setuptools gcc gcc-c++ glibc-devel make cross-mips-binutils zlib-devel libyaml-devel ninja ${SUDO} zypper -n install git python3 python3-devel python3-pip python3-setuptools gcc gcc-c++ glibc-devel make cross-mips-binutils zlib-devel libyaml-devel ninja
# Link the openSUSE locations for binutils tools to their usual GNU locations # Link the openSUSE locations for binutils tools to their usual GNU locations
sudo ln -s /usr/bin/mips-suse-linux-addr2line /usr/bin/mips-linux-gnu-addr2line ${SUDO} ln -s /usr/bin/mips-suse-linux-addr2line /usr/bin/mips-linux-gnu-addr2line
sudo ln -s /usr/bin/mips-suse-linux-ar /usr/bin/mips-linux-gnu-ar ${SUDO} ln -s /usr/bin/mips-suse-linux-ar /usr/bin/mips-linux-gnu-ar
sudo ln -s /usr/bin/mips-suse-linux-as /usr/bin/mips-linux-gnu-as ${SUDO} ln -s /usr/bin/mips-suse-linux-as /usr/bin/mips-linux-gnu-as
sudo ln -s /usr/bin/mips-suse-linux-elfedit /usr/bin/mips-linux-gnu-elfedit ${SUDO} ln -s /usr/bin/mips-suse-linux-elfedit /usr/bin/mips-linux-gnu-elfedit
sudo ln -s /usr/bin/mips-suse-linux-gprof /usr/bin/mips-linux-gnu-gprof ${SUDO} ln -s /usr/bin/mips-suse-linux-gprof /usr/bin/mips-linux-gnu-gprof
sudo ln -s /usr/bin/mips-suse-linux-ld /usr/bin/mips-linux-gnu-ld ${SUDO} ln -s /usr/bin/mips-suse-linux-ld /usr/bin/mips-linux-gnu-ld
sudo ln -s /usr/bin/mips-suse-linux-ld.bfd /usr/bin/mips-linux-gnu-ld.bfd ${SUDO} ln -s /usr/bin/mips-suse-linux-ld.bfd /usr/bin/mips-linux-gnu-ld.bfd
sudo ln -s /usr/bin/mips-suse-linux-nm /usr/bin/mips-linux-gnu-nm ${SUDO} ln -s /usr/bin/mips-suse-linux-nm /usr/bin/mips-linux-gnu-nm
sudo ln -s /usr/bin/mips-suse-linux-objcopy /usr/bin/mips-linux-gnu-objcopy ${SUDO} ln -s /usr/bin/mips-suse-linux-objcopy /usr/bin/mips-linux-gnu-objcopy
sudo ln -s /usr/bin/mips-suse-linux-objdump /usr/bin/mips-linux-gnu-objdump ${SUDO} ln -s /usr/bin/mips-suse-linux-objdump /usr/bin/mips-linux-gnu-objdump
sudo ln -s /usr/bin/mips-suse-linux-ranlib /usr/bin/mips-linux-gnu-ranlib ${SUDO} ln -s /usr/bin/mips-suse-linux-ranlib /usr/bin/mips-linux-gnu-ranlib
sudo ln -s /usr/bin/mips-suse-linux-readelf /usr/bin/mips-linux-gnu-readelf ${SUDO} ln -s /usr/bin/mips-suse-linux-readelf /usr/bin/mips-linux-gnu-readelf
sudo ln -s /usr/bin/mips-suse-linux-size /usr/bin/mips-linux-gnu-size ${SUDO} ln -s /usr/bin/mips-suse-linux-size /usr/bin/mips-linux-gnu-size
sudo ln -s /usr/bin/mips-suse-linux-strings /usr/bin/mips-linux-gnu-strings ${SUDO} ln -s /usr/bin/mips-suse-linux-strings /usr/bin/mips-linux-gnu-strings
sudo ln -s /usr/bin/mips-suse-linux-strip /usr/bin/mips-linux-gnu-strip ${SUDO} ln -s /usr/bin/mips-suse-linux-strip /usr/bin/mips-linux-gnu-strip
python3 -m pip install -U -r requirements.txt python3 -m pip install -U -r requirements.txt
if [[ $1 == "--extra" ]]; then if [[ $1 == "--extra" ]]; then
echo "Installing extra" echo "Installing extra"
sudo zypper -n install clang astyle doxygen || exit 1 ${SUDO} zypper -n install clang astyle doxygen || exit 1
python3 -m pip install -U -r requirements_extra.txt || exit 1 python3 -m pip install -U -r requirements_extra.txt || exit 1
fi fi
@ -105,7 +111,7 @@ if cat /etc/os-release | grep ID=alpine &> /dev/null; then
fi fi
# Install dependencies # Install dependencies
sudo apk add --no-cache bash wget git python3 python3-dev py3-pip build-base zlib-dev yaml-dev ninja ${SUDO} apk add --no-cache bash wget git python3 python3-dev py3-pip build-base zlib-dev yaml-dev ninja
python3 -m pip install -U -r requirements.txt python3 -m pip install -U -r requirements.txt
# Install binutils if required # Install binutils if required
@ -131,8 +137,8 @@ if cat /etc/os-release | grep ID=alpine &> /dev/null; then
--enable-plugins \ --enable-plugins \
--enable-deterministic-archives \ --enable-deterministic-archives \
--disable-werror --disable-werror
sudo make ${SUDO} make
sudo make install ${SUDO} make install
cd .. cd ..
# delete temp directory we made # delete temp directory we made
@ -143,7 +149,7 @@ if cat /etc/os-release | grep ID=alpine &> /dev/null; then
if [[ $1 == "--extra" ]]; then if [[ $1 == "--extra" ]]; then
echo "Installing extra" echo "Installing extra"
sudo apk add --no-cache clang-extra-tools astyle doxygen || exit 1 ${SUDO} apk add --no-cache clang-extra-tools astyle doxygen || exit 1
python3 -m pip install -U -r requirements_extra.txt || exit 1 python3 -m pip install -U -r requirements_extra.txt || exit 1
fi fi