Build a local Yum or DNF repository on Fedora
A local package repository gives Fedora administrators a controlled source for RPMs, internal tools and dependencies for isolated or constrained networks. Setting up a local Yum or DNF repository on Fedora involves serving RPM files with valid metadata and pointing clients at a trusted URL.
It supports repeatable builds, approved software and faster recovery images while reducing repeated downloads during busy release periods. Locally mirrored third-party packages should remain in a clearly labelled repository rather than being blended with official Fedora content.
Current Fedora uses DNF, while “Yum repository” remains familiar terminology and client files still live under /etc/yum.repos.d. Separating package acquisition, signing, metadata, publication and client trust makes later releases auditable and far less disruptive.
Prepare the repository host
Use a Fedora Server or minimal Fedora host with a stable DNS name and administrative SSH access. Install the tools used for package downloads, metadata, web serving and synchronisation.
sudo dnf install -y nginx createrepo_c dnf-plugins-core rsync
Keep content under the packaged Nginx document root, normally /usr/share/nginx/html on Fedora. Create a versioned directory with a current symlink:
sudo install -d -m 0755 /usr/share/nginx/html/local-fedora/releases/release-1/packages
sudo ln -sfnT releases/release-1 /usr/share/nginx/html/local-fedora/current
Start Nginx after installation. If firewalld is active, permit HTTP during setup, or configure TLS before distributing packages.
sudo systemctl enable --now nginx
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
Stage RPMs and dependencies
While the host or a staging machine has internet access, download an approved package and its dependencies into a staging directory:
sudo dnf download --resolve --alldeps --destdir /var/tmp/repo-stage example-app
Replace example-app with a package available from the configured upstream repositories. Repeat the process for every required package. Locally built RPMs should enter a separate staging directory until their dependencies and signing keys are verified.
Use explicit modes such as 0755 for directories and 0644 for public RPMs, and keep private keys outside the web root. The interaction between modes and masks is covered in file permissions and umask.
Generate and publish repository metadata
Create a dedicated repository signing key, export only its public half to /usr/share/nginx/html/local-fedora/RPM-GPG-KEY-local, and sign each RPM. With the key available to the command account, generate and sign the metadata:
sudo rsync -a /var/tmp/repo-stage/ /usr/share/nginx/html/local-fedora/current/packages/
sudo createrepo_c --sign --gpg-sign-key "YOUR_KEY_ID" /usr/share/nginx/html/local-fedora/current/packages/
Replace YOUR_KEY_ID with the real identifier. createrepo_c creates repodata/repomd.xml, which tells DNF what the repository contains and how to verify its metadata. Add --update when regenerating an existing release.
Restore SELinux labels through the packaged web hierarchy, then verify that Nginx exposes the metadata:
sudo restorecon -RFv /usr/share/nginx/html/local-fedora
curl -I http://repo.example.com.au/local-fedora/current/packages/repodata/repomd.xml
For each release, build a new directory, regenerate metadata, test it, then repoint current with ln -sfnT. A sync-health webhook can notify field staff; showing an alert dialog illustrates one Android presentation for that alert.
Configure DNF on client systems
Create a client definition under /etc/yum.repos.d. The hostname is illustrative and should resolve through local DNS:
sudo tee /etc/yum.repos.d/local-fedora.repo >/dev/null <<'EOF'
[local-fedora]
name=Internal Fedora packages
baseurl=http://repo.example.com.au/local-fedora/current/packages/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=http://repo.example.com.au/local-fedora/RPM-GPG-KEY-local
EOF
Package and metadata signatures should both be checked. Verify the public key fingerprint through a separate trusted channel before DNF imports it. For production, replace HTTP with an internally issued HTTPS certificate while retaining GPG verification; a file:// repository is also useful for a single workstation.
Refresh DNF and test the repository on a clean Fedora system:
sudo dnf clean all
sudo dnf makecache
sudo dnf repolist
sudo dnf --disablerepo='*' --enablerepo=local-fedora info example-app
sudo dnf --disablerepo='*' --enablerepo=local-fedora install example-app
Checks for dependable repository operations
A publication check should be repeatable on a clean Fedora virtual machine.
Before publication
repodata/repomd.xmlreturns HTTP 200 and carries a valid signature.- Every RPM passes
rpm -Kagainst the approved signing key. - A client installs a sample package with only the local repository enabled.
- SELinux labels, Nginx document root and firewall scope match the network design.
After rollout, keep routine maintenance small and observable.
During routine maintenance
- Create a versioned release directory before adding or replacing RPMs.
- Regenerate metadata and switch
currentonly after checks pass. - Monitor free space, HTTP errors, metadata age and failed synchronisation jobs.
- Retain previous releases, public keys and an auditable package manifest.
For high availability, the repository can sit behind a load balancer or bonded interfaces. The CentOS-specific network bonding for redundancy demonstrates the bonding concept, although Fedora deployments should use NetworkManager rather than copying CentOS network files.
A practical workflow for Australian teams
Australian schedules also matter: daylight-saving changes, state public holidays and closures in Sydney, Melbourne and Brisbane can shift unattended refresh windows. AARNet-connected campuses may have useful upstream capacity, but the local repository remains the predictable source.
Locally built packages used by Australian universities and engineering firms should use clear internal names, Australian English release notes and DD/MM/YYYY dates. For overseas RPM sources, retain invoices, licences and customs records alongside build provenance.
The dependable pattern is a versioned, signed release, verifiable metadata and a clean-client installation test. That chain turns a directory of RPMs into a repository an administrator can trust and reproduce.