Merge pull request #826 from nullworks/totallynotelite

Update script migration and install script improvements
This commit is contained in:
TotallyNotElite 2019-09-29 16:53:14 +02:00 committed by GitHub
commit e65736f5b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 62 deletions

View File

@ -41,7 +41,7 @@ and a lot of useful features, including
## Automatic: (Ubuntu 17.10+/Arch based only)
Run in terminal:
* `wget -O - https://raw.githubusercontent.com/nullworks/One-in-all-cathook-install/master/install-all | bash`
* `bash <(wget -qO- https://raw.githubusercontent.com/nullworks/One-in-all-cathook-install/master/install-all)`
## Manual (Outdated):
You need CMake to build cathook, CMake should take care of dependencies

View File

@ -2,17 +2,10 @@
RUNUSER="sudo -u $LOGNAME"
#
# Install git in case this is a install-all only install
#
if [ -x "$(command -v pacman)" ]; then
sudo pacman -S --needed --noconfirm git
elif [ -x "$(command -v apt-get)" ]; then
sudo apt-get install -y git
else
echo -e "\033[1;31m\nCathook autoinstall is not supported on this system! Please install the following packages before continuing: Git, Boost + Headers, CMake, Gcc with 32 bit support, Gdb, 32 Bit SDL + Headers, 32 Bit Glew + Headers, 32 Bit Freetype 2 + Headers, Rsync, 32 Bit libglvnd\n\033[0m"
read -p "Press enter to continue or CTRL+C to cancel."
fi
set -e
# install all dependencies
./scripts/dependencycheck
#
# Update cathook
@ -25,9 +18,6 @@ fi
$RUNUSER git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest && $RUNUSER git reset --hard latest # pull changes from github
$RUNUSER git submodule update --depth 1 --init --recursive # update/init submodules
# install all dependencies and allow non interactive install
./scripts/dependencycheck true
#
# Set config version for update script
#
@ -38,7 +28,4 @@ $RUNUSER bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferen
# Build cathook
#
$RUNUSER mkdir -p ./build; pushd build #create a directory for building cathook
$RUNUSER cmake ..;$RUNUSER make -j$(grep -c '^processor' /proc/cpuinfo) # create makefile and build using all available threads
sudo make data # create /opt/cathook/data
popd; cd ..
$RUNUSER ./update

View File

@ -3,12 +3,6 @@
arch_packages=(git boost cmake make gcc gdb lib32-sdl2 lib32-glew lib32-freetype2 rsync lib32-libglvnd dialog)
ubuntu_packages=(software-properties-common build-essential git g++ g++-multilib libboost-all-dev gdb libsdl2-dev:i386 libglew-dev:i386 libfreetype6-dev:i386 cmake dialog rsync)
if [ "$1" == true ]; then
allow_non_interactive=true
else
allow_non_interactive=false
fi
if [ -x "$(command -v pacman)" ]; then
pacman -Qi "${arch_packages[@]}" > /dev/null 2>&1
out=$?
@ -26,8 +20,6 @@ if [ -x "$(command -v pacman)" ]; then
if [ "$out" != 0 ]; then
exit
fi
elif [ "$allow_non_interactive" == false ]; then
exit
fi
sudo pacman -S --noconfirm --needed "${arch_packages[@]}"
fi
@ -48,15 +40,13 @@ elif [ -x "$(command -v apt-get)" ]; then
if [ "$out" != 0 ]; then
exit
fi
elif [ "$allow_non_interactive" == false ]; then
exit
fi
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y "${ubuntu_packages[@]}"
sudo apt-get update
sudo apt-get install -y "${ubuntu_packages[@]}"
fi
else
echo -e "\033[1;33m\nWarning! Automatic package installation is not supported!\n\033[0m"

49
scripts/migrations Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -e
configfile="./scripts/updater-preferences"
. ./scripts/config.shlib
# Migrate pre config lib configs
exists=true
cfg_haskey $configfile version || exists=false
if [ "$exists" == false ]; then
if [ -f $configfile ]; then
value=$(cat $configfile)
rm $configfile
fi
echo "" > $configfile
cfg_write $configfile version 1
if [ "$(git rev-parse --is-shallow-repository)" == "true" ]; then
cfg_write $configfile update_channel stable
else
cfg_write $configfile update_channel developer
fi
if [ -f $configfile ]; then
if [ "$value" == true ] || [ "$value" == false ]; then
cfg_write $configfile autoupdater $value
fi
fi
fi
version="$(cfg_read $configfile version)"
tui=true
if [ ! -x "$(command -v dialog)" ]; then
tui=false
echo -e "\033[1;31mTerminal UI NOT supported! Install \"dialog\"! \033[0m"
fi
if [ ! -t 0 ]; then
tui=false
fi
#
# Migrations go here
#
exists=true
cfg_haskey $configfile update_channel || exists=false
if [ "$exists" == false ]; then
cfg_write $configfile update_channel stable
fi

View File

@ -19,29 +19,13 @@ fi
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
. ./scripts/config.shlib
#Check if all required packages are installed
./scripts/dependencycheck
# Migrate existing configs
exists=true
cfg_haskey $configfile version || exists=false
if [ "$exists" == false ]; then
if [ -f $configfile ]; then
value=$(cat $configfile)
rm $configfile
fi
echo "" > $configfile
cfg_write $configfile version 1
if [ "$(git rev-parse --is-shallow-repository)" == "true" ]; then
cfg_write $configfile update_channel stable
else
cfg_write $configfile update_channel developer
fi
if [ -f $configfile ]; then
if [ "$value" == true ] || [ "$value" == false ]; then
cfg_write $configfile autoupdater $value
fi
fi
fi
# Run migrations
./scripts/migrations || exit 0
. ./scripts/config.shlib
tui=true
if [ ! -x "$(command -v dialog)" ]; then
@ -67,12 +51,6 @@ if [ "$tui" == true ] && [ "$exists" == false ]; then
cfg_write $configfile autoupdater $value
fi
exists=true
cfg_haskey $configfile update_channel || exists=false
if [ "$exists" == false ]; then
cfg_write $configfile update_channel stable
fi
exists=true
cfg_haskey $configfile autoupdater || exists=false
if [ "$1" == "--autoupdater" ]; then
@ -84,9 +62,6 @@ if [ "$1" == "--autoupdater" ]; then
echo -e "\033[1;34m \n \nAuto Updater: Updating cathook in the background\n\033[0m"
fi
#Check if all required packages are installed
./scripts/dependencycheck
function performupdate() {
#get update channel from config
update_channel="$(cfg_read $configfile update_channel)"
@ -108,6 +83,9 @@ function performupdate() {
exit 1
fi
# Run migrations
./scripts/migrations || exit 0
proccount=$(grep -c '^processor' /proc/cpuinfo)
if [ "$AUTOUPDATER" == true ]; then
proccount=1