6.4. The merging process of Rules and Classes

With classes and with rules, multiple XML files get merged to one resulting XML file. This process of merging is often confusing for people, because it behaves different than one would expect.

Let's take a look at two XML parts that we want to merge:

<partitioning config:type="list">
    <drive>
        <partitions config:type="list">
            <partition>
                <filesystem config:type="symbol">swap</filesystem>
                <format config:type="boolean">true</format>
                <mount>swap</mount>
                <partition_id config:type="integer">130</partition_id>
                <size>2000mb</size>
            </partition>
            <partition>
                <filesystem config:type="symbol">xfs</filesystem>
                <partition_type>primary</partition_type>
                <size>4Gb</size>
                <mount>/data</mount>
            </partition>
        </partitions>
    </drive>
</partitioning>
      

<partitioning config:type="list">
  <drive>
    <initialize config:type="boolean">false</initialize>
    <partitions config:type="list">
         <partition>
           <format config:type="boolean">true</format>
           <filesystem config:type="symbol">xfs</filesystem>
           <mount>/</mount>
           <partition_id config:type="integer">131</partition_id>
           <partition_type>primary</partition_type>
           <size>max</size>
         </partition>
    </partitions>
    <use>all</use>
  </drive>
</partitioning>
      

What you would expect is, that you'll end up in a profile with 3 partitions. That is not the case. You'll end up with two partitions and the first partition is a mixup of the swap and the root partition. Stuff that is configured in both partitions, like mount or size, will be used from the second file. Stuff that only exists in the first or second partition, will be copied to the merged partition too.

Sometimes this is what you want, but sometimes this is not what you want. Actually, in my example above, this is both. You don't want a second drive right? You want the two drives to be merged into one but for partitions you want three seperate ones. So how can you achieve what you want? In this example, how do you get three partitions but still one drive?

[Note]Note
For SLES9/SUSE Linux 10.0 and earlier versions

you can only use a trick. It's not official supported by autoyast and more a workaround than a nice solution. For each partition in one file, add an attribute to the partition like this:

<partition dontmerge="1">
...
</partitions>
      

The trick is, that the merge script will not detect the partitions as the same element type because of the new attribute. If you have more files, it might be needed to to add more attributes like dontmerge="2".

[Note]Note
For SLES10/SUSE Linux 10.1 and later

you can use the dont_merge element in the rules or classes file like this:

<classes config:type="list">
    <class>
        <class_name>swap</class_name>
        <configuration>largeswap.xml</configuration>
        <dont_merge config:type="list">
            <element>partition</element>
        </dont_merge>
    </class>
</classes>
      

<rule>
    <board_vendor>
        <match>ntel</match>
        <match_type>regex</match_type>
    </board_vendor>
    <result>
        <profile>classes/largeswap.xml</profile>
        <continue config:type="boolean">true</continue>
        <dont_merge config:type="list">
          <element>partition</element>
        </dont_merge>
    </result>
    <board_vendor>
        <match>PowerEdge [12]850</match>
        <match_type>regex</match_type>
    </board_vendor>
    <result>
        <profile>classes/smallswap.xml</profile>
        <continue config:type="boolean">true</continue>
        <dont_merge config:type="list">
          <element>partition</element>
        </dont_merge>
    </result>
</rule>