#!/bin/bash
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
|
|
#
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
# Please add additional copyright information _after_ the line containing
|
|
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
|
|
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
|
|
#
|
|
# ROCK Linux: rock-src/scripts/Config
|
|
# ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version. A copy of the GNU General Public
|
|
# License can be found at Documentation/COPYING.
|
|
#
|
|
# Many people helped and are helping developing ROCK Linux. Please
|
|
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
|
|
# file for details.
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-END ---
|
|
|
|
if [ -z "${lines:=$LINES}" -o -z "${columns:=$COLUMNS}" ] ; then
|
|
if [ "$( type -p stty )" ] ; then
|
|
lines="$( stty size 2> /dev/null | cut -d' ' -f1 )"
|
|
columns="$( stty size 2> /dev/null | cut -d' ' -f2 )"
|
|
fi
|
|
[ -z "$lines" -o "$lines" -le 0 ] 2> /dev/null && lines=24
|
|
[ -z "$columns" -o "$columns" -le 0 ] 2> /dev/null && columns=80
|
|
fi
|
|
|
|
eval "$(egrep '^rockver=' scripts/parse-config)"
|
|
|
|
config=default
|
|
do_config_cycle=0
|
|
delete_mode=0
|
|
oldconfig=''
|
|
nobashmod=''
|
|
profile=''
|
|
|
|
while [ "$1" ] ; do
|
|
case "$1" in
|
|
# -cycle) do_config_cycle=1 ; shift ;;
|
|
-delete) delete_mode=1 ; shift ;;
|
|
-profile) profile='-profile' ; shift ;;
|
|
-oldconfig) oldconfig='-oldconfig' ; shift ;;
|
|
-nobashmod) nobashmod='-nobashmod' ; shift ;;
|
|
-cfg) config="$2" ; shift ; shift ;;
|
|
|
|
*)
|
|
echo
|
|
echo "Usage: $0 [ -delete | -oldconfig ] [ -cfg <config> ]"
|
|
echo " Create and modify build configurations for the other"
|
|
echo " scripts, e.g. Download, Build-Target, and Emerge-Pkg."
|
|
echo
|
|
echo " -cfg <config> use <config> as the configuration name. If this option"
|
|
echo " is not set the name 'default' is used. If no"
|
|
echo " configuration by this name exists, one with default"
|
|
echo " settings is created."
|
|
echo " -delete delete the specified configuration"
|
|
echo " -oldconfig run without a menu-based interface; changes to settings"
|
|
echo " in configuration files have to be made manually before"
|
|
echo " ./scripts/Config recreates the whole configuration"
|
|
echo
|
|
echo "Other options:"
|
|
echo " -profile create a config.profile with profiling data"
|
|
echo " -nobashmod don't use the bash config helper plugin"
|
|
echo
|
|
exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
./scripts/Check-System || exit 1
|
|
|
|
if [ $delete_mode = 1 ] ; then
|
|
rm -rv config/$config
|
|
exit $?
|
|
fi
|
|
|
|
# hook for third-party targets that need to insert additional packages before config runs, for example.
|
|
# for precnf in target/*/preconfig.sh ; do
|
|
# [ -f $precnf ] && . $precnf
|
|
# done
|
|
|
|
swpid=swp$$
|
|
swpdir="config/$config.$swpid"
|
|
|
|
rm -f rockdialog.scrltmp # src/rockdialog.bin
|
|
mkdir -p src
|
|
|
|
if [ -z "$oldconfig" -a ! -f src/rockdialog.bin ] ; then
|
|
echo "Creating rockdialog tool."
|
|
command="gcc misc/rockdialog/*.c `
|
|
`-Imisc/rockdialog -lncurses -o src/rockdialog.bin"
|
|
eval "$command.$swpid"
|
|
mv src/rockdialog.bin{.$swpid,}
|
|
fi
|
|
|
|
if [ -z "$nobashmod" ]; then
|
|
if [ ! -f src/config_helper.so -o misc/tools-source/config_helper.c -nt src/config_helper.so ]; then
|
|
echo "Building src/config_helper.so."
|
|
gcc -shared -fPIC -Wall -o src/config_helper.so misc/tools-source/config_helper.c || exit 1
|
|
fi
|
|
enable -f src/config_helper.so cfghlp || exit 1
|
|
fi
|
|
|
|
if [ -z "$profile" ]; then
|
|
bprof() { :; }
|
|
bprof_print() { :; }
|
|
else
|
|
if [ ! -f src/bash_profiler.so -o misc/tools-source/bash_profiler.c -nt src/bash_profiler.so ]; then
|
|
echo "Building src/bash_profiler.so."
|
|
gcc -shared -fPIC -Wall -o src/bash_profiler.so misc/tools-source/bash_profiler.c || exit 1
|
|
fi
|
|
enable -f src/bash_profiler.so bprof || exit 1
|
|
bprof_print() {
|
|
bprof all print >> config.profile
|
|
awk '
|
|
$4 == "profiled" { next; }
|
|
$4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; }
|
|
{ count[$4]+=$1; time[$4]+=$2; }
|
|
END {
|
|
for (id in count)
|
|
printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id;
|
|
}
|
|
' < config.profile | sort -n -k2 > config.profile.new
|
|
mv config.profile{.new,}
|
|
}
|
|
fi
|
|
|
|
bprof main start
|
|
|
|
echo "Running ROCK Linux $rockver configuration ..."
|
|
if [ ! -e config/$config ] ; then
|
|
mkdir -p config/$config
|
|
echo "Creating new configuration $config ..."
|
|
$0 -oldconfig $profile $nobashmod -cfg $config
|
|
fi
|
|
|
|
# From scripts/parse-config
|
|
base=$(pwd -P)
|
|
|
|
. scripts/functions
|
|
. scripts/config.func
|
|
|
|
mkdir -p config/$config
|
|
touch config/$config/{config{,_usr},packages}
|
|
|
|
rm -rf $swpdir
|
|
cp -r config/$config $swpdir
|
|
|
|
current=""
|
|
menu_this=0 ; menu_current=0 ; menu_stack=x
|
|
|
|
include ()
|
|
{
|
|
local x
|
|
for x in $@ ; do
|
|
[ -f "$x" ] && . "./$x"
|
|
done
|
|
}
|
|
|
|
arch=none
|
|
if expr "`uname -m`" : "x86_64" > /dev/null ; then arch=x86 ; fi
|
|
if expr "`uname -m`" : "i.86" > /dev/null ; then arch=x86 ; fi
|
|
if expr "`uname -m`" : "alpha" > /dev/null ; then arch=alpha ; fi
|
|
if expr "`uname -m`" : "ppc" > /dev/null ; then arch=powerpc ; fi
|
|
if expr "`uname -m`" : "powerpc" > /dev/null ; then arch=powerpc ; fi
|
|
if expr "`uname -m`" : "sparc" > /dev/null ; then arch=sparc ; fi
|
|
if expr "`uname -m`" : "mips" > /dev/null ; then arch=mips ; fi
|
|
|
|
export ROCKCFG_EXPERT=0
|
|
|
|
. $swpdir/config
|
|
. $swpdir/config_usr
|
|
|
|
old_pkg_cmd=""
|
|
do_config_cycle=1
|
|
recreate_packages=1
|
|
while [ "$do_config_cycle" == 1 ] ; do
|
|
pkg_cmd="$ROCKCFG_ARCH"
|
|
[ "$ROCKCFG_DISABLE_BROKEN" = 1 ] && pkg_cmd="${pkg_cmd} -nobroken"
|
|
pkg_cache="$swpdir/config.pcache.${pkg_cmd// }"
|
|
|
|
if [ "$old_pkg_cmd" != "$pkg_cmd" ] ; then
|
|
recreate_packages=1
|
|
fi
|
|
if [ "$recreate_packages" == 1 ] ; then
|
|
recreate_packages=0
|
|
if [ -f "$pkg_cache" ] ; then
|
|
cp -a "$pkg_cache" "$swpdir/packages"
|
|
pkgin
|
|
else
|
|
eval "./scripts/Create-PkgList $pkg_cmd" \
|
|
> $swpdir/packages
|
|
cp -a "$swpdir/packages" "$pkg_cache"
|
|
fi
|
|
old_pkg_cmd="$pkg_cmd"
|
|
else
|
|
cp -a "$pkg_cache" "$swpdir/packages"
|
|
fi
|
|
|
|
pkgin
|
|
rm -f $swpdir/config.{dialog,data,help}{,.*}
|
|
|
|
config_cycle
|
|
|
|
bprof main stop
|
|
bprof rockconfig start
|
|
|
|
. scripts/config.in
|
|
|
|
bprof rockconfig stop
|
|
bprof main start
|
|
|
|
pkgout
|
|
configtitle="$(printf ' %-50s %6s active packages ]' \
|
|
"ROCK Linux $rockver Configuration - $config" \
|
|
"[ $(echo `grep '^X' $swpdir/packages | wc -l`)" )"
|
|
|
|
do_dialog_cycle=1
|
|
while [ "$do_dialog_cycle" = 1 ] ; do
|
|
if [ -z "$oldconfig" ] ; then
|
|
bprof main stop
|
|
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' ' ' \
|
|
< $swpdir/config.dialog.$menu_current`" \
|
|
2> $swpdir/config.out
|
|
returncode=$? ; item="`cat $swpdir/config.out`"
|
|
bprof rockdialog stop
|
|
bprof main start
|
|
else
|
|
returncode=1
|
|
fi
|
|
|
|
[ "$returncode" = 1 -a "$menu_current" -ne 0 ] && returncode="menu-back"
|
|
|
|
case "$returncode" in
|
|
0|6)
|
|
command="`grep "^$item " \
|
|
$swpdir/config.data.$menu_current | cut -f2-`"
|
|
if [[ "$command" != menu_current=* ]] ; then
|
|
[ -n "$command" ] && do_dialog_cycle=0
|
|
current="$item"
|
|
fi
|
|
eval "$command"
|
|
;;
|
|
menu-back)
|
|
command="`grep "^MENU_BACK " \
|
|
$swpdir/config.data.$menu_current | cut -f2-`"
|
|
eval "$command"
|
|
;;
|
|
1|255)
|
|
do_dialog_cycle=0
|
|
do_config_cycle=0
|
|
rm -f $swpdir/config.{data,dialog,out,help}{,.*}
|
|
rm -f $swpdir/config.pcache.*
|
|
rm -f rockdialog.scrltmp # src/rockdialog.bin
|
|
echo "New config written to config/$config/*."
|
|
echo "Cleaning up. Configuration finished."
|
|
;;
|
|
2)
|
|
item=$(echo $item | cut -f1 -d' ') # dialog(1) bug?
|
|
current="$item"
|
|
|
|
get_help $item > $swpdir/config.dialog
|
|
|
|
bprof main stop
|
|
./src/rockdialog.bin --title 'ROCK Linux Config - Help' \
|
|
--backtitle "ROCK Linux $rockver Configuration" \
|
|
--textbox $swpdir/config.dialog \
|
|
$(( $lines - 4 )) $(( $columns - 5 ))
|
|
bprof main start
|
|
;;
|
|
*)
|
|
do_dialog_cycle=0
|
|
do_config_cycle=0
|
|
echo "unknown returncode: $returncode"
|
|
;;
|
|
esac
|
|
done
|
|
bprof main stop
|
|
bprof_print
|
|
done
|
|
pkgout
|
|
|
|
rm -f $swpdir/*.tmp
|
|
|
|
echo -e "#\n# ROCK Linux $rockver Config File\n#\n" \
|
|
> $swpdir/config
|
|
echo -e "#\n# ROCK Linux $rockver User Config File\n#" \
|
|
> $swpdir/config_usr
|
|
|
|
for x in ${!ROCKCFG_*}; do
|
|
echo "export ${x}='${!x}'"
|
|
done >> $swpdir/config
|
|
for x in ${!ROCKCFGUSR_*}; do
|
|
echo "${x}='${!x}'"
|
|
done >> $swpdir/config_usr
|
|
|
|
sort -k1,1r -k3,3 $swpdir/packages > $swpdir/packages.sorted
|
|
mv -f $swpdir/packages{.sorted,}
|
|
|
|
for x in $( ls $swpdir/ ); do
|
|
cp $swpdir/{$x,__tmp}
|
|
mv $swpdir/__tmp config/$config/$x
|
|
done
|
|
for x in $( ls config/$config ); do
|
|
[ -e $swpdir/$x ] || rm -f config/$config/$x
|
|
done
|
|
rm -rf $swpdir
|