3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Config
5 # Copyright (C) 2004 - 2024 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 if [ -z "${lines:=$LINES}" -o -z "${columns:=$COLUMNS}" ]; then
16 if [ "$(type -p stty)" ]; then
17 lines
="$( stty size 2> /dev/null | cut -d' ' -f1)"
18 columns
="$(stty size 2> /dev/null | cut -d' ' -f2)"
20 [ -z "$lines" -o "$lines" -le 0 ] 2> /dev
/null
&& lines
=24
21 [ -z "$columns" -o "$columns" -le 0 ] 2> /dev
/null
&& columns
=80
24 eval "$(egrep '^sdever=' scripts/parse-config)"
35 echo "Usage: $0 [ -delete | -oldconfig ] [ -cfg <config> ]"
38 echo " -profile create a config.profile with profiling data"
44 -cycle) do_config_cycle
=1; shift ;;
45 -delete) delete_mode
=1 ; shift ;;
46 -profile) profile
='-profile' ; shift ;;
47 -oldconfig) oldconfig
='-oldconfig' ; shift ;;
48 -cfg) config
="$2" ; shift; shift ;;
55 if [ -z "$config" ]; then
60 if [ ! -d config
/$config -a -e /etc
/SDE-CONFIG
/config
-a $config = default
]; then
61 echo "Using /etc/SDE-CONFIG/ as default config"
62 mkdir
-p config
/$config
63 cp -vf /etc
/SDE-CONFIG
/* config
/$config/
64 sed -i -E '/SDECFG_(CROSSBUILD|OPT|LTO|PARALLEL_MAX|PKGSEL_TMPL|SRC_TMPFS|C_FLAGS)/d' \
68 if [ ! -d config
/$config -a -n "$oldconfig" ]; then
69 echo "Error: -oldconfig is not supported for a new config"
74 if [ $delete_mode = 1 ]; then
81 if [ $do_config_cycle = 0 ]; then
82 echo "T2 $sdever configuration"
85 mkdir
-p config
/$config
86 touch config
/$config/{config
,packages
}
89 echo "Aquiring config lock ..."
91 exec 200>> config
/$config/lock.pid
93 echo $$
> config
/$config/lock.pid
96 mkdir
-p $cfgtmpdir # src
98 if [ -z "$oldconfig" -a ! -f src
/confdialog.bin
]; then
99 echo "Creating confdialog tool"
100 command="cc -O2 misc/confdialog/*.c `
101 `-Imisc/confdialog -lncurses -o src/confdialog.bin"
103 if ! eval "$command.$$"; then
104 echo "Compilation of the dialog tool failed, ncurses-devel missing?"
107 mv src
/confdialog.bin.$$ src
/confdialog.bin
110 # don't let Ctrl-C interrupt, because it destroys the configurations
113 while "$0" -cfg $config $oldconfig $profile -cycle; do :; done
117 rm config
/$config/lock.pid
121 if [ ! -f src
/bash
/luabash.??
* ]; then
122 echo "Building src/bash/luabash"
123 j
="$(nproc 2>/dev/null)"
124 make -j${j:-1} --no-print-directory -C misc
/luabash \
125 X_OUTARCH
=$PWD/src
${HOSTCC:+CC=$HOSTCC} ${HOSTCC:+LD=ld}
129 if [ ! -f src
/bash
/luabash.??
* ]; then
130 echo "Error building the Lua bash accelerator"
134 if ! enable -f $PWD/src
/bash
/luabash.??
* luabash
; then
135 echo "Error enabling the Lua bash accelerator: bash built with plugin support?"
139 luabash load
scripts
/config-functions.lua ||
exit 1
141 if [ -z "$profile" ]; then
145 if [ ! -f src
/bash_profiler.so
-o misc
/tools-source
/bash_profiler.c
-nt src
/bash_profiler.so
]; then
146 echo "Building src/bash_profiler.so"
147 cc
-O2 -shared -fPIC -Wall -o src
/bash_profiler.so misc
/tools-source
/bash_profiler.c ||
exit 1
149 enable -f src
/bash_profiler.so bprof ||
exit 1
151 local cprof
=$cfgtmpdir/config.profile
152 bprof all print
>> $cprof
154 $4 == "profiled" { next; }
155 $4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; }
156 { count[$4]+=$1; time[$4]+=$2; }
159 printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id;
161 ' < $cprof |
sort -n -k2 > $cprof.new
168 .
scripts
/config-functions.
in
169 arch
=`uname -m | uname2arch`
171 export SDECFG_ARCH
="$arch" SDECFG_KERNEL
="linux" SDECFG_EXPERT
=0
172 menu_this
=0 menu_current
=0 menu_counter
=0
173 menu_stack
=x menu_back
=-1 menu_backpos
=-1
175 configtitle
="$(printf ' %-50s %6s active packages ]' \
176 "T2
$sdever Configuration
- $config" \
177 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)")"
181 . config
/$config/config
184 rm -f $cfgtmpdir/config.
{dialog
,data
,help}
185 touch $cfgtmpdir/config.
{dialog
,data
,help}
186 echo -e "#\n# T2 $sdever Config File\n#" > config
/$config/config
187 spacer
="" expert
=0 tabspace
="5" tabspace_list
=""
188 commentnr
=0 editfilenr
=0
190 bprof mkpkglist start
191 cmd
="scripts/Create-PkgList $SDECFG_ARCH $SDECFG_KERNEL"
192 if [ "$cmd" != "`cat $cfgtmpdir/config.pcache.cmd 2> /dev/null`" ]; then
193 $cmd |
tee $cfgtmpdir/config.pcache.data
> config
/$config/packages
194 echo "$cmd" > $cfgtmpdir/config.pcache.cmd
196 cat $cfgtmpdir/config.pcache.data
> config
/$config/packages
200 # Create lists of .in files
203 export SDECFG_ID
="$sdever"; pkgin
; .
scripts
/config.
in; pkgout
204 echo "export SDECFG_ID='$SDECFG_ID'" >> config
/$config/config
205 rm -f $cfgtmpdir/*.tmp
207 cut
-f1,2,4,5,8- -d' ' config
/$config/packages |
sed 's, [^ ]*$,,' | \
208 tr ' ' '\t' |
expand -t2,15,35, > $cfgtmpdir/packages.txt
210 configtitle
="$(printf ' %-50s %6s active packages ]' \
211 "T2
$sdever Configuration
- $config" \
212 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)")"
216 if [ -z "$oldconfig" ]; then
217 eval "src/confdialog.bin --title 'Build Config' \
218 --backtitle '$configtitle' \
219 --menu 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
220 $(($lines - 4)) $(($columns - 5)) $(($lines - 12)) \
221 '$current' `tr '\n' ' ' < $cfgtmpdir/config.dialog`" 2> $cfgtmpdir/config.out
222 returncode
=$? item
="$(< $cfgtmpdir/config.out)"
229 [ "$returncode" = 1 -a "$menu_back" -ne -1 ] && returncode
="menu-back"
231 case "$returncode" in
233 command="`grep "^
$item " $cfgtmpdir/config.data | cut -f2-`"
234 { echo -e "\n# Remember menu position:\ncurrent='$item'"
235 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
236 echo -e "\n# Execute this config command:\n$command"
237 } >> config
/$config/config
240 { echo -e "\n# New menu position:\ncurrent='$menu_backpos'"
241 echo -e "\n# New sub-menu:\nmenu_current='$menu_back'"
242 } >> config
/$config/config
246 echo "New config written to: config/$config/"
252 item
=$
(echo $item | cut
-f1 -d' ') # dialog(1) bug?
253 { echo -e "\n# Remember menu position:\ncurrent='$item'"
254 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
255 } >> config
/$config/config
257 get_help
$item > $cfgtmpdir/config.dialog
260 src
/confdialog.bin
--title 'T2 Config - Help' \
261 --backtitle "T2 $sdever Configuration" \
262 --textbox $cfgtmpdir/config.dialog \
263 $
(($lines - 4)) $
(($columns - 5))
267 echo "unknown returncode: $returncode"