changeset 873:78096ad6f418

Provide own, python based uudecode if none is found in the system.
author Sascha Wilde <wilde@intevation.de>
date Thu, 07 Aug 2014 18:41:00 +0200
parents 02e357826417
children ce7c4d07d4aa
files packaging/linux-installer.inc.in
diffstat 1 files changed, 45 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Wed Aug 06 18:56:23 2014 +0200
+++ b/packaging/linux-installer.inc.in	Thu Aug 07 18:41:00 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/