Browse Source

Stefan Fiedler:


			
			
				rocklinux
			
			
		
Stefan Fiedler 18 years ago
parent
commit
809d483f52
2 changed files with 70 additions and 72 deletions
  1. +26
    -18
      scripts/Config
  2. +44
    -54
      scripts/config.func

+ 26
- 18
scripts/Config

@ -87,7 +87,7 @@ done
if [ $do_config_cycle = 0 ]
then
export swpid=swp$$
rm -f config.{data,dialog,out,help}.$swpid
rm -f config.{data,dialog,out,help}{,.*}.$swpid
rm -f config.pcache.*.$swpid
rm -f rockdialog.scrltmp # src/rockdialog.bin
mkdir -p src
@ -155,7 +155,7 @@ bprof main start
current=""
menu_this=0 ; menu_current=0 ; menu_counter=0
menu_stack=x ; menu_back=-1 ; menu_backpos=-1
menu_stack=x
mkdir -p config/$config
touch config/$config/{config,packages}
@ -163,7 +163,7 @@ touch config/$config/{config,packages}
rm -rf config/$config.$swpid
cp -r config/$config{,.$swpid}
rm -f config.{dialog,data,help}.$swpid
rm -f config.{dialog,data,help}{,.*}.$swpid
touch config.{dialog,data,help}.$swpid
bprof main stop
@ -211,13 +211,16 @@ configtitle="$(printf ' %-50s %6s active packages ]' \
"[ $(echo `grep '^X' config/$config.$swpid/packages | wc -l`)" )"
bprof main stop
do_dialog_cycle=1
while [ "$do_dialog_cycle" = 1 ] ; do
if [ -z "$oldconfig" ] ; then
bprof rockdialog start
eval "./src/rockdialog.bin --title 'Build Config' \
--backtitle '$configtitle' \
--menu 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
$(( $lines - 4 )) $(( $columns - 5 )) $(( $lines - 12 )) \
'$current' `tr '\n' ' ' < config.dialog.$swpid`" 2> config.out.$swpid
'$current' `tr '\n' ' ' < config.dialog.$menu_current.$swpid`" 2> config.out.$swpid
returncode=$? ; item="`cat config.out.$swpid`"
bprof rockdialog stop
else
@ -226,7 +229,7 @@ fi
bprof main start
[ "$returncode" = 1 -a "$menu_back" -ne -1 ] && returncode="menu-back"
[ "$returncode" = 1 -a "$menu_current" -ne 0 ] && returncode="menu-back"
writeback() {
sort -k1,1r -k3,3 config/$config.$swpid/packages \
@ -246,30 +249,32 @@ writeback() {
exit_code=0
case "$returncode" in
0|6)
command="`grep "^$item " config.data.$swpid | cut -f2-`"
{ echo -e "\n# Remember menu position:\ncurrent='$item'"
echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
echo -e "\n# Execute this config command:\n$command"
} >> config/$config.$swpid/config_usr
command="`grep "^$item " config.data.$menu_current.$swpid | cut -f2-`"
if [[ "$command" != menu_current=* ]] ; then
do_dialog_cycle=0
{ echo -e "\n# Remember menu position:\ncurrent='$item'"
echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
echo -e "\n# Execute this config command:\n$command"
} >> config/$config.$swpid/config_usr
else
eval "$command"
fi
;;
menu-back)
{ echo -e "\n# New menu position:\ncurrent='$menu_backpos'"
echo -e "\n# New sub-menu:\nmenu_current='$menu_back'"
} >> config/$config.$swpid/config_usr
command="`grep "^MENU_BACK " config.data.$menu_current.$swpid | cut -f2-`"
eval "$command"
;;
1|255)
rm -f config.{data,dialog,out,help}.$swpid
do_dialog_cycle=0
rm -f config.{data,dialog,out,help}{,.*}.$swpid
rm -f config.pcache.*.$swpid
rm -f rockdialog.scrltmp # src/rockdialog.bin
echo "New config written to config/$config/*."
echo "Cleaning up. Configuration finished."
exit_code=1 ;;
2)
tempitem=$item
item=$(echo $item | cut -f1 -d' ') # dialog(1) bug?
{ echo -e "\n# Remember menu position:\ncurrent='$item'"
echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
} >> config/$config.$swpid/config_usr
current="$item"
get_help $item > config.dialog.$swpid
@ -281,10 +286,13 @@ case "$returncode" in
bprof main start
;;
*)
do_dialog_cycle=0
echo "unknown returncode: $returncode"
exit_code=1 ;;
esac
done
writeback
bprof main stop

