TT Lab
Get started
Learn Learning paths Courses

RHEL-Family Administration

Building a Repository With createrepo_c

Continue in TT Lab

Goal

You collect rpms, build a repository with createrepo_c, register it with a .repo file, and install from that repository alone.

Why it matters

The number one cause of the most frequent report on air-gapped networks, "I put it in the repository but it doesn't show", is forgetting createrepo_c --update. The files are visible but dnf does not know. The second is the client cache. If you get the order of these two into your hands, 90% of those reports end within minutes.

And if you know the structure of repomd.xml, you can judge what is and is not in the repository — for example, if there is no updateinfo, dnf update --security quietly does nothing.

Steps

  1. Create the /root/repo/pool directory and download the tree package and its dependencies into that directory without installing. There must be at least one .rpm.
  2. Build metadata in /root/repo/pool with createrepo_c. repodata/repomd.xml must appear.
  3. Create /etc/yum.repos.d/labhub-local.repo. The repository ID is labhub-local, the name must contain a snapshot date (the string snapshot and YYYY-MM-DD), and it must include baseurl=file:///root/repo/pool, enabled=1, gpgcheck=0, and metadata_expire=-1.
  4. Refresh the cache and save the repository list to /root/repo/repolist.txt. labhub-local must be visible.
  5. With all other repositories turned off and only labhub-local on, reinstall tree, and save that command's output to /root/repo/install.txt.
  6. Download the nano package into the pool as well, then incrementally update the metadata, and after updating, write the number of packages in the labhub-local repository as a single numeric line in /root/repo/pkgcount.txt.
  7. From repomd.xml, pull out only the metadata type names and write them in /root/repo/mdtypes.txt, one per line. primary, filelists, and other must all be present.
  8. Make /root/repo/report.txt with the following 4 lines. REPO_ID=labhub-local / PACKAGES=<6번 값> / MDTYPES=<7번 파일의 줄 수> / HAS_UPDATEINFO=<yes|no> (that is, the value from step 6, the number of lines in the step 7 file, and yes or no)

Notes

Collecting rpms

Create the /root/repo/pool directory and download the tree package and its dependencies into that directory without installing. There must be at least one .rpm.

dnf has a command that downloads only the rpm without installing. Also use the option that downloads the dependencies as well.

Generating metadata

Build metadata in /root/repo/pool with createrepo_c. repodata/repomd.xml must appear.

If you give createrepo_c a directory, it creates repodata under it.

Writing the repository definition

Create /etc/yum.repos.d/labhub-local.repo. The repository ID is labhub-local, the name must contain a snapshot date (the string snapshot and YYYY-MM-DD), and it must include baseurl=file:///root/repo/pool, enabled=1, gpgcheck=0, and metadata_expire=-1.

It is a .repo file under yum.repos.d. What is inside the square brackets is the repository ID, and name, baseurl, and enabled are required.

Refreshing the cache and checking

Refresh the cache and save the repository list to /root/repo/repolist.txt. labhub-local must be visible.

After marking the metadata cache as expired, look at the repository list. The new repository must be visible.

Installing from that repository alone

With all other repositories turned off and only labhub-local on, reinstall tree, and save that command's output to /root/repo/install.txt.

There is an option combination that turns off all repositories and turns on only one.

Updating after adding a package

Download the nano package into the pool as well, then incrementally update the metadata, and after updating, write the number of packages in the labhub-local repository as a single numeric line in /root/repo/pkgcount.txt.

dnf sees it only if you put in the rpm and reindex. There is an incremental update option.

Checking the repomd.xml structure

From repomd.xml, pull out only the metadata type names and write them in /root/repo/mdtypes.txt, one per line. primary, filelists, and other must all be present.

Each metadata type is shown with the type attribute. Pull out only the type names.

Repository report

Make /root/repo/report.txt with the following 4 lines. REPO_ID=labhub-local / PACKAGES=<6번 값> / MDTYPES=<7번 파일의 줄 수> / HAS_UPDATEINFO=<yes|no> (that is, the value from step 6, the number of lines in the step 7 file, and yes or no)

Gather the number of packages and the metadata types. The values must be actual check results.