diff packaging/linux-installer.inc.in @ 878:ad3b32a7375f

merge
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 07 Aug 2014 19:13:46 +0200
parents 78096ad6f418
children 1cc9faa572fd
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Thu Aug 07 19:13:32 2014 +0200
+++ b/packaging/linux-installer.inc.in	Thu Aug 07 19:13:46 2014 +0200
@@ -171,7 +171,13 @@
     autostart_path=${XDG_CONFIG_HOME:-~/.config/autostart}
     startmenu_path=${XDG_DATA_HOME:-~/.local/share/applications}
   fi
-    instcfg_file="${instcfg_path}/${INSTCFGNAME}"
+  instcfg_file="${instcfg_path}/${INSTCFGNAME}"
+  extra_bin_path=`mktemp --tmpdir -d tmpbin.XXXXXXXXXX`
+}
+
+cleanup()
+{
+  rm -rf "$extra_bin_path"
 }
 
 write_instcfg()
@@ -392,6 +398,38 @@
   write_autostart "${autostart_path}/trustbridge.desktop"
 }
 
+provide_uudecode_maybe()
+{
+  # The shar needs uudecode, which might not be installed.  If its not
+  # available we will provide our own python based implementation.
+  if which uudecode >/dev/null 2>&1 ; then
+      getxt "Found system uudecode.\n"
+  else
+    local myuudecode="$extra_bin_path/uudecode"
+    cat >"$myuudecode" <<EOF
+#!/usr/bin/python2
+import os
+import sys
+import uu
+os.path.chmod = os.chmod
+def rm_if_exists(file):
+    try:
+        os.remove(file)
+    except OSError:
+        pass
+os.path.exists = rm_if_exists
+if len(sys.argv) > 1:
+    f = open(sys.argv[1], 'r')
+else:
+    f = sys.stdin
+uu.decode(f, None, None, 1)
+EOF
+    chmod 755 "$myuudecode"
+    PATH="${extra_bin_path}:$PATH"
+    getxt "Using python uudecode provided by installer.\n"
+  fi
+}
+
 #======================================================================
 # main()
 
@@ -444,6 +482,9 @@
     install -d "${instcfg[PREFIX]}" || fatal "Could not create '%s'!\n" "${instcfg[PREFIX]}"
 fi
 
+getxt "checking for uudecode ...\n"
+provide_uudecode_maybe
+
 getxt "unpacking files ...\n"
 cd "${instcfg[PREFIX]}"
 
@@ -469,4 +510,7 @@
 
 getxt "Writing installation configuration to: %s ...\n" "$instcfg_file"
 write_instcfg
+
+getxt "Cleaning up temporary stuff ...\n"
+cleanup
 exit 0

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