Building a Repository With createrepo_c
Goal
You collect rpms, build a repository with createrepo_c, register it with a .repo file, and install from that repository alone. In the final step, you go through "I put it in but it doesn't show" with three different causes and tell them apart.
Why it matters
A repository is not a special server but just rpms + repodata/ (the table of contents), and the client does not look at the rpm directory directly but at the table of contents it downloaded into its own cache. So "I put it in the repository but it doesn't show" can break at any of three layers: the index (createrepo_c --update) was not rebuilt on the server, the client uses a stale cache (on air-gapped networks, metadata_expire=-1 does not refetch on its own), or an exclude rule in the repository definition hides it. The habit of checking the layers in order finishes most of those reports 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
- Create the
/root/repo/pooldirectory and download thetreepackage and its dependencies into that directory without installing. There must be at least one.rpm. - Build repository metadata in
/root/repo/pool.repodata/repomd.xmlmust appear. - Create
/etc/yum.repos.d/labhub-local.repo. The repository ID islabhub-local; put a snapshot date (the wordsnapshotandYYYY-MM-DD) in the name, point the address at/root/repo/poolwith the file scheme, keep it enabled, turn off signature checking, and set metadata expiry to "never expires (-1)". - Refresh the cache and save the repository list to
/root/repo/repolist.txt.labhub-localmust be visible. - With all other repositories turned off and only
labhub-localon, reinstalltree, and save that command's output to/root/repo/install.txt. - Download the
nanopackage into the pool as well, then incrementally update the metadata, and after updating, write the number of packages dnf sees inlabhub-localas a single numeric line in/root/repo/pkgcount.txt. - From
repomd.xml, pull out only the metadata type names and write them in/root/repo/mdtypes.txt, one per line. Nothing may be missing or added. - Incident: raise
incident rh-repo-invisible, work out per mirror why the new packages put into three mirrors are not visible, and fix them so they are visible. The report is/root/incident/rh-repo-invisible/report.txt.
Notes
- This lab is about 42 minutes. It fits within a 60-minute session, but if you spend a long time on the incident, extend it with
+시간(add time). The lab Pod has no volume, so your work disappears when the session ends. - To fetch an already installed package again from the same repository, use the
reinstallsubcommand, notinstall --reinstall; in this dnf (4.14), the former form dies withunrecognized arguments. - dnf does not refetch a repository with
metadata_expire=-1on its own. If you fixed the server, you must also expire or refetch the cache on the client side. - Incident tools:
incident listshows the incidents you can raise and a one-line symptom for each, andincident show <이름>(name) shows the ticket again. Raisingincident <이름>again returns it to its original broken state. - The incident report goes in
/root/incident/<이름>/report.txt(name is the incident name): one line<대상>: <원인 코드>(target: cause code) per target, plusevidence: <원인을 보여 준 출력 한 줄>(one line of output that showed the cause). Copy the evidence as is from output you actually saw. - Common mistake 1: not expiring the client cache after reindexing in step 6, so you see the old list.
- Common mistake 2: getting the number of slashes in
baseurlwrong in step 3. A local path isfile://followed by an absolute path, so there are three slashes.
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.
Direction: the material of a repository is a bundle of rpm files. There is a subcommand (a plugin) that fetches only the files without installing. Tools: that subcommand's options for the download location and for fetching dependencies too. Concretely: the dependency option fetches only "what this machine lacks"; the option that fetches even what is already installed is covered in the air-gap lab.
Generating metadata
Build repository metadata in /root/repo/pool. repodata/repomd.xml must appear under it.
Direction: dnf does not scan the rpm directory directly; it reads only the table of contents (repomd.xml) and the metadata bundles it points to (primary, filelists, other). Tool: the tool that scans a directory and makes those bundles; its name is in this lab's title. Concretely: give the tool a directory and repodata/ appears under it.
Writing the repository definition
Create /etc/yum.repos.d/labhub-local.repo. The repository ID is labhub-local; put a snapshot date (the word snapshot and YYYY-MM-DD) in the name, have the address point at /root/repo/pool with the file scheme, keep it enabled, turn off signature checking (only here, because it is an unsigned snapshot we just made), and set metadata expiry to "never expires (-1)". The key names and format are in the format example.
Direction: one .repo file is all there is to registering a repository, and it decides "what to trust" and "when to fetch again". Tools: key=value lines under a bracketed section (the repository ID). Concretely: a local path address has two slashes after the scheme plus the absolute path's slash, making three. An air-gapped snapshot does not change, so set expiry to infinite.
Refreshing the cache and checking
Refresh the cache and save the repository list to /root/repo/repolist.txt. labhub-local must be visible.
Direction: even if you make the table of contents on the server (directory) side, the client looks at the table of contents it downloaded into its own cache; once you register a new repository, you must have it rebuild the cache. Tools: the subcommand that clears or expires the cache, the subcommand that rebuilds the cache, and the repository list. Concretely: the grader checks not only the file but also whether labhub-local is visible when asked again now.
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.
Direction: to prove "it is fetched from the repository I made", no other repository may be able to get in. Tools: the pair of command-line options that turns off all repositories and turns on just one for this run only, and the subcommand that fetches an already installed package again. Concretely: labhub-local must be printed in the Repository column of the output for it to count as evidence. In this dnf, install --reinstall is an error, so use the fetch-again subcommand.
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 dnf sees in the labhub-local repository as a single numeric line in /root/repo/pkgcount.txt (the number you asked dnf, not the number of files).
Direction: just putting an rpm file into the directory never lets dnf notice it; you must update the table of contents and also expire the client cache (expiry is -1, so it does not refetch on its own). Tools: the metadata tool's incremental update option, the cache expiry subcommand, and a repository query targeting only one repository. Concretely: the grader compares the number you wrote with the number dnf sees in that repository now.
Checking the repomd.xml structure
From /root/repo/pool/repodata/repomd.xml, pull out only the metadata type names and write them in /root/repo/mdtypes.txt, one per line. Every type in the table of contents must be there, with nothing missing or added. Also check whether a security advisory (updateinfo) is among them.
Direction: repomd.xml is a table of contents. One kind of metadata is one data element, and the type name is in that element's attribute. Tool: a text tool that looks at XML line by line (extracting only attribute values). Concretely: the checksum element also has an attribute with the same name, so you must pick only the data element's. If there is no updateinfo, security update commands silently do nothing.
Incident: none of the new packages put into three mirrors are visible
Running incident rh-repo-invisible puts one new package each (acme-app-ng, acme-tools-ng, acme-libs-ng) into three in-house mirrors (mirror-app, mirror-tools, mirror-libs), but this server's dnf finds none of them (read the ticket first). Classify each mirror as one of excluded (an exclude rule in the repository definition hides it), not-reindexed (only the file was put in and the index was not rebuilt), stale-cache (the server has the new index but this client uses a stale cache), wrong-arch (the architecture does not match), or wrong-baseurl (the repository address points to another directory), and fix them so the three packages are visible. End state: the existing packages remain visible, acme-libs-legacy stays hidden, and the three mirrors' metadata_expire=-1 (the air-gapped policy) stays as it is. In /root/incident/rh-repo-invisible/report.txt, write three lines <미러>: <코드> (mirror: code) and evidence: <관찰한 출력 한 줄> (one line of output you observed).
Direction: "I put it in but it doesn't show" breaks at one of three layers: the server directory's index (repodata), the client's metadata cache, or the repository definition (exclude, address). For each mirror, check separately "is it in the server's index?" and "is this client looking at that index?". Tools: the contents of the index's primary, the revision in repomd.xml, the per-repository detailed list (refresh time, expiry), a dump of the repository's actual configuration, and a temporary-cache query that does not touch this server's cache. Concretely: if you start by clearing the cache, the evidence that it was a stale cache disappears; look first, then fix. An exclude rule can be narrowed to target just one package.