Dynamic package selection (prototype)
Thomas Neumann
blacky+fai at fluffbunny.de
Thu Jan 21 18:21:45 CET 2010
hiya
I experimented a bit and got the following to work. The reason why I was
experimenting was to be able to get rid of a lot of classes that are used
for just one very specific and limited "configuration issue". (Ultimately
I hope to be able to get rid of the and-patch for install-packages without
losing flexibility.)
1.) create a "dummy" package config
$ cd /srv/fai/config/package_config
$ ln -s /tmp/PKGS_dev PKGS_dev
2.) script the package selection mechanism
$ cd /srv/fai/config/class
$ cat 41-package-primer
-----------------------------------------
#!/bin/bash
# provide a facility to dynamically add packages during class/ execution
# [this script depends on 41-osdetect.source]
CLASSNAME="PKGS_dyn"
if ifclass OS_DEBIAN || ifclass OS_DEBIAN ; then
echo "PACKAGES aptitude" >> ${FAI}/package_config/PKGS_dyn
elif ifclass OS_SLES ; then
echo "PACKAGES yast" >> ${FAI}/package_config/PKGS_dyn
else
exit 2
fi
echo $CLASSNAME
-----------------------------------------
(OS_DEBIAN, OS_UBUNTU and OS_SLES are classes. These depend on a different
script which sets them.)
And now let's say I want to install the ssh-server packages for different
distributions:
$ cat 53-sshd
-----------------------------------------
[...]
# make sure the ssh server package is installed
if ifclass OS_DEBIAN || ifclass OS_UBUNTU ; then
PACKAGENAME="openssh-server"
elif ifclass OS_SLES ; then
PACKAGENAME="openssh"
else
PACKAGENAME="# unknown name for ssh-server package"
error=5
fi
echo "${PACKAGENAME}" >> ${FAI}/package_config/PKGS_dyn
-----------------------------------------
Of course this is a very limited example. More sophisticated ones are
possible - including fetching the list of additional packages from a
database or a cvs file. (Actually I already did fetch additional packages
for specific servers from a cvs file. The above process enabled me to
shift the installation of these additional packages from task_configure to
task_instsoft, thereby reducing the number of calls to yast. Which may not
seem important, but in effect shaved of 30s from the installation process.
Yast likes to process it's repository metadata information on each
execution.)
tschüß
thomas
More information about the linux-fai
mailing list