Skip to content

Fix RPM packaging for modern openSUSE Leap 16, Fedora, and RHEL/Rocky Linux - #749

Open
leotada wants to merge 2 commits into
dlang:masterfrom
leotada:fix-rpm-packaging-leap16-rhel-rocky
Open

leotada wants to merge 2 commits into
dlang:masterfrom
leotada:fix-rpm-packaging-leap16-rhel-rocky

Conversation

@leotada

@leotada leotada commented Oct 19, 2026

Copy link
Copy Markdown

Summary of Changes

This PR modernizes the RPM packaging in linux/dmd_rpm.sh to fix compatibility on openSUSE Leap 16, openSUSE Tumbleweed, Rocky Linux / RHEL, and Fedora:

  1. RPM Boolean Rich Dependencies (Requires:):

    • Replaced distro-specific names with explicit boolean dependencies: (libcurl($FARCH) or libcurl4($FARCH)) and (libgcc($FARCH) or libgcc_s1($FARCH)).
    • On openSUSE Leap 16+, libcurl4 is used (there is no libcurl or libcurl4-32bit). On Fedora/RHEL, libcurl is used. This allows the RPM packages to be cross-compatible across all RPM-based distros.
  2. 32-bit Multilib Isolation & Weak Dependencies (Recommends:):

    • Bundled 32-bit Phobos (/usr/lib/libphobos2.so*) previously caused RPM's find-requires to inject an automatic 32-bit Requires: libgcc_s.so.1 into the 64-bit package, which fails on standard 64-bit systems where 32-bit libgcc_s.so.1 is not installed by default. Added %global __requires_exclude_from ^/usr/lib/libphobos2\\.so.*$ on x86_64 to prevent this leak.
    • Converted 32-bit development dependencies (glibc-devel(x86-32) or glibc-devel-32bit, libgcc(x86-32) or libgcc_s1-32bit, libcurl(x86-32) or libcurl4-32bit) from hard Requires: to Recommends:. This prevents installation failures on 64-bit-only installations while still pulling in multilib packages when requested/available.
    • Fixed typo in openSUSE 32-bit dependencies: gcc-32bit($FARCH) evaluated to non-existent gcc-32bit(x86-64).
  3. Smooth openSUSE Upgrades (Provides: & Obsoletes:):

    • Added Provides and Obsoletes for phobos-devel, phobos-devel-static, and dub to prevent file conflicts when upgrading over openSUSE's distribution-split packages.
  4. Build System Compatibility:

    • Updated OS verification to recognize /etc/os-release so dmd_rpm.sh can be executed on any modern Linux distribution.
    • Made fakeroot optional if rpmbuild is already installed.
    • Defined _topdir and _tmppath to ensure clean builds in unprivileged or containerized build environments.

- Use explicit RPM boolean rich dependencies in Requires:
  (libcurl($FARCH) or libcurl4($FARCH)) and (libgcc($FARCH) or libgcc_s1($FARCH))
  so the Fedora and openSUSE RPMs are cross-compatible across Fedora,
  openSUSE Leap 15/16/Tumbleweed, and RHEL/Rocky Linux.
- Use cross-distro Recommends: for 32-bit multilib packages:
  (glibc-devel(x86-32) or glibc-devel-32bit), (libgcc(x86-32) or libgcc_s1-32bit),
  and (libcurl(x86-32) or libcurl4-32bit) so 64-bit-only systems are not blocked
  and fixed the invalid gcc-32bit($FARCH) typo.
- Exclude bundled 32-bit /usr/lib/libphobos2.so* from automatic requirement
  generation via __requires_exclude_from on x86_64 packages.
- Add Provides and Obsoletes for phobos-devel, phobos-devel-static, and dub
  to avoid file collisions when upgrading over split openSUSE packages.
- Allow dmd_rpm.sh to run on build environments with /etc/os-release and make
  fakeroot optional if rpmbuild is available.
@dejlek

dejlek commented Oct 20, 2026 •

Copy link
Copy Markdown

Tested on Fedora 44, Leap 16, Tumbleweed, Alma 8 and 9 with dmd 2.110.0. It works, with one bug.

The 32-bit require exclusion does the job. Without it the 32-bit libphobos pulls libgcc_s.so.1 and friends into the 64-bit package. Rich deps resolve on all of these distros. Leap 16 upgrades over the distro split stack cleanly. The fakeroot and _topdir/_tmppath changes work too.

The bug: Obsoletes: libphobos2-0_109 is hardcoded, but this script builds every release. A 2.110 build has soname .so.0.110, and Tumbleweed already ships libphobos2-0_113. Derive the name from SO_VERSION instead.

Smaller stuff:

  • Recommends are installed by default, so 32-bit multilib still gets pulled on Fedora/EL. Use Suggests for "only when requested".
  • The DUB_VER fallback writes the dmd version into dub's Provides/Obsoletes. That is the wrong version namespace.
  • Obsoletes: dub < $DUB_VER misses when the distro dub is newer, so /usr/bin/dub still conflicts.
  • /etc/os-release exists everywhere, so the new check passes everywhere. Drop it or check ID_LIKE.
  • Rich deps need rpm 4.13, so RHEL 7 cannot install this. Say RHEL 8+ in the readme.

- Derive PHOBOS_LIB_PKG dynamically from SO_VERSION (libphobos2-0_xxx)
- Use Suggests: instead of Recommends: for 32-bit multilib packages
- Avoid mixing version namespaces on dub fallback
- Inspect ID and ID_LIKE in /etc/os-release
- Specify RHEL/Rocky/CentOS 8+ in readme
@leotada

leotada commented Oct 21, 2026

Copy link
Copy Markdown
Author

Thanks a lot for the thorough review and testing across the 5 container distributions, @dejlek!

I have addressed all the points in the latest commit (5b0f0cc):

  1. Derived PHOBOS_LIB_PKG dynamically:
    • Now derived using PHOBOS_LIB_PKG="libphobos2-$(echo $SO_VERSION | tr . _)" with Obsoletes: $PHOBOS_LIB_PKG <= $VERSION-$REVISION so it properly tracks the soname for any DMD release.
  2. Switched to Suggests::
    • Converted 32-bit multilib development packages to Suggests: instead of Recommends: so that dnf / zypper do not pull 32-bit packages by default on 64-bit systems.
  3. DUB version fallback:
    • Removed the $VERSION fallback to avoid mixing DMD and DUB version namespaces. If usr/bin/dub version cannot be extracted dynamically, it now provides unversioned dub, dub($FARCH).
  4. OS check verification:
    • Updated the /etc/os-release check to inspect ID and ID_LIKE (debian|rhel|fedora|suse|centos|rocky|alma).
  5. README:
    • Updated the documentation to explicitly specify RHEL/Rocky/CentOS 8+ (due to RPM >= 4.13 requirement for boolean rich dependencies).

@dejlek

dejlek commented Oct 22, 2026 •

Copy link
Copy Markdown

Retested the new commit. The obsoletes name, Suggests, the os-release check and the readme are all good now.

Two things left. Obsoletes: dub <= $DUB_VER still misses a newer distro dub. On Tumbleweed the upgrade aborts on a /usr/bin/dub conflict when the distro dub is newer than the bundled one. An unversioned Obsoletes: dub is the only reliable fix. And the dub version goes into the metadata unchecked. When dub --version printed something unexpected I got dub = run-0 in Provides and Obsoletes. Validate the format and fall back when it does not match.

One behavior change worth knowing: the derived obsoletes name means a soname bump leaves the old libphobos2 package orphaned. Harmless, since the file names differ, but different from before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants