changeset 935:e977f7a0e8fd

Cleanup temporary stuff (like shar lockdir) always (even when interrupted) on exit.
author Sascha Wilde <wilde@intevation.de>
date Fri, 22 Aug 2014 18:03:52 +0200
parents 519b14c5260d
children 53f704422fac
files packaging/linux-installer.inc.in
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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

http://wald.intevation.org/projects/trustbridge/