The packages section of your kickstart file is marked by the tags "%packages" and "%end", so if 'egrep -m2 -n "%(packages|end)" /path/to/kickstart.ks' should return two line numbers (say 19 and 121), so if you sed -n '20,120p' /path/to/kickstart.ks|grep -ie "^[a-z0-9@-]" you'll have the groups (prefixed by the "at" sign), deinstallations (prefixed with a minus sign) and package names. Tying it together it could look something like:
Code:
# Path and name of kickstart file.
KS="/path/to/kickstart.ks"
# Determination of section start and end.
SECTION=($(egrep -m2 -n "%(packages|end)" ${KS}|awk -F':' '{print $1}'))
# Retrieve package list.
eval echo "sed -n '$[${SECTION[0]}+1],$[${SECTION[1]}-1]p' ${KS}"|sh|grep -ie "^[a-z0-9@-]" | while read LINE; do
# What to do if LINE does not match expectation.
ARRAY=(${LINE}); [ ${#ARRAY[@]} -eq 1 ] || { echo "Line \"${LINE}\" contains ${#ARRAY[@]} items, skipping."; break; }
# LINE now should contain single item of groupname or packagename.
case "${LINE}" in
@*) # For groups check name.
GROUP=$(grep -m1 -i "${LINE:1:255}" /usr/share/doc/rpm-*/GROUPS||echo "${LINE:1:255}")
echo rpm -i -g \"${GROUP}\"
;;
-*) # For ausradierung we dont check anything!
echo rpm -e "${LINE}"
;;
*) # Just install.
echo rpm -i "${LINE}"
;;
esac
done
...which would only echo commands. Once you have determined it would be OK to run (I'm not sure about the group names, haven't checked with F10/F11) change "echo rpm" to "rpm" or "yum -y" (I wonder if that should be 'yum groupinstall' for groups?).
As always YMMV(VM).