Thought I'd send the final results of what I got working to the list.

Interestingly I ran into a problem where trying to use <compositemapper 
refid="..."/> would throw an error about that task not supporting the refid 
attribute. I eventually hit on the solution that I could use the generic mapper 
task with the refid even though according to the documentation "The composite 
mapper has no corresponding <mapper type> attribute.". 

It does seem less than intuitive that when you use the augment task to modify a 
composite mapper, that you need to use the <mapper> attribute to refid it.

Any way here's what I came up with in the end, thanks for the suggestions.

    <!-- determine the rpm architecture -->
    <exec executable="rpm" outputproperty="rpm.target" os="Linux">
      <arg value="--eval" />
      <arg value="%{_target_cpu}" />
    </exec>


    <!-- build rpms supplied as src -->
    <fileset dir="${src}" id="rpmstobuild" />
    <!-- perform some manipulations using ant-contrib -->
    <!-- generate the file list of packages to be rebuilt -->
    <antcontrib:for list="${packages.rpm.build}" param="rpmpkg">
      <sequential>
        <augment id="rpmstobuild">
          <include name="**/@{rpmpkg}*" />
        </augment>
      </sequential>
    </antcontrib:for>

    <compositemapper id="rpmstobuildmapper" />
    <!-- generate the mappers to identify the resulting packages -->
    <antcontrib:for list="${packages.rpm.build}" param="rpmpkg">
      <sequential>

        <!-- first, what's the name of the main package, direct translation to 
binary rpm or
             is it called something else -->
        <local name="default-pkg" />
        <antcontrib:if>
          <isset property="packages.r...@{rpmpkg}.default" />
          <antcontrib:then>
            <property name="default-pkg" 
value="${packages.r...@{rpmpkg}.default}" />
          </antcontrib:then>
          <antcontrib:else>
            <property name="default-pkg" value="@{rpmpkg}" />
          </antcontrib:else>
        </antcontrib:if>
        <augment id="rpmstobuildmapper">
          <regexpmapper from="(@{rpmpkg})(.*)\.src\.rpm" 
to="${rpm.target}/${default-pkg}\2.${rpm.target}.rpm" />
        </augment>

        <!-- next test if the extra packages property is set, in which case 
we'll need to loop over them to
              generate the necessary augments to suit -->
        <antcontrib:if>
          <isset property="packages.r...@{rpmpkg}.extra" />
          <antcontrib:then>
            <antcontrib:for list="${packages.r...@{rpmpkg}.extra}" 
param="extrarpmpkg">
              <sequential>
                <augment id="rpmstobuildmapper">
                  <regexpmapper from="(@{rpmpkg})(.*)\.src\.rpm" 
to="${rpm.target}/@{extrarpmpkg}\2.${rpm.target}.rpm" />
                </augment>
              </sequential>
            </antcontrib:for>
          </antcontrib:then>
        </antcontrib:if>

      </sequential>
    </antcontrib:for>

    <apply executable="/usr/bin/rpmbuild" os="Linux" dest="${rpm.rpmdir}">
      <arg value="--rebuild" />
      <arg value="--define" />
      <arg value="_topdir ${rpm.topdir}" />
      <fileset refid="rpmstobuild" />
      <mapper refid="rpmstobuildmapper" />
    </apply>

    <!-- copy rpms provided as binary -->
    <fileset dir="${src}" id="rpmstocopy" />
    <!-- perform some manipulations using ant-contrib -->
    <antcontrib:for list="${packages.rpm.copy}" param="rpmpkg">
      <sequential>
        <augment id="rpmstocopy">
          <include name="**/@{rpmpkg}*" />
        </augment>
      </sequential>
    </antcontrib:for>



--
Regards,
Darragh Bailey

Systems Software Engineer
Hewlett Packard Galway Ltd.

Postal Address:    Hewlett Packard Galway Limited, Ballybrit Business Park, 
Galway
Registered Office: Hewlett Packard Galway Limited, 63-74 Sir John Rogerson's 
Quay Dublin 2
Registered Number: 361933 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to