]> git.lizzy.rs Git - rust.git/commitdiff
install: Improve error handling
authorBrian Anderson <banderson@mozilla.com>
Sat, 22 Mar 2014 03:12:51 +0000 (20:12 -0700)
committerBrian Anderson <banderson@mozilla.com>
Mon, 24 Mar 2014 21:29:18 +0000 (14:29 -0700)
src/etc/install.sh

index 5b41e25e2577465565a742a62d7d220287026332..63bb71558ab289b8b09985a4aac3efe2e45be6af 100644 (file)
@@ -224,13 +224,14 @@ step_msg "validating $CFG_SELF args"
 validate_opt
 
 # Sanity check: can we can write to the destination?
-mkdir -p "${CFG_PREFIX}/lib"
+umask 022 && mkdir -p "${CFG_PREFIX}/lib"
+need_ok "directory creation failed"
 touch "${CFG_PREFIX}/lib/rust-install-probe" 2> /dev/null
 if [ $? -ne 0 ]
 then
     err "can't write to destination. try again with 'sudo'."
 fi
-rm -r "${CFG_PREFIX}/lib/rust-install-probe"
+rm "${CFG_PREFIX}/lib/rust-install-probe"
 need_ok "failed to remove install probe"
 
 # Sanity check: can we run these binaries?
@@ -238,35 +239,51 @@ need_ok "failed to remove install probe"
 need_ok "can't run these binaries on this platform"
 
 
-# First, uninstall from the installation prefix
+# First, uninstall from the installation prefix.
+# Errors are warnings - try to rm everything in the manifest even if some fail.
 # FIXME: Hardcoded 'rustlib' ignores CFG_RUSTLIBDIR
 if [ -f "${CFG_PREFIX}/lib/rustlib/manifest" ]
 then
+    # Iterate through installed manifest and remove files
     while read p; do
-        msg "uninstall ${CFG_PREFIX}/$p"
-        rm "${CFG_PREFIX}/$p"
-        need_ok "failed to remove file"
+        msg "removing ${CFG_PREFIX}/$p"
+        if [ -f "${CFG_PREFIX}/$p" ]
+        then
+            rm "${CFG_PREFIX}/$p"
+            if [ $? -ne 0 ]
+            then
+                warn "failed to remove ${CFG_PREFIX}/$p"
+            fi
+        else
+            warn "supposedly installed file ${CFG_PREFIX}/$p does not exist!"
+        fi
     done < "${CFG_PREFIX}/lib/rustlib/manifest"
 
     # Remove 'rustlib' directory
-    msg "uninstall ${CFG_PREFIX}/lib/rustlib"
+    msg "removing ${CFG_PREFIX}/lib/rustlib"
     rm -r "${CFG_PREFIX}/lib/rustlib"
-    need_ok "failed to remove rustlib"
+    if [ $? -ne 0 ]
+    then
+        warn "failed to remove rustlib"
+    fi
 else
     if [ -n "${CFG_UNINSTALL}" ]
     then
-        err "unable to find manifest at ${CFG_PREFIX}/lib/rustlib"
-        exit 0
+        err "unable to find installation manifest at ${CFG_PREFIX}/lib/rustlib"
     fi
 fi
 
 # If we're only uninstalling then exit
 if [ -n "${CFG_UNINSTALL}" ]
 then
+    echo
+    echo "    Rust is uninstalled. Have a nice day."
+    echo
     exit 0
 fi
 
-# Iterate through the new manifest and install files
+
+# Now install, iterate through the new manifest and copy files
 while read p; do
 
     umask 022 && mkdir -p "${CFG_PREFIX}/$(dirname $p)"