متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 223System · Packages

How to create a local package repository

Servers without internet access still need packages; an in-house tool should install with dnf install like any other package; and production should get only package versions you have tested. A local repository is a folder of RPM files plus metadata made by createrepo_c, served from a file path or a web server. This how-to builds one, uses it on clients, keeps it updated, and signs packages.

  • 5 الدروس
  • 7 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

223.1

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
/etc/yum.repos.d/internal.repo
[internal]
name=Internal packages
baseurl=http://repo.example.com/internal
enabled=1
gpgcheck=1
gpgkey=http://repo.example.com/RPM-GPG-KEY-internal

223.2

Step by step

  1. Collect the packages — your own RPMs, or downloaded ones with all dependencies:
dnf download --resolve --alldeps --destdir /srv/repo/internal nginx
  1. Create the metadata (quick answer) — createrepo_c writes the repodata/ folder. After adding or removing packages run createrepo_c --update /srv/repo/internal.
  2. Serve it — any web server: point an Nginx root (or Apache DocumentRoot) at /srv/repo with directory listing off. For the same server only, baseurl=file:///srv/repo/internal works too.
  3. Client repo file (quick answer, second block) — then dnf clean metadata && dnf repolist shows the repo.
  4. Sign your packages — gpgcheck=1 makes dnf refuse unsigned or changed packages. Sign with rpm --addsign (rpm-sign, a GPG key) and publish the public key. Do not set gpgcheck=0 "to make it work".
  5. 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.
  6. Debian/Ubuntu — the same idea with aptly or reprepro (signed Release files).

223.3

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.

الأوامر في هذا الدرس

223.4

Common problems

ProblemCauseFix
Cannot download repomd.xmlWrong baseurl, web server, or firewall.curl http://repo.example.com/internal/repodata/repomd.xml.
New package not foundMetadata not updated, or client cache old.createrepo_c --update; dnf clean metadata on the client.
GPG check FAILED / not signedPackage not signed or key not imported.Sign with rpm --addsign; correct gpgkey URL.
Missing dependencies on installOnly the package was copied.dnf download --resolve --alldeps.
Permission denied / 403 from the web serverFile rights or SELinux context.Readable files; restorecon -Rv /srv/repo with a web content context.
Mirror fills the diskOld versions kept forever.reposync --delete --newest-only, or a retention plan.

223.5

Go further

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.

كل الأوامر في هذا الفصل