[PATCH 1 of 2] Provide own, python based uudecode if none is found in the system

Wald Commits scm-commit at wald.intevation.org
Thu Aug 7 18:42:55 CEST 2014


# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1407429660 -7200
# Node ID 78096ad6f418e7dbbde250f6b9d5b901379b97bb
# Parent  02e35782641757a46dd516f518d4218bb70953e1
Provide own, python based uudecode if none is found in the system.

diff -r 02e357826417 -r 78096ad6f418 packaging/linux-installer.inc.in
--- 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


More information about the Trustbridge-commits mailing list