[CentOS] Kickstart package groups

Tue Oct 28 21:15:41 UTC 2008
Paul Heinlein <heinlein at madboa.com>

On Tue, 28 Oct 2008, Francisco Puente wrote:

> Hello,
> 
> I'm building another kickstart CD, minimal, and creating my own 
> repository.
> 
> Is there any way I can get the list of files that a group (like 
> @core o @base) will install?

Below my .sig is an XSLT stylesheet that will do the trick. Save it to 
your filesystem as, e.g., comps.xsl. Then use xsltproc to apply it to 
the comps.xml file, e.g.,

   xsltproc --novalid comps.xsl /path/to/repodata/comps.xml > comps.html

The resulting HTML file will provide you a reasonable list of packages 
associated with each group.

Warning: the list might not be complete because any given package in 
your named group(s) might might require packages not in those groups. 
That's why anaconda does dependency checking at installation time.

-- 
Paul Heinlein <> heinlein at madboa.com <> http://www.madboa.com/

----- comps.xsl -----

<?xml version='1.0'?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet version="1.0"
                    mlns="http://www.w3.org/1999/xhtml"
               xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="xml"
               indent="yes"
             encoding="iso-8859-1"
       doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
       doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

   <!-- the main event -->
   <xsl:template match="comps">
     <html lang="en-US">
       <head>
         <title>comps.xml</title>
         <xsl:call-template name="default.css"/>
       </head>
       <body>
     <xsl:call-template name="intro.text"/>
     <table width="95%">
       <tr>
         <th>Name</th>
         <th>Default</th>
         <th>Visible</th>
         <th>Description</th>
       </tr>
       <xsl:apply-templates select="group" mode="group.chart"/>
     </table>
     <p> </p>
     <table width="95%">
       <tr>
         <th>Name</th>
         <th>Groups Req.</th>
         <th>Packages Req.</th>
       </tr>
     <xsl:apply-templates select="group" mode="package.chart"/>
     </table>
       </body>
     </html>
   </xsl:template>


   <!-- for listing descriptions, whether group is default, ... -->
   <xsl:template match="group" mode="group.chart">
     <xsl:variable name="id" select="id"/>
     <tr>
       <td id="{$id}-info">
         <a href="#{$id}-detail"><xsl:value-of select="name"/></a>
       </td>
       <td><xsl:value-of select="default"/> </td>
       <td><xsl:value-of select="uservisible"/> </td>
       <td><xsl:value-of select="description"/> </td>
     </tr>
   </xsl:template>

   <!-- for listing groups and packages req. by this group -->
   <xsl:template match="group" mode="package.chart">
     <xsl:variable name="id" select="id"/>
     <tr>
       <td id="{$id}-detail">
         <a href="#{$id}-info"><xsl:value-of select="name"/></a>
       </td>
       <td><xsl:apply-templates select="grouplist"/></td>
       <td><xsl:apply-templates select="packagelist"/></td>
     </tr>
   </xsl:template>

   <!-- templates for grouplist and children -->
   <xsl:template match="grouplist">
     <table width="100%">
       <xsl:apply-templates select="*" mode="html.table"/>
     </table>
   </xsl:template>

   <xsl:template match="groupreq" mode="html.table">
     <tr>
       <xsl:call-template name="sub.table.row">
         <xsl:with-param name="leftcol" select="."/>
         <xsl:with-param name="rightcol" select="' '"/>
       </xsl:call-template>
     </tr>
   </xsl:template>

   <xsl:template match="metapkg" mode="html.table">
     <tr>
       <xsl:call-template name="sub.table.row">
         <xsl:with-param name="leftcol" select="."/>
         <xsl:with-param name="rightcol" select="@type"/>
       </xsl:call-template>
     </tr>
   </xsl:template>

   <!-- templates for packagelist and children -->
   <xsl:template match="packagelist">
     <table width="100%">
       <xsl:apply-templates select="*" mode="html.table"/>
     </table>
   </xsl:template>

   <xsl:template match="packagereq" mode="html.table">
     <tr>
       <xsl:call-template name="sub.table.row">
         <xsl:with-param name="leftcol" select="."/>
         <xsl:with-param name="rightcol" select="@type"/>
       </xsl:call-template>
     </tr>
   </xsl:template>


   <!-- named templates -->
   <xsl:template name="sub.table.row">
     <xsl:param name="leftcol"/>
     <xsl:param name="rightcol"/>
     <xsl:variable name="last">
       <xsl:choose>
         <xsl:when test="position() = last()">1</xsl:when>
         <xsl:otherwise>0</xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:choose>
       <xsl:when test="$last = '1'">
         <td style="border-style: none;"><xsl:value-of select="$leftcol"/></td>
         <td style="border-style: none; text-align: right;">
             <xsl:value-of select="$rightcol"/>
         </td>
       </xsl:when>
       <xsl:otherwise>
         <td><xsl:value-of select="$leftcol"/></td>
         <td style="text-align: right;"><xsl:value-of select="$rightcol"/></td>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>

   <xsl:template name="default.css">
     <xsl:variable name="color" select="'#990000'"/>
     <style type="text/css">
       a, a:link, a:active, a:visited {
         color: <xsl:value-of select="$color"/>;
         }
       body {
         font-size: small;
         background-color: white;
         color: black;
         width: 700px;
         }
       td {
         border-bottom: 1px solid #999;
         font-size: small;
         vertical-align: top;
         }
       th {
         color: white;
         background-color: <xsl:value-of select="$color"/>;
         font-weight: bold;
         text-align: left;
         padding-right: 15px;
         }
     </style>
   </xsl:template>

   <xsl:template name="intro.text">
     <p>
       Below is an outline of the package groups available at installation
       and, later, via yum and other package-management tools. The top
       table contains descriptions of each group. To see a detailed view
       of the packages that get installed with each group, click on the
       group name.
     </p>
   </xsl:template>

</xsl:stylesheet>

----- end comps.xsl -----