1 |
#!/bin/sh |
#!/bin/sh |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/include/bootstrap-wrapper.sh,v 1.1 2008-09-24 10:54:00 niro Exp $ |
# $Id$ |
3 |
|
|
4 |
# boostrap-wrapper |
convert_to_message() |
5 |
# |
{ |
6 |
# run_bootstrap() |
# only für ncurses gui |
7 |
# { |
[[ ${GUITYPE} != ncurses ]] && return 0 |
8 |
# local line |
|
9 |
# |
local method="$1" |
10 |
# while read line |
local message |
11 |
# do |
local pkg |
12 |
# echo $line |
|
13 |
# sleep 0.01 |
if [[ ${method} = --install ]] |
14 |
# done < ~/boostrap.log |
then |
15 |
# |
pkg=$(echo "${@#$1}" | sed 's/.*:\ .*\/\(.*\).*/\1/') |
16 |
# # bootstrap-default-system |
else |
17 |
# } |
pkg=$(echo "${@#$1}" | sed 's/.*:\ \(.*\).mpk.*/\1/;s/\//\ /g') |
18 |
|
fi |
19 |
|
|
20 |
|
case ${method} in |
21 |
|
--fetch) message="Fetching ${pkg}..." ;; |
22 |
|
--unpack) message="Decompressing ${pkg}..." ;; |
23 |
|
--install) message="Installing ${pkg}..." ;; |
24 |
|
esac |
25 |
|
echo -en "\nXXX\n${message}\nXXX\n" |
26 |
|
} |
27 |
|
|
28 |
convert_to_percent() |
convert_to_percent() |
29 |
{ |
{ |
30 |
|
local percent |
31 |
# never get 100% here, we define it our self or the dialogbox closes unwilingly |
# never get 100% here, we define it our self or the dialogbox closes unwilingly |
32 |
echo "$@" | sed 's/.*(\(.*\)).*/\1/;s/\//\ /g' | awk '{print ($1 / $2 * 100) - 1}' |
percent=$(echo "$@" | sed 's/.*(\(.*\)).*/\1/;s/\//\ /g' | awk '{print ($1 / $2 * 100) - 1}') |
33 |
|
if [[ ${GUITYPE} = ncurses ]] |
34 |
|
then |
35 |
|
# no floats in ncurses gui possible |
36 |
|
printf %.0f "${percent}" |
37 |
|
else |
38 |
|
echo "${percent}" |
39 |
|
fi |
40 |
} |
} |
41 |
|
|
42 |
wrapper() |
wrapper() |
47 |
${action} | while read line |
${action} | while read line |
48 |
do |
do |
49 |
case $line in |
case $line in |
50 |
*fetching*:*|*!fetch*|*fetch\ complete*) convert_to_percent ${line};; |
#*fetching*:*|*!fetch*|*fetch\ complete*) convert_to_message --fetch ${line}; convert_to_percent ${line};; |
51 |
*unpacking*:*|*!unpack*) convert_to_percent ${line};; |
#*unpacking*:*|*!unpack*) convert_to_message --unpack ${line}; convert_to_percent ${line};; |
52 |
*installing*:*) convert_to_percent ${line};; |
#*installing*:*) convert_to_message --install ${line}; convert_to_percent ${line};; |
53 |
|
*fetching*:*) convert_to_message --fetch ${line}; convert_to_percent ${line};; |
54 |
|
*unpacking*:*) convert_to_message --unpack ${line}; convert_to_percent ${line};; |
55 |
|
*installing*:*) convert_to_message --install ${line}; convert_to_percent ${line};; |
56 |
*) [[ ${DEBUG} = true ]] && echo "${line}" ;; |
*) [[ ${DEBUG} = true ]] && echo "${line}" ;; |
57 |
esac |
esac |
58 |
done |
done |
61 |
echo "100" |
echo "100" |
62 |
} |
} |
63 |
|
|
64 |
# download_stage1() |
install_stage() |
|
# { |
|
|
# NOCOLORS=true MROOT=/mnt/magellan mage download toolchain |
|
|
# } |
|
|
# |
|
|
# download_stage2() |
|
|
# { |
|
|
# NOCOLORS=true MROOT=/mnt/magellan mage download basesystem26 |
|
|
# } |
|
|
# |
|
|
# install_stage1() |
|
|
# { |
|
|
# NOCOLORS=true MROOT=/mnt/magellan mage install toolchain |
|
|
# } |
|
|
|
|
|
install_stage2() |
|
65 |
{ |
{ |
66 |
NOCOLORS=true bootstrap-default-system |
NOCOLORS=true bootstrap-default-system 2> /dev/null |
67 |
} |
} |
68 |
|
|
69 |
## runme |
case $1 in |
70 |
#wrapper "$1" |
--ncurses) GUITYPE="ncurses" ;; |
71 |
wrapper install_stage2 |
--gtk) GUITYPE="gtk" ;; |
72 |
|
*) GUITYPE="gtk" ;; |
73 |
|
esac |
74 |
|
wrapper install_stage |