+ 44
- 54
scripts/config.func

@ -185,10 +185,10 @@ fi
comment() {
bprof comment start
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ] && \
[ $menu_current = $menu_this ] ; then
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ]
then
commentnr=$(( $commentnr + 1 ))
echo "COMMENT_$commentnr '$spacer$1'" >> config.dialog.$swpid
echo "COMMENT_$commentnr '$spacer$1'" >> config.dialog.$menu_this.$swpid
# Hi, esden here, very ill stuff here I save the help
# strings here to a temporary file named config.help.$swpid
@ -203,9 +203,9 @@ comment() {
comment_id() {
bprof comment_id start
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
[ $menu_current = $menu_this ] ; then
echo "$2 '$spacer$1'" >> config.dialog.$swpid
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ]
then
echo "$2 '$spacer$1'" >> config.dialog.$menu_this.$swpid
# If you do not know what mighty esden
# is doing here see comment()
@ -287,15 +287,17 @@ choice() {
echo "export $1='${data//$q/$q\\$q$q}'" >> config/$config.$swpid/config
fi
if [ "$menumode" -gt 0 -a $menu_current = $menu_this ] ; then
if [ "$menumode" -gt 0 ]
then
{ echo -en "$item\tchoice_action '$usr_name' '$usr_data'" ; shift ; shift
echo -n " '' 'Reset_this_switch_to_default_value'"
for x ; do echo -n " '$x'" ; done ; echo ; } >> config.data.$swpid
for x ; do echo -n " '$x'" ; done ; echo ; } >> config.data.$menu_this.$swpid
xdata="$obegin$data$oend"
while [ "$1" -a "$1" != "$data" ] ; do shift ; shift ; done
printf "'$item' '$spacer%-${tabspace}s ${2//_/ }'\n" "$xdata" >> config.dialog.$swpid
printf "'$item' '$spacer%-${tabspace}s ${2//_/ }'\n" "$xdata" \
>> config.dialog.$menu_this.$swpid
fi
bprof choice stop
@ -330,15 +332,16 @@ text() {
local q="'" obegin="(" oend=")"
set_data "$2" "$3"
if [ "$menumode" -gt 0 -a $menu_current = $menu_this ] ; then
if [ "$menumode" -gt 0 ]
then
echo -e "$2\ttext_action '$1' '$usr_name'" \
"'${data//$q/$q\\$q$q}'" >> config.data.$swpid
"'${data//$q/$q\\$q$q}'" >> config.data.$menu_this.$swpid
xdata="${obegin}$( printf "%-${tabspace}s" \
"$(echo $data | cut -c1-20)")${oend}"
printf "'$2' '$spacer%s $1'\n" \
"${xdata//$q/$q\\$q$q}" >> config.dialog.$swpid
"${xdata//$q/$q\\$q$q}" >> config.dialog.$menu_this.$swpid
# If you do not know what mighty esden
# is doin here see comment()
@ -361,11 +364,12 @@ bool() {
local x obegin="[" oend="]"
set_data "$2" "$3"
if [ "$menumode" -gt 0 -a $menu_current = $menu_this ] ; then
if [ "$menumode" -gt 0 ]
then
if [ $data -eq 0 ] ; then x="${obegin} ${oend}" ; else x="${obegin}*${oend}" ; fi
echo -e "$2\tbool_action '$usr_name' '$usr_data' '$3'" >> config.data.$swpid
echo -e "$2\tbool_action '$usr_name' '$usr_data' '$3'" >> config.data.$menu_this.$swpid
printf "$2 '$spacer%-${tabspace}s ${1//_/ }'\n" "$x" >> config.dialog.$swpid
printf "$2 '$spacer%-${tabspace}s ${1//_/ }'\n" "$x" >> config.dialog.$menu_this.$swpid
# If you do not know what mighty esden is doin here see comment()
if [ "$4" != "" ] ; then
@ -404,25 +408,21 @@ editfile() {
line_nr=1
while read line ; do
line="${line//$q/$q\\$q$q}"
if [ $menu_current = $menu_this ] ; then
printf "$1:${editfilenr} '$spacer%-${tabspace}s %s'\n" \
`printf "%03d:" $line_nr` "$line" >> config.dialog.$swpid
printf "$1:${editfilenr} '$spacer%-${tabspace}s %s'\n" \
`printf "%03d:" $line_nr` "$line" >> config.dialog.$menu_this.$swpid
echo -e "$1:${editfilenr}\teditfile_action $2" \
"$line_nr '$3'" >> config.data.$swpid
fi
echo -e "$1:${editfilenr}\teditfile_action $2" \
"$line_nr '$3'" >> config.data.$menu_this.$swpid
editfilenr=$(( $editfilenr + 1 ))
line_nr=$(( $line_nr + 1 ))
done < "$2"
if [ $menu_current = $menu_this ] ; then
printf "$1:${editfilenr} '$spacer%-${tabspace}s %s'\n" \
`printf "%03d:" $line_nr` "<add new rule>" >> config.dialog.$swpid
printf "$1:${editfilenr} '$spacer%-${tabspace}s %s'\n" \
`printf "%03d:" $line_nr` "<add new rule>" >> config.dialog.$menu_this.$swpid
echo -e "$1:${editfilenr}\teditfile_action $2" \
"$line_nr '$3'" >> config.data.$swpid
fi
echo -e "$1:${editfilenr}\teditfile_action $2" \
"$line_nr '$3'" >> config.data.$menu_this.$swpid
editfilenr=$(( $editfilenr + 1 ))
@ -450,32 +450,28 @@ editfile_action() {
startprog() {
bprof startprog start
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
[ $menu_current = $menu_this ] ; then
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ]
then
printf "$1 '$spacer%-${tabspace}s %s'\n" \
"-->" "$2" >> config.dialog.$swpid
echo -e "$1\t$3" >> config.data.$swpid
"-->" "$2" >> config.dialog.$menu_this.$swpid
echo -e "$1\t$3" >> config.data.$menu_this.$swpid
fi
bprof startprog stop
}
block_begin() {
bprof block_begin start
if [ $menu_current = $menu_this ] ; then
[ "$tabspace_list" ] && spacer="$spacer "
tabspace_list="$tabspace $tabspace_list"
tabspace="$(( $tabspace + $1 - 2 ))"
fi
[ "$tabspace_list" ] && spacer="$spacer "
tabspace_list="$tabspace $tabspace_list"
tabspace="$(( $tabspace + $1 - 2 ))"
bprof block_begin stop
}
block_end() {
bprof block_end start
if [ $menu_current = $menu_this ] ; then
spacer="${spacer%??}"
tabspace="${tabspace_list%% *}"
tabspace_list="${tabspace_list#* }"
fi
spacer="${spacer%??}"
tabspace="${tabspace_list%% *}"
tabspace_list="${tabspace_list#* }"
bprof block_end stop
}
@ -491,21 +487,15 @@ menu_begin() {
bprof menu_begin start
menu_counter=$(( $menu_counter + 1 ))
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
[ $menu_current = $menu_this ] ; then
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ]
then
printf "$1 '$spacer%-${tabspace}s %s'\n" \
"===>" "$2" >> config.dialog.$swpid
echo -e "$1\tmenu_current=$menu_counter" >> config.data.$swpid
fi
if [ $ROCKCFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
[ $menu_current = $menu_counter ] ; then
echo "$1 '===> $2'" >> config.dialog.$swpid
echo -e "$1\tmenu_current=$menu_this" >> config.data.$swpid
fi
"===>" "$2" >> config.dialog.$menu_this.$swpid
echo -e "$1\tmenu_current=$menu_counter" >> config.data.$menu_this.$swpid
if [ $menu_current = $menu_counter ] ; then
menu_back=$menu_this
menu_backpos=$1
echo "$1 '===> $2'" >> config.dialog.$menu_counter.$swpid
echo -e "$1\tmenu_current=$menu_this current=$1" >> config.data.$menu_counter.$swpid
echo -e "MENU_BACK\tmenu_current=$menu_this current=$1" >> config.data.$menu_counter.$swpid
fi
menu_stack="$menu_this $menu_stack"

Loading…
Cancel
Save