comparison packaging/linux-installer.inc.in @ 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 1cc9faa572fd
comparison
equal deleted inserted replaced
872:02e357826417 873:78096ad6f418
169 instcfg_path="${CFGPATH}" 169 instcfg_path="${CFGPATH}"
170 instdata_path="${DATAPATH}" 170 instdata_path="${DATAPATH}"
171 autostart_path=${XDG_CONFIG_HOME:-~/.config/autostart} 171 autostart_path=${XDG_CONFIG_HOME:-~/.config/autostart}
172 startmenu_path=${XDG_DATA_HOME:-~/.local/share/applications} 172 startmenu_path=${XDG_DATA_HOME:-~/.local/share/applications}
173 fi 173 fi
174 instcfg_file="${instcfg_path}/${INSTCFGNAME}" 174 instcfg_file="${instcfg_path}/${INSTCFGNAME}"
175 extra_bin_path=`mktemp --tmpdir -d tmpbin.XXXXXXXXXX`
176 }
177
178 cleanup()
179 {
180 rm -rf "$extra_bin_path"
175 } 181 }
176 182
177 write_instcfg() 183 write_instcfg()
178 { 184 {
179 install -d `dirname "$instcfg_file"` 185 install -d `dirname "$instcfg_file"`
390 fi 396 fi
391 397
392 write_autostart "${autostart_path}/trustbridge.desktop" 398 write_autostart "${autostart_path}/trustbridge.desktop"
393 } 399 }
394 400
401 provide_uudecode_maybe()
402 {
403 # The shar needs uudecode, which might not be installed. If its not
404 # available we will provide our own python based implementation.
405 if which uudecode >/dev/null 2>&1 ; then
406 getxt "Found system uudecode.\n"
407 else
408 local myuudecode="$extra_bin_path/uudecode"
409 cat >"$myuudecode" <<EOF
410 #!/usr/bin/python2
411 import os
412 import sys
413 import uu
414 os.path.chmod = os.chmod
415 def rm_if_exists(file):
416 try:
417 os.remove(file)
418 except OSError:
419 pass
420 os.path.exists = rm_if_exists
421 if len(sys.argv) > 1:
422 f = open(sys.argv[1], 'r')
423 else:
424 f = sys.stdin
425 uu.decode(f, None, None, 1)
426 EOF
427 chmod 755 "$myuudecode"
428 PATH="${extra_bin_path}:$PATH"
429 getxt "Using python uudecode provided by installer.\n"
430 fi
431 }
432
395 #====================================================================== 433 #======================================================================
396 # main() 434 # main()
397 435
398 parse_args "$@" 436 parse_args "$@"
399 init_vars 437 init_vars
442 if [ ! -d "${instcfg[PREFIX]}" ] ; then 480 if [ ! -d "${instcfg[PREFIX]}" ] ; then
443 getxt "creating installation directory ...\n" 481 getxt "creating installation directory ...\n"
444 install -d "${instcfg[PREFIX]}" || fatal "Could not create '%s'!\n" "${instcfg[PREFIX]}" 482 install -d "${instcfg[PREFIX]}" || fatal "Could not create '%s'!\n" "${instcfg[PREFIX]}"
445 fi 483 fi
446 484
485 getxt "checking for uudecode ...\n"
486 provide_uudecode_maybe
487
447 getxt "unpacking files ...\n" 488 getxt "unpacking files ...\n"
448 cd "${instcfg[PREFIX]}" 489 cd "${instcfg[PREFIX]}"
449 490
450 set +u 491 set +u
451 set -- '-c' 492 set -- '-c'
467 getxt "Setting up start menu entries ...\n" 508 getxt "Setting up start menu entries ...\n"
468 setup_startmenu 509 setup_startmenu
469 510
470 getxt "Writing installation configuration to: %s ...\n" "$instcfg_file" 511 getxt "Writing installation configuration to: %s ...\n" "$instcfg_file"
471 write_instcfg 512 write_instcfg
513
514 getxt "Cleaning up temporary stuff ...\n"
515 cleanup
472 exit 0 516 exit 0

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