How to create custom package groups from a custom yum repository?

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux 5 and later
  • Installation of packages from a custom yum repository

Issue

  • How to define a package group and add individual packages to it?
  • One use case is to create rpm groups for third party packages to ease installation and generate cleaner kickstart files.

Resolution

Note: Creating custom yum repository groups is outside the scope of support and support regarding this information may be limited. This article is provided as a courtesy to our customers.

  • The group data is stored in a file called "comps.xml"  under the repodata folder.

  • First create the custom repository :

1. Create the RPM repository, and copy all the RPMs you want to use into that directory:

# mkdir -p /usr/share/repository
# cp *.rpm  /usr/share/repository

2. Run createrepo command to create the repodata folder :

# cd /usr/share/repository
# createrepo .

Note: The createrepo package needs to be installed on the system

  • Now to create the Groups file :

3. Create the following comps.xml file under repodata folder :

<comps>
<!--  <meta> -->
<!-- Meta information will go here eventually -->
<!--  </meta> -->
  <group>
    <id>mygroup</id>
    <name>MyGroup</name>
    <default>true</default>
    <description>Description of group goes here</description>
    <uservisible>true</uservisible>
    <packagelist>
      <packagereq type="mandatory">package1</packagereq>
      <packagereq type="default">package2</packagereq>
      <packagereq type="optional">pacakge3</packagereq>
    </packagelist>
  </group>
</comps>

Each group has an id, user visibility value, name, description, and package list. In the package list, there are three types package:

  • mandatory: the packages marked as mandatory are always installed if the group is selected.
  • default: the packages marked default are selected by default if the group is selected.
  • optional: the packages marked optional must be specifically selected even if the group is selected.

4. Rerun createrepo so that group assignments are taken into account :

# createrepo -g repodata/comps.xml .

5.  Create the file /etc/yum.repos.d/file.repo as follows:

# cat /etc/yum.repos.d/file.repo
[myrepo]
name=My Repo
baseurl=file:///usr/share/repository
enabled=1

6. To test :

#yum clean all
# yum --noplugins groupinfo mygroup
  • Component
  • yum

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments