[librsvg: 2/7] Make cleanup code actually clean everything up Includes a check to not delete "/"




commit a1531b9fc962c70113a0b36f36a16d8afb4df49c
Author: Madds H <madds hollandart io>
Date:   Mon Aug 23 19:44:25 2021 -0500

    Make cleanup code actually clean everything up
    Includes a check to not delete "/"
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/579>

 tools/docker/docker-test.sh | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/tools/docker/docker-test.sh b/tools/docker/docker-test.sh
index d1f1de5b..dfcb3aae 100755
--- a/tools/docker/docker-test.sh
+++ b/tools/docker/docker-test.sh
@@ -57,7 +57,10 @@ function prepare_librsvg {
                echo "Repackaging Librsvg"
                mkdir $TMPDIR
                echo "Copying librsvg to $TMPDIR"
-               cp -r $LIBDIR/. $TMPDIR
+               rsync -av --exclude '.git' --exclude 'target' $LIBDIR/ $TMPDIR/
+
+               #Uncomment this line if your distro doesn't have rsync, it'll make a lot of text when copying 
the git folder, but works
+               #cp -r $LIBDIR/. $TMPDIR
                cd $TMPDIR
 
                #Run autogen, this prepares librsvg for building, and allows make clean to be ran
@@ -109,12 +112,12 @@ function build_docker {
 #removes the designated system image
 function remove_system_image {
        echo "removing system image librsvg-base-$SYS"
-       sudo docker rmi librsvg/librsvg-base-$SYS
+       sudo docker rmi --force librsvg/librsvg-base-$SYS
 }
 
 function remove_librsvg_image {
        echo "removing librsvg image librsvg-$SYS"
-       sudo docker rmi librsvg/librsvg-$SYS
+       sudo docker rmi --force librsvg/librsvg-$SYS
 }
 
 function cleanup {
@@ -136,6 +139,21 @@ function cleanup {
                remove_system_image
                rm $SYS/librsvg.tar.gz
                rm $SYS/build-rsvg.sh
+
+               confirm_rm_dir
+               if [[ "$TMPDIR" == "/" ]] 
+               then
+                       echo "Tried to delete root, exiting"
+                       exit 1
+               fi
+
+               if [[ ! -d "$TMPDIR" ]] 
+               then
+                       echo "$TMPDIR does not exist, exiting"
+                       exit 0
+               fi
+               rm -rf $TMPDIR
+
                exit 0
        fi
        
@@ -150,6 +168,15 @@ function confirm {
                esac
        done
 }
+function confirm_rm_dir {
+       echo "Would you like to also remove the librsvg files from the tmp directory: $TMPDIR"
+       select yn in "Yes" "No"; do
+       case $yn in
+           Yes ) break;;
+           No ) exit 1;;
+               esac
+       done
+}
 
 #runs the built docker image, this runs build_librsvg.sh automatically attached to the console
 function run_docker {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]