2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: scripts/Config
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
7 # Copyright (C) 2004 - 2006 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 Clifford Wolf
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- SDE-COPYRIGHT-NOTE-END ---
18 if [ -z "${lines:=$LINES}" -o -z "${columns:=$COLUMNS}" ] ; then
19 if [ "$( type -p stty )" ] ; then
20 lines
="$( stty size 2> /dev/null | cut -d' ' -f1 )"
21 columns
="$( stty size 2> /dev/null | cut -d' ' -f2 )"
23 [ -z "$lines" -o "$lines" -le 0 ] 2> /dev
/null
&& lines
=24
24 [ -z "$columns" -o "$columns" -le 0 ] 2> /dev
/null
&& columns
=80
27 eval "$( egrep '^sdever=' lib/libsde.in )"
39 echo "Usage: $0 [ -delete | -oldconfig ] [ -cfg <config> ]"
42 echo " -profile create a config.profile with profiling data"
43 echo " -nobashmod don't use the bash config helper plugin"
49 -cycle) do_config_cycle
=1 ; shift ;;
50 -delete) delete_mode
=1 ; shift ;;
51 -profile) profile
='-profile' ; shift ;;
52 -oldconfig) oldconfig
='-oldconfig' ; shift ;;
53 -nobashmod) nobashmod
='-nobashmod' ; shift ;;
54 -cfg) config
="$2" ; shift ; shift ;;
61 if [ -z "$config" ]; then
66 if [ ! -d config
/$config -a -n "$oldconfig" ]; then
67 echo "Abort: -oldconfig is not supported for new configs"
72 if [ $delete_mode = 1 ] ; then
79 if [ $do_config_cycle = 0 ] ; then
81 mkdir
-p $cfgtmpdir # src
83 if [ -z "$oldconfig" -a ! -f tmp
/confdialog.bin
] ; then
84 echo "Creating confdialog tool."
85 command="gcc src/confdialog/*.c `
86 `-Isrc/confdialog -lncurses -o tmp/confdialog.bin"
88 echo "$command" ; eval "$command.$$"
89 mv tmp
/confdialog.bin.$$ tmp
/confdialog.bin
93 # don't accept Ctrl-C because it destroy the configurations
96 if [ -d "config/$config" ]; then
97 if .
/lib
/sde-config
/migrate.sh
"$config"; then
98 mkdir
-p $cfgtmpdir/config
/
99 cp -a config
/$config/* $cfgtmpdir/config
/
100 if [ $?
-ne 0 ]; then
101 echo "Copy of config failed, aborting."
107 echo "Starting OpenSDE ($sdever) configuration ..."
108 while "$0" -cfg $config $oldconfig $profile $nobashmod -cycle ; do : ; done
115 if [ -z "$nobashmod" ]; then
116 if [ ! -f tmp
/config_helper.so
-o src
/tools-source
/config_helper.c
-nt tmp
/config_helper.so
]; then
117 echo "Building tmp/config_helper.so."
118 gcc
-shared -fPIC -Wall -o tmp
/config_helper.so src
/tools-source
/config_helper.c ||
exit 1
120 enable -f tmp
/config_helper.so cfghlp ||
exit 1
123 if [ -z "$profile" ]; then
127 if [ ! -f tmp
/bash_profiler.so
-o src
/tools-source
/bash_profiler.c
-nt tmp
/bash_profiler.so
]; then
128 echo "Building tmp/bash_profiler.so."
129 gcc
-shared -fPIC -Wall -o tmp
/bash_profiler.so src
/tools-source
/bash_profiler.c ||
exit 1
131 enable -f tmp
/bash_profiler.so bprof ||
exit 1
133 local cprof
=$cfgtmpdir/config.profile
134 bprof all print
>> $cprof
136 $4 == "profiled" { next; }
137 $4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; }
138 { count[$4]+=$1; time[$4]+=$2; }
141 printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id;
143 ' < $cprof |
sort -n -k2 > $cprof.new
150 . lib
/sde-config
/functions.
in
151 arch
=`uname -m | uname2arch`
152 current
= ; export SDECFG_ARCH
="$arch" ; export SDECFG_EXPERT
=0
153 menu_this
=0 ; menu_current
=0 ; menu_counter
=0
154 menu_stack
=x
; menu_back
=-1 ; menu_backpos
=-1
157 mkdir
-p $cfgtmpdir/config
158 touch $cfgtmpdir/config
/{config
,packages
}
161 configtitle
="$(printf ' %-50s %6s active packages ]' \
162 "The OpenSDE
($sdever) Configuration
- $config" \
163 "[ $
(echo `grep '^X' $cfgtmpdir/config/packages | wc -l`)" )"
167 .
$cfgtmpdir/config
/config
170 rm -f $cfgtmpdir/config.
{dialog
,data
,help}
171 touch $cfgtmpdir/config.
{dialog
,data
,help}
172 echo -e "#\n# OpenSDE ($sdever) Config File\n#" > $cfgtmpdir/config
/config
173 spacer
= ; expert
=0 ; tabspace
="5" ; tabspace_list
=
174 commentnr
=0 ; editfilenr
=0
176 bprof mkpkglist start
177 cmd
="./bin/sde-list package --arch '$SDECFG_ARCH'"
179 if [ "$cmd" != "`cat $cfgtmpdir/config.pcache.cmd 2> /dev/null`" ] ; then
180 eval "$cmd" |
tee $cfgtmpdir/config.pcache.data
> $cfgtmpdir/config
/packages
181 echo "$cmd" > $cfgtmpdir/config.pcache.cmd
183 cat $cfgtmpdir/config.pcache.data
> $cfgtmpdir/config
/packages
187 # Create lists of .in files
190 export SDECFG_ID
="$sdever"; pkgin
; . lib
/sde-config
/main.
in; pkgout
191 echo "export SDECFG_ID='$SDECFG_ID'" >> $cfgtmpdir/config
/config
192 rm -f $cfgtmpdir/*.tmp
194 cut
-f1,2,4,5,8- -d' ' $cfgtmpdir/config
/packages |
sed 's, [^ ]*$,,' | \
195 tr ' ' '\t' |
expand -t2,15,35, > $cfgtmpdir/packages.txt
197 configtitle
="$(printf ' %-50s %6s active packages ]' \
198 "The OpenSDE
($sdever) Configuration
- $config" \
199 "[ $
(echo `grep '^X' $cfgtmpdir/config/packages | wc -l`)" )"
203 if [ -z "$oldconfig" ] ; then
204 eval "./tmp/confdialog.bin --title 'Build Config' \
205 --backtitle '$configtitle' \
206 --menu 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
207 $(( $lines - 4 )) $(( $columns - 5 )) $(( $lines - 12 )) \
208 '$current' `tr '\n' ' ' < $cfgtmpdir/config.dialog`" 2> $cfgtmpdir/config.out
209 returncode
=$?
; item
="`cat $cfgtmpdir/config.out`"
216 [ "$returncode" = 1 -a "$menu_back" -ne -1 ] && returncode
="menu-back"
218 case "$returncode" in
220 command="`grep "^
$item " $cfgtmpdir/config.data | cut -f2-`"
221 { echo -e "\n# Remember menu position:\ncurrent='$item'"
222 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
223 echo -e "\n# Execute this config command:\n$command"
224 } >> $cfgtmpdir/config
/config
227 { echo -e "\n# New menu position:\ncurrent='$menu_backpos'"
228 echo -e "\n# New sub-menu:\nmenu_current='$menu_back'"
229 } >> $cfgtmpdir/config
/config
232 mkdir
-p config
/$config
234 for x
in config
/$config/*; do
235 if [ ! -e "$cfgtmpdir/config/${x##*/}" ]; then
239 cp -a $cfgtmpdir/config
/* config
/$config/
241 echo "New config written to config/$config/*."
242 echo "Cleaning up. Configuration finished."
248 item
=$
(echo $item | cut
-f1 -d' ') # dialog(1) bug?
249 { echo -e "\n# Remember menu position:\ncurrent='$item'"
250 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
251 } >> $cfgtmpdir/config
/config
253 get_help
$item > $cfgtmpdir/config.dialog
256 .
/tmp
/confdialog.bin
--title 'The OpenSDE Config - Help' \
257 --backtitle "The OpenSDE ($sdever) Configuration" \
258 --textbox $cfgtmpdir/config.dialog \
259 $
(( $lines - 4 )) $
(( $columns - 5 ))
263 echo "unknown returncode: $returncode"