[PATCH] Cleanup temporary stuff (like shar lockdir) always (even when interrupted) on exit

Wald Commits scm-commit at wald.intevation.org
Fri Aug 22 18:04:28 CEST 2014


# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1408723432 -7200
# Node ID e977f7a0e8fdae1005b6bea52e10569bc3e05311
# Parent  519b14c5260de9176cde0732ec47984438043f11
Cleanup temporary stuff (like shar lockdir) always (even when interrupted) on exit.

diff -r 519b14c5260d -r e977f7a0e8fd packaging/linux-installer.inc.in
--- a/packaging/linux-installer.inc.in	Fri Aug 22 17:16:53 2014 +0200
+++ b/packaging/linux-installer.inc.in	Fri Aug 22 18:03:52 2014 +0200
@@ -177,7 +177,13 @@
 
 cleanup()
 {
-  rm -rf "$extra_bin_path"
+  getxt "Cleaning up temporary stuff ...\n"
+  # remove temporary directories,
+  # $lock_dir is generate by the shar
+  for dir in "${instcfg[PREFIX]}/$lock_dir" "$extra_bin_path" ; do
+    [ -d "$dir" ] &&
+        rm -rf "$dir"
+  done
 }
 
 write_instcfg()
@@ -433,6 +439,7 @@
 
 #======================================================================
 # main()
+trap cleanup EXIT
 
 parse_args "$@"
 init_vars
@@ -512,6 +519,6 @@
 getxt "Writing installation configuration to: %s ...\n" "$instcfg_file"
 write_instcfg
 
-getxt "Cleaning up temporary stuff ...\n"
-cleanup
+# cleanup
+# is called implicitly at exit via trap...
 exit 0


More information about the Trustbridge-commits mailing list