commit
2f45883735
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -13,9 +13,6 @@
|
|||||||
[submodule "ucccccp"]
|
[submodule "ucccccp"]
|
||||||
path = external/ucccccp
|
path = external/ucccccp
|
||||||
url = https://github.com/nullworks/ucccccp.git
|
url = https://github.com/nullworks/ucccccp.git
|
||||||
[submodule "external/co-library"]
|
|
||||||
path = external/co-library
|
|
||||||
url = https://github.com/nullworks/co-library.git
|
|
||||||
[submodule "external/MicroPather"]
|
[submodule "external/MicroPather"]
|
||||||
path = external/MicroPather
|
path = external/MicroPather
|
||||||
url = https://github.com/nullworks/MicroPather
|
url = https://github.com/nullworks/MicroPather
|
||||||
@ -30,4 +27,4 @@
|
|||||||
url = https://github.com/sakra/cotire
|
url = https://github.com/sakra/cotire
|
||||||
[submodule "external/clip"]
|
[submodule "external/clip"]
|
||||||
path = external/clip
|
path = external/clip
|
||||||
url = https://github.com/nullworks/clip
|
url = https://github.com/nullworks/clip
|
17
install-all
17
install-all
@ -5,23 +5,6 @@ RUNCMD="sudo -u $RUNUSER"
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# install all dependencies
|
|
||||||
./scripts/dependencycheck
|
|
||||||
|
|
||||||
#
|
|
||||||
# Update cathook
|
|
||||||
#
|
|
||||||
if [ ! -d "./.git" ]; then
|
|
||||||
$RUNCMD git init
|
|
||||||
$RUNCMD git remote add origin https://github.com/nullworks/cathook
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set config version for update script
|
|
||||||
#
|
|
||||||
|
|
||||||
$RUNCMD bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferences version 2"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build cathook
|
# Build cathook
|
||||||
#
|
#
|
||||||
|
@ -1,9 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# $1 Git only
|
||||||
|
|
||||||
|
GIT=${1:-false}
|
||||||
|
|
||||||
arch_packages=(git boost cmake make gcc gdb lib32-sdl2 lib32-glew lib32-freetype2 rsync lib32-libglvnd dialog)
|
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)
|
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)
|
||||||
fedora_packages=(cmake dialog make gcc-c++ glibc-devel.i686 freetype-devel.i686 SDL2-devel.i686 glew-devel.i686 boost-devel.i686 rsync gdb git)
|
fedora_packages=(cmake dialog make gcc-c++ glibc-devel.i686 freetype-devel.i686 SDL2-devel.i686 glew-devel.i686 boost-devel.i686 rsync gdb git)
|
||||||
|
|
||||||
|
# Check if we should only install git
|
||||||
|
if [ "$GIT" == true ]; then
|
||||||
|
arch_packages=(git)
|
||||||
|
ubuntu_packages=(git)
|
||||||
|
fedora_packages=(git)
|
||||||
|
fi
|
||||||
|
|
||||||
function requestPermissions {
|
function requestPermissions {
|
||||||
string=$@
|
string=$@
|
||||||
# Prefer GUI question
|
# Prefer GUI question
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# $3 Init
|
# $1 TUI
|
||||||
|
# $2 INIT
|
||||||
|
# $3 Pre update
|
||||||
|
|
||||||
|
CURR_VERSION=3
|
||||||
|
|
||||||
|
TUI=${1:-false}
|
||||||
|
INIT=${2:-false}
|
||||||
|
PRE_UPDATE=${3:-false}
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -17,26 +25,63 @@ if [ ! -t 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Init goes here
|
# Git check, migrate users from .zip to git repos
|
||||||
#
|
#
|
||||||
|
if [ "$PRE_UPDATE" == "true" ]; then
|
||||||
if [ "$3" == true ]; then
|
if [ ! -x "$(command -v git)" ]; then
|
||||||
cfg_write $configfile update_channel stable
|
# install only git
|
||||||
cfg_write $configfile version 3
|
echo git not installed!
|
||||||
|
./scripts/dependencycheck true
|
||||||
|
fi
|
||||||
|
if [ ! -d "./.git" ]; then
|
||||||
|
git init
|
||||||
|
git remote add origin https://github.com/nullworks/cathook
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version="$(cfg_read $configfile version)"
|
#
|
||||||
|
# Init goes here
|
||||||
|
#
|
||||||
|
function init() {
|
||||||
|
if [ "$INIT" == true ]; then
|
||||||
|
cfg_write $configfile update_channel stable
|
||||||
|
cfg_write $configfile version $CURR_VERSION
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Migrations go here
|
# Migrations go here
|
||||||
#
|
#
|
||||||
|
function migrations() {
|
||||||
exists=true
|
exists=true
|
||||||
|
cfg_haskey $configfile version || exists=false
|
||||||
if [ "$version" == 1 ] || [ "$version" == 2 ]; then
|
if [ "$exists" == true ]; then
|
||||||
cfg_write $configfile version 3
|
version="$(cfg_read $configfile version)"
|
||||||
if [ -d "./build/CMakeFiles/cathook.dir" ]; then
|
else
|
||||||
rm -r ./build/CMakeFiles/cathook.dir
|
# No version string. Nothing we can do.
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if (( $version > $CURR_VERSION )); then
|
||||||
|
cfg_write $configfile version $CURR_VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Hack to fix compile error between version 1 and version 3. Version 2 was set on installs on accident.
|
||||||
|
if [ "$version" == 1 ] || [ "$version" == 2 ]; then
|
||||||
|
cfg_write $configfile version 3
|
||||||
|
if [ -d "./build/CMakeFiles/cathook.dir" ]; then
|
||||||
|
rm -r ./build/CMakeFiles/cathook.dir
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$PRE_UPDATE" == "true" ] && [ "$INIT" == "true" ]; then
|
||||||
|
# Our job is done here. We dont want to set a config version here yet.
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$INIT" == true ]; then
|
||||||
|
init
|
||||||
|
else
|
||||||
|
migrations
|
||||||
fi
|
fi
|
||||||
|
@ -4,14 +4,15 @@
|
|||||||
# $2 Disable TUI
|
# $2 Disable TUI
|
||||||
# $3 Init
|
# $3 Init
|
||||||
|
|
||||||
ARG1=${1:-false}
|
AUTO_UPDATER_ENABLED=${1:-false}
|
||||||
ARG2=${2:-false}
|
DISABLE_TUI=${2:-false}
|
||||||
ARG3=${3:-false}
|
INIT=${3:-false}
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
configfile="./scripts/updater-preferences"
|
configfile="./scripts/updater-preferences"
|
||||||
|
|
||||||
|
# Verify that we aren't root
|
||||||
if [ $(id -u) -eq 0 ]; then
|
if [ $(id -u) -eq 0 ]; then
|
||||||
echo -e "\033[1;33m \n \nThis script must'nt be run as root!\n\033[0m"
|
echo -e "\033[1;33m \n \nThis script must'nt be run as root!\n\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
@ -29,34 +30,41 @@ echo $$ > ${LOCKFILE}
|
|||||||
|
|
||||||
. ./scripts/config.shlib
|
. ./scripts/config.shlib
|
||||||
|
|
||||||
# Run migrations
|
# If the config file doesn't exist, create it
|
||||||
|
if [ ! -e ${configfile} ]; then
|
||||||
|
touch ${configfile}
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Check if TUI is available
|
||||||
|
tui=true
|
||||||
|
dialog=true
|
||||||
|
if [ ! -t 0 ]; then
|
||||||
|
tui=false
|
||||||
|
fi
|
||||||
|
if [ "$DISABLE_TUI" == "true" ]; then
|
||||||
|
tui=false
|
||||||
|
fi
|
||||||
|
if [ ! -x "$(command -v dialog)" ] || [ "$tui" == false ]; then
|
||||||
|
dialog=false
|
||||||
|
if [ "$tui" == true ]; then
|
||||||
|
echo -e "\033[1;31mTerminal UI NOT supported! Install \"dialog\"! \033[0m"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run migrations if not a developer
|
||||||
exists=true
|
exists=true
|
||||||
cfg_haskey $configfile update_channel || exists=false
|
cfg_haskey $configfile update_channel || exists=false
|
||||||
if [ "$exists" == true ]; then
|
if [ "$exists" == true ]; then
|
||||||
update_channel="$(cfg_read $configfile update_channel)"
|
update_channel="$(cfg_read $configfile update_channel)"
|
||||||
fi
|
fi
|
||||||
if [ "$update_channel" != "developer" ] && [ "$ARG3" == false ]; then
|
if [ "$update_channel" != "developer" ]; then
|
||||||
./scripts/migrations $ARG1 $ARG2 false || exit 0
|
./scripts/migrations $tui $INIT true || exit 1
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if all required packages are installed
|
|
||||||
./scripts/dependencycheck
|
|
||||||
|
|
||||||
tui=true
|
|
||||||
if [ ! -t 0 ]; then
|
|
||||||
tui=false
|
|
||||||
fi
|
|
||||||
if [ "$ARG2" == "true" ]; then
|
|
||||||
tui=false
|
|
||||||
fi
|
|
||||||
if [ ! -x "$(command -v dialog)" ] && [ "$tui" == true ]; then
|
|
||||||
tui=false
|
|
||||||
echo -e "\033[1;31mTerminal UI NOT supported! Install \"dialog\"! \033[0m"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ask the user if they want to enable the auto updater
|
||||||
exists=true
|
exists=true
|
||||||
cfg_haskey $configfile autoupdater || exists=false
|
cfg_haskey $configfile autoupdater || exists=false
|
||||||
if [ "$tui" == true ] && [ "$exists" == false ]; then
|
if [ "$dialog" == true ] && [ "$exists" == false ]; then
|
||||||
value=true
|
value=true
|
||||||
response=255
|
response=255
|
||||||
while [ "$response" != 0 ] && [ "$response" != 1 ]; do
|
while [ "$response" != 0 ] && [ "$response" != 1 ]; do
|
||||||
@ -69,9 +77,10 @@ if [ "$tui" == true ] && [ "$exists" == false ]; then
|
|||||||
cfg_write $configfile autoupdater $value
|
cfg_write $configfile autoupdater $value
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Send notice about auto updater, terminate script if its not enabled
|
||||||
exists=true
|
exists=true
|
||||||
cfg_haskey $configfile autoupdater || exists=false
|
cfg_haskey $configfile autoupdater || exists=false
|
||||||
if [ "$ARG1" == "true" ]; then
|
if [ "$AUTO_UPDATER_ENABLED" == "true" ]; then
|
||||||
if [ $exists == false ] || [ "$(cfg_read $configfile autoupdater)" == false ]; then
|
if [ $exists == false ] || [ "$(cfg_read $configfile autoupdater)" == false ]; then
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
@ -82,11 +91,18 @@ fi
|
|||||||
|
|
||||||
function performupdate() {
|
function performupdate() {
|
||||||
# If init, then update_channel isn't set yet. Assume stable.
|
# If init, then update_channel isn't set yet. Assume stable.
|
||||||
if [ "$ARG3" == true ]; then
|
if [ "$INIT" == true ]; then
|
||||||
update_channel="stable"
|
update_channel="stable"
|
||||||
else
|
else
|
||||||
#get update channel from config
|
#get update channel from config
|
||||||
update_channel="$(cfg_read $configfile update_channel)"
|
exists=true
|
||||||
|
cfg_haskey $configfile autoupdater || exists=false
|
||||||
|
cfg_haskey $configfile version || exists=false
|
||||||
|
if [ "$exists" == true ]; then
|
||||||
|
update_channel="$(cfg_read $configfile update_channel)"
|
||||||
|
else
|
||||||
|
update_channel="invalid"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$update_channel" == "stable" ]; then
|
if [ "$update_channel" == "stable" ]; then
|
||||||
@ -96,11 +112,12 @@ function performupdate() {
|
|||||||
elif [ "$update_channel" == "developer" ]; then
|
elif [ "$update_channel" == "developer" ]; then
|
||||||
echo -e "\033[1;33m\nWarning! Running in developer mode! Expect issues!\n\033[0m" && git pull origin || { echo -e "\033[1;31m\n\nFailed to pull from github!\n\033[0m"; exit 1; }
|
echo -e "\033[1;33m\nWarning! Running in developer mode! Expect issues!\n\033[0m" && git pull origin || { echo -e "\033[1;31m\n\nFailed to pull from github!\n\033[0m"; exit 1; }
|
||||||
else
|
else
|
||||||
if [ "$tui" == true ]; then
|
if [ "$dialog" == true ]; then
|
||||||
value=true
|
value=true
|
||||||
dialog --keep-tite --title "Updater" --yesno "Unknown update channel. Restore to stable update channel?" 10 25 || value=false
|
dialog --keep-tite --title "Updater" --yesno "Unknown update channel or version. Restore to stable update channel and reset version?" 10 25 || value=false
|
||||||
if [ "$value" == true ]; then
|
if [ "$value" == true ]; then
|
||||||
cfg_write $configfile update_channel stable
|
# force reinit
|
||||||
|
./scripts/migrations $tui true false || exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
@ -108,17 +125,21 @@ function performupdate() {
|
|||||||
|
|
||||||
# Run migrations
|
# Run migrations
|
||||||
if [ "$update_channel" != "developer" ]; then
|
if [ "$update_channel" != "developer" ]; then
|
||||||
./scripts/migrations $ARG1 $ARG2 $ARG3 || exit 0
|
./scripts/migrations $tui $INIT false || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#submodules
|
# Check if all required packages are installed
|
||||||
|
./scripts/dependencycheck
|
||||||
|
|
||||||
|
# Submodules
|
||||||
if [ "$update_channel" == "developer" ]; then
|
if [ "$update_channel" == "developer" ]; then
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
else
|
else
|
||||||
git submodule sync
|
git submodule sync > /dev/null
|
||||||
git submodule update --depth 1 --init --recursive
|
git submodule update --depth 1 --init --recursive
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make sure that the auto updater only uses 1 core for compiling
|
||||||
proccount=$(grep -c '^processor' /proc/cpuinfo)
|
proccount=$(grep -c '^processor' /proc/cpuinfo)
|
||||||
if [ "$AUTOUPDATER" == true ]; then
|
if [ "$AUTOUPDATER" == true ]; then
|
||||||
proccount=1
|
proccount=1
|
||||||
@ -127,9 +148,10 @@ function performupdate() {
|
|||||||
#Create build folder in case it doesn't exist
|
#Create build folder in case it doesn't exist
|
||||||
mkdir -p ./build
|
mkdir -p ./build
|
||||||
# Update cathook
|
# Update cathook
|
||||||
cd build && cmake .. && cmake --build . --target cathook -- -j$proccount || { echo -e "\033[1;31m \n \nFailed to compile cathook\n\033[0m"; exit 1; }
|
pushd build && cmake .. && cmake --build . --target cathook -- -j$proccount || { echo -e "\033[1;31m \n \nFailed to compile cathook\n\033[0m"; exit 1; }
|
||||||
# Update data
|
# Update data
|
||||||
cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory! Trying with root rights!\n\033[0m"; sudo cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory\n\033[0m"; exit 1; } }
|
cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory! Trying with root rights!\n\033[0m"; sudo cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory\n\033[0m"; exit 1; } }
|
||||||
|
popd
|
||||||
echo -e "\n\033[1;34mCathook updated successfully\n\033[0m"
|
echo -e "\n\033[1;34mCathook updated successfully\n\033[0m"
|
||||||
rm -f ${LOCKFILE}
|
rm -f ${LOCKFILE}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user