From 656e4e4a9e04936348f9cf60768e4d0c2195f67b Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sat, 19 Oct 2019 18:36:08 +0200 Subject: [PATCH 1/3] Add migration to fix error in cotire compile Also make submodule functions run after migrations, dont run migrations for developers --- install-all | 2 +- scripts/migrations | 7 +++++++ scripts/updater | 33 +++++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/install-all b/install-all index eed0cb07..ea4fbeef 100755 --- a/install-all +++ b/install-all @@ -20,7 +20,7 @@ fi # Set config version for update script # -$RUNCMD bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferences version 1" +$RUNCMD bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferences version 2" # # Build cathook diff --git a/scripts/migrations b/scripts/migrations index 417795ac..da8f0543 100755 --- a/scripts/migrations +++ b/scripts/migrations @@ -47,3 +47,10 @@ cfg_haskey $configfile update_channel || exists=false if [ "$exists" == false ]; then cfg_write $configfile update_channel stable fi + +if [ "$version" == 1 ]; then + cfg_write $configfile version 2 + if [ -d "./build/cotire" ]; then + rm -r ./build/cotire + fi +fi diff --git a/scripts/updater b/scripts/updater index 6e2976f7..ca80d379 100755 --- a/scripts/updater +++ b/scripts/updater @@ -22,14 +22,17 @@ fi trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT echo $$ > ${LOCKFILE} -# Run migrations -./scripts/migrations "$@" || exit 0 - -#Check if all required packages are installed -./scripts/dependencycheck - . ./scripts/config.shlib +# Run migrations +update_channel="$(cfg_read $configfile update_channel)" +if [ "$update_channel" != "developer" ]; then + ./scripts/migrations "$@" || exit 0 +fi + +# Check if all required packages are installed +./scripts/dependencycheck + tui=true if [ ! -t 0 ]; then tui=false @@ -73,11 +76,11 @@ function performupdate() { update_channel="$(cfg_read $configfile update_channel)" if [ "$update_channel" == "stable" ]; then - git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest && git reset --hard latest && git submodule update --depth 1 --init --recursive || { echo -e "\033[1;33m\nFailed to pull from github! Trying alternative pull (legacy)\n\033[0m"; git fetch --depth 1 && git reset --hard @{upstream} && git submodule update --depth 1 --init --recursive || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://github.com/nullworks/cathook\n\033[0m"; exit 1; } } + git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest && git reset --hard latest || { echo -e "\033[1;33m\nFailed to pull from github! Trying alternative pull (legacy)\n\033[0m"; git fetch --depth 1 && git reset --hard @{upstream} || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://github.com/nullworks/cathook\n\033[0m"; exit 1; } } elif [ "$update_channel" == "master" ]; then - git fetch --force --depth 1 origin && git reset --hard origin/master && git submodule update --depth 1 --init --recursive || { echo -e "\033[1;33m\nFailed to pull from github! Trying alternative pull (legacy)\n\033[0m"; git fetch --depth 1 && git reset --hard @{upstream} && git submodule update --depth 1 --init --recursive || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://cathook.club\n\033[0m"; exit 1; } } + git fetch --force --depth 1 origin && git reset --hard origin/master || { echo -e "\033[1;33m\nFailed to pull from github! Trying alternative pull (legacy)\n\033[0m"; git fetch --depth 1 && git reset --hard @{upstream} || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://cathook.club\n\033[0m"; exit 1; } } elif [ "$update_channel" == "developer" ]; then - echo -e "\033[1;33m\nWarning! Running in developer mode! Expect issues!\n\033[0m" && git pull origin && git submodule update --init --recursive || { 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 if [ "$tui" == true ]; then value=true @@ -90,8 +93,18 @@ function performupdate() { fi # Run migrations - ./scripts/migrations "$@" || exit 0 + if [ "$update_channel" != "developer" ]; then + ./scripts/migrations "$@" || exit 0 + fi + #submodules + if [ "$update_channel" == "developer" ]; then + git submodule update --init --recursive + else + git submodule sync + git submodule update --depth 1 --init --recursive + fi + proccount=$(grep -c '^processor' /proc/cpuinfo) if [ "$AUTOUPDATER" == true ]; then proccount=1 From 26d9f6d8a390ff04c5e17101b8c3b5061d1a1e65 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sat, 19 Oct 2019 19:21:40 +0200 Subject: [PATCH 2/3] Fix bug in migration --- scripts/migrations | 4 ++-- scripts/updater | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/migrations b/scripts/migrations index da8f0543..6492f38c 100755 --- a/scripts/migrations +++ b/scripts/migrations @@ -50,7 +50,7 @@ fi if [ "$version" == 1 ]; then cfg_write $configfile version 2 - if [ -d "./build/cotire" ]; then - rm -r ./build/cotire + if [ -d "./build/CMakeFiles/cathook.dir" ]; then + rm -r ./build/CMakeFiles/cathook.dir fi fi diff --git a/scripts/updater b/scripts/updater index ca80d379..bde20c39 100755 --- a/scripts/updater +++ b/scripts/updater @@ -25,7 +25,11 @@ echo $$ > ${LOCKFILE} . ./scripts/config.shlib # Run migrations -update_channel="$(cfg_read $configfile update_channel)" +exists=true +cfg_haskey $configfile update_channel || exists=false +if [ "$exists" == true ]; then + update_channel="$(cfg_read $configfile update_channel)" +fi if [ "$update_channel" != "developer" ]; then ./scripts/migrations "$@" || exit 0 fi From bb3ba927d921db3fb8c2381d212945829ee387fd Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sat, 19 Oct 2019 19:34:07 +0200 Subject: [PATCH 3/3] update developer conversion script --- config | 2 +- scripts/developer | 43 ++++++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/config b/config index 0bbc59d6..e8167d97 100755 --- a/config +++ b/config @@ -35,7 +35,7 @@ do elif [ "$response" == 2 ]; then cfg_write $configfile update_channel master elif [ "$response" == 3 ]; then - cfg_write $configfile update_channel developer + ./scripts/developer else continue fi diff --git a/scripts/developer b/scripts/developer index 718605df..277d5f69 100755 --- a/scripts/developer +++ b/scripts/developer @@ -4,17 +4,38 @@ if [ $EUID == 0 ]; then exit fi -if [ ! -f ./scripts/updater-preferences ]; then - while true; do - read -p "Do you want to switch your cathook repository into developer mode? y/n " yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done -fi +while true; do + read -p "Do you want to switch your cathook repository into developer mode? y/n " yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac +done +# git setup git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch --unshallow -git fetch --all +git submodule foreach --recursive 'git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"' +git submodule foreach --recursive 'git fetch --unshallow' + +# config setup +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +configfile="$DIR/updater-preferences" +. config.shlib +cfg_write $configfile update_channel developer + +while true; do + read -p "Would you like to reset your repository to the origin/master branch? y/n " yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac +done + +# more git setup +git reset --hard origin/master +git submodule foreach --recursive 'git reset --hard' +git submodule sync +git submodule update --init --recursive