From 49093fef5d3c3c8cb63ce4020439886102a02788 Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Sat, 25 Nov 2023 16:53:12 +0100 Subject: [PATCH] Updates for rsync --- .install/copy.sh | 6 ++++++ .install/library.sh | 13 +++++++++++++ .install/preparation.sh | 8 +++++++- .install/required.sh | 15 ++++++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/.install/copy.sh b/.install/copy.sh index 4c74935..ce4a5ca 100644 --- a/.install/copy.sh +++ b/.install/copy.sh @@ -54,6 +54,12 @@ if gum confirm "Do you want to install the prepared dotfiles now?" ;then echo "~/dotfiles folder created." fi rsync -a -I ~/dotfiles-versions/$version/ ~/dotfiles/ + if [[ $(_isFolderEmpty ~/dotfiles/) == 0 ]] ;then + echo "AN ERROR HAS OCCURED. Copy prepared dofiles from ~/dotfiles-versions/$version/ to ~/dotfiles/ failed" + echo "Please check that rsync is installad on your system." + echo "Execution of rsync -a -I ~/dotfiles-versions/$version/ ~/dotfiles/ is required." + exit + fi echo "All files from ~/dotfiles-versions/$version/ to ~/dotfiles/ copied." else echo "Skipped: DEV MODE!" diff --git a/.install/library.sh b/.install/library.sh index 7b3916d..9fbb6f2 100755 --- a/.install/library.sh +++ b/.install/library.sh @@ -34,6 +34,19 @@ _isInstalledYay() { return; #false } +_isFolderEmpty() { + folder="$1" + if [ -d $folder ] ;then + if [ -z "$(ls -A $folder)" ]; then + echo 0 + else + echo 1 + fi + else + echo 1 + fi +} + # ------------------------------------------------------ # Function Install all package if not installed # ------------------------------------------------------ diff --git a/.install/preparation.sh b/.install/preparation.sh index d3cb6f0..d20378a 100644 --- a/.install/preparation.sh +++ b/.install/preparation.sh @@ -22,10 +22,16 @@ if [ ! -d ~/dotfiles-versions/$version ]; then echo "~/dotfiles-versions/$version folder created." else echo "The folder ~/dotfiles-versions/$version already exists from previous installations." - rm -fr ~/dotfiles-versions/$version + rm -rf ~/dotfiles-versions/$version mkdir ~/dotfiles-versions/$version echo "Clean build prepared for the installation." fi rsync -a -I --exclude-from=.install/excludes.txt . ~/dotfiles-versions/$version/ +if [[ $(_isFolderEmpty ~/dotfiles-versions/$version/) == 0 ]] ;then + echo "AN ERROR HAS OCCURED. Preparation of ~/dotfiles-versions/$version/ failed" + echo "Please check that rsync is installad on your system." + echo "Execution of rsync -a -I --exclude-from=.install/excludes.txt . ~/dotfiles-versions/$version/ is required." + exit +fi echo "dotfiles $version successfully prepared in ~/dotfiles-versions/$version/" echo "" diff --git a/.install/required.sh b/.install/required.sh index 0390f66..5cfec0f 100644 --- a/.install/required.sh +++ b/.install/required.sh @@ -2,7 +2,20 @@ # Check for required packages to run the installation # ------------------------------------------------------ -echo "Checking that required packages for the installation are installed..." +# Synchronize packages +sudo pacman -Sy echo "" + +# Check for required packages +echo ":: Checking that required packages for the installation are installed..." _installPackagesPacman "rsync" "gum"; +echo "" + +# Double check rsync +if ! command -v rsync &> /dev/null; then + echo ":: Force rsync installation" + sudo pacman -S rsync --noconfirm +else + echo ":: rsync double checked" +fi echo "" \ No newline at end of file