هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
dnf install -y createrepo_c
mkdir -p /srv/repo/internal
cp ~/rpmbuild/RPMS/x86_64/*.rpm /srv/repo/internal/
createrepo_c /srv/repo/internal[internal]
name=Internal packages
baseurl=http://repo.example.com/internal
enabled=1
gpgcheck=1
gpgkey=http://repo.example.com/RPM-GPG-KEY-internalStep by step
- Collect the packages — your own RPMs, or downloaded ones with all dependencies:
dnf download --resolve --alldeps --destdir /srv/repo/internal nginx- Create the metadata (quick answer) —
createrepo_cwrites therepodata/folder. After adding or removing packages runcreaterepo_c --update /srv/repo/internal. - Serve it — any web server: point an Nginx
root(or ApacheDocumentRoot) at/srv/repowith directory listing off. For the same server only,baseurl=file:///srv/repo/internalworks too. - Client repo file (quick answer, second block) — then
dnf clean metadata && dnf repolistshows the repo. - Sign your packages —
gpgcheck=1makes dnf refuse unsigned or changed packages. Sign withrpm --addsign(rpm-sign, a GPG key) and publish the public key. Do not setgpgcheck=0"to make it work". - A mirror of official repositories (offline sites) —
dnf reposync --repoid=baseos --download-metadata -p /srv/repo/copies a whole repo; refresh it on a schedule. For large setups use Red Hat Satellite, Pulp or Foreman. - Debian/Ubuntu — the same idea with
aptlyorreprepro(signedReleasefiles).
Check that it worked
On a client, dnf repolist lists internal; dnf --disablerepo='*' --enablerepo=internal list available shows your packages; dnf install mytool works and verifies the signature.
Common problems
| Problem | Cause | Fix |
|---|---|---|
Cannot download repomd.xml | Wrong baseurl, web server, or firewall. | curl http://repo.example.com/internal/repodata/repomd.xml. |
| New package not found | Metadata not updated, or client cache old. | createrepo_c --update; dnf clean metadata on the client. |
GPG check FAILED / not signed | Package not signed or key not imported. | Sign with rpm --addsign; correct gpgkey URL. |
| Missing dependencies on install | Only the package was copied. | dnf download --resolve --alldeps. |
Permission denied / 403 from the web server | File rights or SELinux context. | Readable files; restorecon -Rv /srv/repo with a web content context. |
| Mirror fills the disk | Old versions kept forever. | reposync --delete --newest-only, or a retention plan. |
Go further
- Command pages: createrepo, dnf, rpm.
- Next how-tos: Find which package owns a file, Patch a server with security updates, Register a RHEL server and enable repositories, Host two websites on one server.
- Learn it: RHCSA — Your own repository, RHCSA — .repo files, RHCSA — Repository security.
1What does createrepo_c create?
The repodata/ folder with the metadata that dnf reads to know which packages the repository has.
2Why keep gpgcheck=1 for an internal repository?
dnf then refuses packages that are unsigned or were changed, so nobody can slip in a modified package.