#!/bin/sh # $Id$ source /etc/installer.conf convert_to_message() { # only für ncurses gui [[ ${GUITYPE} != ncurses ]] && return 0 local method="$1" local message local pkg if [[ ${method} = --install ]] then pkg=$(echo "${@#$1}" | sed 's/.*:\ .*\/\(.*\).*/\1/') else pkg=$(echo "${@#$1}" | sed 's/.*:\ \(.*\).mpk.*/\1/;s/\//\ /g') fi case ${method} in --fetch) message="Fetching ${pkg}..." ;; --unpack) message="Decompressing ${pkg}..." ;; --install) message="Installing ${pkg}..." ;; esac echo -en "\nXXX\n${message}\nXXX\n" } convert_to_percent() { local percent # never get 100% here, we define it our self or the dialogbox closes unwilingly percent=$(echo "$@" | sed 's/.*(\(.*\)).*/\1/;s/\//\ /g' | awk '{print ($1 / $2 * 100) - 1}') if [[ ${GUITYPE} = ncurses ]] then # no floats in ncurses gui possible printf %.0f "${percent}" else echo "${percent}" fi } wrapper() { local action="$1" local line ${action} | while read line do # add an entry to install log echo "${line}" >> ${INSTALLER_LOG} case $line in #*fetching*:*|*!fetch*|*fetch\ complete*) convert_to_message --fetch ${line}; convert_to_percent ${line};; #*unpacking*:*|*!unpack*) convert_to_message --unpack ${line}; convert_to_percent ${line};; #*installing*:*) convert_to_message --install ${line}; convert_to_percent ${line};; *fetching*:*) convert_to_message --fetch ${line}; convert_to_percent ${line};; *unpacking*:*) convert_to_message --unpack ${line}; convert_to_percent ${line};; *installing*:*) convert_to_message --install ${line}; convert_to_percent ${line};; *) [[ ${DEBUG} = true ]] && echo "${line}" ;; esac done # 100% here, close the dialog echo "100" } install_stage() { # redirect stderr to stdout! NOCOLORS=true bootstrap-default-system 2>&1 } case $1 in --ncurses) GUITYPE="ncurses" ;; --gtk) GUITYPE="gtk" ;; *) GUITYPE="gtk" ;; esac wrapper install_stage