You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-2.2-install/data/calculate

140 lines
2.5 KiB

#!/sbin/runscript
depend() {
need localmount root fsck modules
before keymaps consolefont dbus
use swap hostname
}
xorg_video_driver()
{
local xorgFile="/etc/X11/xorg.conf"
if [[ -f $xorgFile ]]
then
cat /etc/X11/xorg.conf | grep Driver | cut -d\" -f2
fi
}
cmdline_video_driver()
{
local cmdline=`cat /proc/cmdline`
for x in $cmdline
do
case $x in
# parse cmdline param calculate
calculate\=*)
local value=`echo "$x" | cut -d\= -f2-`
# if calculate specified in new format
if [[ "$value" =~ : ]]
then
for i in ${value//,/ }
do
case ${i} in
video:*)
local value=`echo "$i" | cut -d: -f2-`
if [[ -n "$value" ]]
then
echo "$value"
return 0
fi
;;
esac
done
# if calculate specified in old format
else
local videodrv=`echo "$value" | cut -d, -f5`
if [[ -n $videodrv ]]
then
echo "$videodrv"
return 0
fi
fi
;;
esac
done
return 1
}
video_driver()
{
cmdline_video_driver || xorg_video_driver
}
check_install_ability()
{
local pkg=$1
FETCHCOMMAND=false DISTDIR=/usr/portage/distfiles emerge -fq $pkg &>/dev/null
}
is_already_install()
{
local pkg=$1
local category=`echo $pkg | cut -d\/ -f1`
local pkg=`echo $pkg | cut -d\/ -f2`
local categoryPath=/var/db/pkg/${category}
[[ -e $categoryPath ]] && ls $categoryPath | grep -q "^$pkg"
}
install_pkg()
{
local pkg=$1
ebegin "Installing $pkg"
FETCHCOMMAND=false DISTDIR=/usr/portage/distfiles emerge $pkg &>/dev/null
}
variable_value()
{
local varname=$1
cl-install -v --filter $varname |
awk "{ if (\$1 == \"$varname\") print \$3 }"
}
install_video_driver()
{
ebegin "Checking video drivers"
case `video_driver` in
fglrx)
local drv="x11-drivers/ati-drivers"
;;
nvidia)
local nvidiamask=`variable_value os_nvidia_mask`
[[ -n $nvidiamask ]] && \
echo $nvidiamask >/etc/portage/package.mask/nvidia
local drv="x11-drivers/nvidia-drivers"
;;
*)
true
;;
esac
if [[ -n $drv ]]
then
if ! is_already_install $drv
then
check_install_ability $drv && install_pkg $drv
fi
eend $?
else
eend 0
fi
}
start() {
install_video_driver
LANG=C /usr/bin/cl-install --live
/usr/sbin/env-update
source /etc/profile
/sbin/update-modules
/sbin/rc-update --update
return 0
}
stop() {
local roottype=`variable_value os_root_type`
if [[ $roottype == "hdd" ]] && rc-config list boot | grep -q calculate
then
rc-update del calculate boot
fi
}