diff --git a/Cataclysm-Ubuntu-Compiler.sh b/Cataclysm-Ubuntu-Compiler.sh index 05e69a8..8372d4a 100644 --- a/Cataclysm-Ubuntu-Compiler.sh +++ b/Cataclysm-Ubuntu-Compiler.sh @@ -1,5 +1,24 @@ #!/bin/bash +if type apt-get >/dev/null 2>&1 +then + OS=Debian +elif type pacman >/dev/null 2>&1 +then + OS=Arch +elif type dnf >/dev/null 2>&1 +then + OS=RPM-DNF + #elif type zypper >/dev/null 2>&1 + #then + # OS=RPM-ZYPPER +elif type yum >/dev/null 2>&1 +then + OS=RPM-YUM +fi + +ARCH=$(arch) + read -n 1 -p "Would you like to install Cataclysm: Dark Days Ahead? You can choose to install the updater script either way. (Please enter Y or N): " INSTALL echo "" if [[ ( "$INSTALL" = 'Y' ) || ( "$INSTALL" = 'y' ) ]] @@ -9,7 +28,33 @@ then if [[ ( "$VERSION" = 'N' ) || ( "$VERSION" = 'n' ) ]] then echo "Installing needed dependencies." - sudo apt-get update && sudo apt-get install astyle build-essential ccache clang git libglib2.0-dev liblua5.2-0 liblua5.2-dev libncurses5-dev libncursesw5-dev lua5.2 tmux -y + if [ "$OS" = "Debian" ] + then + sudo apt-get update && sudo apt-get install astyle build-essential ccache clang git libglib2.0-dev liblua5.2-devel liblua5.3-dev libncurses5-dev libncursesw5-dev lua5.2 lua5.3 zip -y + elif [ "$OS" = "Arch" ] + then + sudo pacman -Syy && sudo pacman -S astyle ccache clang git glib2 lua ncurses zip + elif [ "$OS" = "RPM-DNF" ] + then + if [ "$ARCH" = 'x86_64' ] + then + sudo dnf install astyle.$ARCH ccache.$ARCH clang.$ARCH git.$ARCH glib2.$ARCH lua.$ARCH lua-devel.$ARCH ncurses-devel.$ARCH zip.$ARCH + elif [ "$ARCH" = 'i686' ] + then + sudo dnf install astyle.$ARCH clang.$ARCH git.$ARCH glib2.$ARCH lua.$ARCH lua-devel.$ARCH ncurses-devel.$ARCH zip.$ARCH + fi + #elif [ "$OS" = "RPM-ZYPPER" ] + #then + elif [ "$OS" = "RPM-YUM" ] + then + if [ "$ARCH" = 'x86_64' ] + then + sudo yum install astyle.$ARCH ccache.$ARCH clang.$ARCH git.$ARCH glib2.$ARCH lua.$ARCH lua-devel.$ARCH make.$ARCH ncurses-devel.$ARCH zip.$ARCH + elif [ "$ARCH" = 'i686' ] + then + sudo yum install astyle.$ARCH clang.$ARCH git.$ARCH glib2.$ARCH lua.$ARCH lua-devel.$ARCH make.$ARCH ncurses-devel.$ARCH zip.$ARCH + fi + fi read -n 1 -p "Would you like to choose a different font to use for the game? Doing so will create a launcher for you (Please enter Y or N): " FONT echo "" if [[ ( "$FONT" = 'Y' ) || ( "$FONT" = 'y' ) ]] @@ -21,12 +66,31 @@ then LAUNCHER=$(pwd) fi mkdir $LAUNCHER/backups - sudo echo -e 'ACTIVE_CONSOLES="/dev/tty[1-6]"\n' | sudo tee $LAUNCHER/backups/game-font 1> /dev/null - sudo echo -e 'CHARMAP="UTF-8"\n' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null - sudo echo 'CODESET="guess"' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null - sudo echo 'FONTFACE="Terminus"' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null - sudo echo -e 'FONTSIZE="14x28"\n' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null - sudo echo 'VIDEOMODE=' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null + if [ -f /etc/default/console-setup ] + then + sudo echo -e 'ACTIVE_CONSOLES="/dev/tty[1-6]"\n' | sudo tee $LAUNCHER/backups/game-font 1> /dev/null + sudo echo -e 'CHARMAP="UTF-8"\n' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null + sudo echo 'CODESET="guess"' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null + sudo echo 'FONTFACE="Terminus"' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null + sudo echo -e 'FONTSIZE="14x28"\n' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null + sudo echo 'VIDEOMODE=' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null + elif [ -f /etc/vconsole.conf ] + then + if [ "$OS" = 'RPM-DNF' ] + then + sudo dnf install terminus-fonts-console + #elif [ "$OS" = 'RPM-ZYPPER' ] + #then + elif [ "$OS" = 'RPM-YUM' ] + then + sudo yum install terminus-fonts-console + elif [ "$OS" = 'Arch' ] + then + sudo pacman -S terminus-font + fi + sudo echo 'KEYMAP="us"' | sudo tee $LAUNCHER/backups/game-font 1> /dev/null + sudo echo 'FONT="ter-v32n"' | sudo tee -a $LAUNCHER/backups/game-font 1> /dev/null + fi sudo chown root:root $LAUNCHER/backups/game-font sudo chmod 644 $LAUNCHER/backups/game-font @@ -34,28 +98,110 @@ then echo "LAUNCHDIRECTORY=$LAUNCHER" >> $LAUNCHER/cataclysm-launcher.sh echo "GAMEDIRECTORY=$(pwd)/Cataclysm-DDA" >> $LAUNCHER/cataclysm-launcher.sh echo "echo 'Backing up current font.'" >> $LAUNCHER/cataclysm-launcher.sh - echo "sudo cp /etc/default/console-setup \$LAUNCHDIRECTORY/backups/regular-font" >> $LAUNCHER/cataclysm-launcher.sh - echo "sudo cp \$LAUNCHDIRECTORY/backups/game-font /etc/default/console-setup" >> $LAUNCHER/cataclysm-launcher.sh + if [ -f /etc/default/console-setup ] + then + echo "sudo cp /etc/default/console-setup \$LAUNCHDIRECTORY/backups/regular-font" >> $LAUNCHER/cataclysm-launcher.sh + echo "sudo cp \$LAUNCHDIRECTORY/backups/game-font /etc/default/console-setup" >> $LAUNCHER/cataclysm-launcher.sh + elif [ -f /etc/vconsole.conf ] + then + echo "sudo cp /etc/vconsole.conf \$LAUNCHDIRECTORY/backups/regular-font">> $LAUNCHER/cataclysm-launcher.sh + echo "sudo cp \$LAUNCHDIRECTORY/backups/game-font /etc/vconsole.conf" >> $LAUNCHER/cataclysm-launcher.sh + echo "sudo systemctl restart systemd-vconsole-setup.service" >> $LAUNCHER/cataclysm-launcher.sh + fi echo "cd \$GAMEDIRECTORY; ./cataclysm" >> $LAUNCHER/cataclysm-launcher.sh - echo "sudo cp \$LAUNCHDIRECTORY/backups/regular-font /etc/default/console-setup" >> $LAUNCHER/cataclysm-launcher.sh + if [ -f /etc/default/console-setup ] + then + echo "sudo cp \$LAUNCHDIRECTORY/backups/regular-font /etc/default/console-setup" >> $LAUNCHER/cataclysm-launcher.sh + elif [ -f /etc/vconsole.conf ] + then + echo "sudo cp \$LAUNCHDIRECTORY/backups/regular-font /etc/vconsole.conf" >> $LAUNCHER/cataclysm-launcher.sh + echo "sudo systemctl restart systemd-vconsole-setup.service" >> $LAUNCHER/cataclysm-launcher.sh + fi echo "unset LAUNCHDIRECTORY" >> $LAUNCHER/cataclysm-launcher.sh echo "unset GAMEDIRECTORY" >> $LAUNCHER/cataclysm-launcher.sh chmod +x $LAUNCHER/cataclysm-launcher.sh fi - elif [[ ( "$VERSION" = 'T' ) || ( "$VERSION" = 't' ) ]] +elif [[ ( "$VERSION" = 'T' ) || ( "$VERSION" = 't' ) ]] then echo "Installing needed dependencies." - sudo apt-get update && sudo apt-get install astyle build-essential ccache clang git libfreetype6-dev libglib2.0-dev liblua5.2-0 liblua5.2-dev libncurses5-dev libncursesw5-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev lua5.2 -y - GRAPHICS=$(dpkg -l 2>/dev/null | grep "xserver-xorg" | tail -n 1 | awk '{print $1}') - if [ "$GRAPHICS" != "ii" ] + if [ "$OS" = 'Debian' ] + then + sudo apt-get update && sudo apt-get install build-essential ccache clang git libfreetype6-dev liblua5.2-dev liblua5.3-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev lua5.2 lua5.3 zip -y + elif [ "$OS" = 'Arch' ] + then + sudo pacman -Syy && sudo pacman -S base-devel bzip2 ccache clang freetype2 gcc-libs git glibc lua sdl2 sdl2_image sdl2_mixer sdl2_ttf zip zlib + elif [ "$OS" = 'RPM-DNF' ] + then + if [ "$ARCH" = 'x86_64' ] + then + sudo dnf install bzip2.$ARCH ccache.$ARCH clang.$ARCH freetype.$ARCH git.$ARCH glibc.$ARCH lua.$ARCH make.$ARCH SDL2-devel.$ARCH SDL2_image-devel.$ARCH SDL2_mixer-devel.$ARCH SDL2_ttf-devel.$ARCH zip.$ARCH + elif [ "$ARCH" = 'i686' ] + then + sudo dnf install clang.$ARCH freetype.$ARCH git.$ARCH glibc.$ARCH lua.$ARCH make.$ARCH SDL2-devel.$ARCH SDL2_image-devel.$ARCH SDL2_mixer-devel.$ARCH SDL2_ttf-devel.$ARCH zip.$ARCH + fi + #elif [ "$OS" = 'RPM-ZYPPER' ] + #then + elif [ "$OS" = 'RPM-YUM' ] + then + if [ "$ARCH" = 'x86_64' ] + then + sudo yum install bzip2.$ARCH ccache.$ARCH clang.$ARCH freetype.$ARCH git.$ARCH glibc.$ARCH lua.$ARCH make.$ARCH SDL2-devel.$ARCH SDL2_image-devel.$ARCH SDL2_mixer-devel.$ARCH SDL2_ttf-devel.$ARCH zip.$ARCH + elif [ "$ARCH" = 'i686' ] + then + sudo yum install clang.$ARCH freetype.$ARCH git.$ARCH glibc.$ARCH lua.$ARCH make.$ARCH SDL2-devel.$ARCH SDL2_image-devel.$ARCH SDL2_mixer-devel.$ARCH SDL2_ttf-devel.$ARCH zip.$ARCH + fi + fi + if [ "$OS" = 'Debian' ] + then + GRAPHICS=$(dpkg -l 2>/dev/null | grep "xinit" | awk '{print $2}') + elif [ "$OS" = 'Arch' ] + then + GRAPHICS=$(pacman -Q | awk '{print $1}' | grep "xinit") + elif [ "$OS" = 'RPM-DNF' ] + then + GRAPHICS=$(dnf list installed | grep xinit | awk '{print $1}') + #elif [ "$OS" = 'RPM-ZYPPER' ] + #then + # GRAPHICS=$(rpm -qa | grep xinit | awk '{print $1}') + elif [ "$OS" = 'RPM-YUM' ] + then + GRAPHICS=$(yum list installed | grep xinit | awk '{print $1}') + fi + if ! [[ "$GRAPHICS" =~ xinit ]] then echo "It would appear that you do not have a graphical environment installed." read -n 1 -p "Would you like to install one now so you can play the Tiles version? (Please enter Y or N.) (If you select Y, then i3WM and Xorg will be installed): " GUI echo "" if [[ ( "$GUI" = 'Y' ) || ( "$GUI" = 'y' ) ]] then - sudo apt-get update && sudo apt-get install i3 lightdm xinit x11-server-utils zip -y - elif [[ ( "$GUI" = 'N' ) || ( "$GUI" = 'n' ) ]] + if [ "$OS" = 'Debian' ] + then + sudo apt-get update && sudo apt-get install i3 lightdm xinit x11-server-utils -y + elif [ "$OS" = 'Arch' ] + then + sudo pacman -Syy && sudo pacman -S i3 lightdm xinit + elif [ "$OS" = 'RPM-DNF' ] + then + if [ "$ARCH" = 'x86_64' ] + then + sudo dnf install i3.$ARCH lightdm.$ARCH + elif [ "$ARCH" = 'i686' ] + then + echo "Sorry, I couldn't find a way to install a GUI environment on a 32-bit system for!" + fi + #elif [ "$OS" = 'RPM-ZYPPER' ] + #then + elif [ "$OS" = 'RPM-YUM' ] + then + if [ "$ARCH" = 'x86_64' ] + then + sudo yum install i3.$ARCH lightdm.$ARCH + elif [ "$ARCH" = 'i686' ] + then + echo "Sorry, I couldn't find a way to install a GUI environment on a 32-bit system for!" + fi + fi + elif [[ ( "$GUI" = 'N' ) || ( "$GUI" = 'n' ) ]] then echo "Sorry, the Tiles version of C:DDA cannot work without a GUI." exit @@ -71,7 +217,10 @@ then then LAUNCHER=$(pwd) fi - mkdir $LAUNCHER/backups + if [ -d $LAUNCHER/backups ] + then + mkdir $LAUNCHER/backups + fi echo "Installing new font." mkdir temp @@ -79,7 +228,11 @@ then wget https://www.fontsquirrel.com/fonts/download/white-rabbit mv white-rabbit white-rabbit.zip unzip white-rabbit.zip - sudo mv whitrabt.ttf /usr/local/share/fonts/ + sudo mv whitrabt.ttf /usr/share/fonts/ + if type fc-cache >/dev/null 2>&1 + then + fc-cache -f + fi cd .. && rm -r temp echo "xterm*faceName: White Rabbit" > $LAUNCHER/backups/game-font echo "xterm*faceSize: 14" >> $LAUNCHER/backups/game-font @@ -103,7 +256,7 @@ then echo " echo 'Restoring regular font.'" >> $LAUNCHER/cataclysm-launcher.sh echo " cp \$LAUNCHDIRECTORY/backups/regular-font ~/.Xresources" >> $LAUNCHER/cataclysm-launcher.sh echo "else" >> $LAUNCHER/cataclysm-launcher.sh - echo " rm ~/.Xresources" >> $LAUNCHER/cataclysm-launcher.sh + echo " rm -f ~/.Xresources" >> $LAUNCHER/cataclysm-launcher.sh echo "fi" >> $LAUNCHER/cataclysm-launcher.sh echo "unset LAUNCHDIRECTORY" >> $LAUNCHER/cataclysm-launcher.sh echo "unset GAMEDIRECTORY" >> $LAUNCHER/cataclysm-launcher.sh @@ -119,7 +272,7 @@ then if [[ ( "$VERSION" = 'N' ) || ( "$VERSION" = 'n' ) ]] then make -s -j$(nproc --all) CLANG=1 CCACHE=1 RELEASE=1 LUA=1 USE_HOME_DIR=1 - elif [[ ( "$VERSION" = 'T' ) || ( "$VERSION" = 't' ) ]] +elif [[ ( "$VERSION" = 'T' ) || ( "$VERSION" = 't' ) ]] then make -s -j$(nproc --all) CLANG=1 CCACHE=1 RELEASE=1 LUA=1 TILES=1 USE_HOME_DIR=1 fi @@ -150,7 +303,15 @@ then echo "make clean" >> $LAUNCHER/cataclysm-updater.sh if [[ ( "$VERSION" = 'N' ) || ( "$VERSION" = 'n' ) ]] then - echo "make -s -j$(nproc --all) CLANG=1 CCACHE=1 RELEASE=1 LUA=1 USE_HOME_DIR=1" >> $LAUNCHER/cataclysm-updater.sh + if [[ "$OS" =~ 'RPM' ]] + then + if [ "$ARCH" = 'i686' ] + then + echo "make -s -j$(nproc --all) CLANG=1 RELEASE=1 LUA=1 USE_HOME_DIR=1" >> $LAUNCHER/cataclysm-updater.sh + fi + else + echo "make -s -j$(nproc --all) CLANG=1 CCACHE=1 RELEASE=1 LUA=1 USE_HOME_DIR=1" >> $LAUNCHER/cataclysm-updater.sh + fi elif [[ ( "$VERSION" = 'T' ) || ( "$VERSION" = 't' ) ]] then echo "make -s -j$(nproc --all) CLANG=1 CCACHE=1 RELEASE=1 LUA=1 TILES=1 USE_HOME_DIR=1" >> $LAUNCHER/cataclysm-updater.sh @@ -164,3 +325,5 @@ unset FONT unset LAUNCHER unset UPDATE unset GUI +unset OS +unset GRAPHICS