How to make autoyast script a bit more dynamic

SUSE Manager customers using autoyast are in the lucky position to set many variables and use them in autoyast xml file directly. e.g. hostip= can be referred in autoinst.xml as $hostip which is great. Admins could set the values in the autoinstallation profile in conjunction with the autoyast xml file referring to it.

But when it comes to be more flexible and say if filesystem type is xfs instead of brfs then the value should be replaced and the section of "<subvolumes config:type="list">" should be removed.

To accomplish a such "flexibility" there are several ways one can do. I tried the way with rules as stated in the official autoyast docu but ended up with prescript modifying /tmp/profile/autoinst.xml

But writing a prescript to modify the autoinst.xml into a modified.xml with lot of find, replace, insert lead me to use sed awk which can become quite complicate.

This code below is my learnings how to achieve some find, replace, remove, insert within the autoinst.xml.

Before continue reading below I assume that you are aware about what is autoinst.xml and modifying it during yast installation happens through pre-scripts which generate a new modified.xml which will be next re-read by the yast installer. pre-script-doc

<pre-scripts config:type="list">







cp /tmp/profile/autoinst.xml /tmp/profile/temp.xml

if [ $fst == "xfs" ]


sed -i '/[[:space:]]<partitioning config:type="list">$/,/[[:space:]]<\/partitioning>$/ s/[[:space:]]<filesystem config:type="symbol">btrfs<\/filesystem>$/<filesystem config:type="symbol">xfs<\/filesystem>/g' /tmp/profile/temp.xml

sed -i '/[[:space:]]<subvolumes config:type="list">$/,/[[:space:]]<\/subvolumes>$/{//!d}' /tmp/profile/temp.xml


if [ $dskt == "yes" ]


wget -O /tmp/profile/software.xml

if [ -f /tmp/profile/temp.xml ]


awk '/<\/patterns>/{while(getline line<"/tmp/profile/software.xml"){print line}} //' /tmp/profile/temp.xml>/tmp/profile/modified.xml


awk '/<\/patterns>/{while(getline line<"/tmp/profile/software.xml"){print line}} //' /tmp/profile/autoinst.xml>/tmp/profile/modified.xml


cp /tmp/profile/modified.xml /mnt/tmp/






Now, piece by piece explain it:

Diese Webseite verwendet Cookies. Durch die weitere Nutzung stimmen Sie der Verwendung von Cookies zu.