Skip to content

Conversation

@liunan-ms
Copy link
Contributor

This PR adds fix for making azurelinux-rpm-config flavored over redhat-rpm-config and managing symlinks for compatibility.

Spec file and compatibility improvements:

  • Added Name and Conflicts tags to the spec to clarify the package's identity and ensure it replaces conflicting Fedora packages.
  • Removed the global replacement of (fedora|redhat) -> azurelinux because it renames the directory path /usr/lib/rpm/redhat/ to /usr/lib/rpm/azurelinux/ inside azurelinux-rpm-config spec, but python3-rpm-macros hardcodes /usr/lib/rpm/redhat/... : Tree - rpms/python-rpm-macros - src.fedoraproject.org.
  • Added overlays to create symlinks for /usr/lib/rpm/azurelinux.
  • Added symlinks for /usr/bin/<arch>-azurelinux-linux-gnu-pkg-config to their redhat counterparts, ensuring compatibility without interfering with Fedora's package during bootstrapping.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses compatibility issues with the azurelinux-rpm-config package by changing the approach from globally renaming "redhat" to "azurelinux" to using symlinks for compatibility. The key insight is that python3-rpm-macros hardcodes /usr/lib/rpm/redhat/ paths, so renaming that directory would break compatibility.

Changes:

  • Removed global search-replace operations that renamed files and directory references from "redhat" to "azurelinux"
  • Added symlinks (/usr/lib/rpm/azurelinux -> /usr/lib/rpm/redhat and pkg-config wrappers) to maintain compatibility with both naming conventions
  • Added Name, Obsoletes, and Conflicts tags to properly identify the package and ensure it supersedes Fedora's redhat-rpm-config

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 9 to 51
{ type = "spec-set-tag", tag = "Name", value = "azurelinux-rpm-config" },
# Set this distro's URL.
{ type = "spec-set-tag", tag = "URL", value = "https://aka.ms/azurelinux" },
# Set our version.
{ type = "spec-update-tag", tag = "Version", value = "1004" },
# Provide compatibility with Fedora's upstream version.
{ type = "spec-add-tag", tag = "Provides", value = "redhat-rpm-config = %{version}-%{release}" },
# Make sure this package takes precedence over any Fedora variant.
# Make sure this package takes precedence over (and would replace) any Fedora variant.
# Note that Fedora's version of redhat-rpm-config has a version equal to 300 + the release number
# (e.g., 343 for Fedora 43).
{ type = "spec-add-tag", tag = "Obsoletes", value = "redhat-rpm-config < 1000" },
# Global search-and-replace in spec file: {fedora,redhat}->azurelinux
{ type = "spec-search-replace", regex = "(fedora|redhat)", replacement = "azurelinux" },
# Remove symlink; replace it with a dynamically constructed one in the spec.
# We need to change how we generate a symlink and the tag referencing the checked-in one.
{ type = "spec-search-replace", regex = '^.*:\s*azurelinux-annobin-cc1\s*$', replacement = "" },
{ type = "spec-append-lines", section = "%prep", lines = ["ln -sfr azurelinux-annobin-select-annobin-built-plugin azurelinux-annobin-cc1"] },
{ type = "spec-add-tag", tag = "Conflicts", value = "redhat-rpm-config < 1000" },

# Create symlink for our own name: /usr/lib/rpm/azurelinux -> /usr/lib/rpm/redhat
# Note that we don't do the reverse to avoid conflicts with upstream Fedora
# redhat-rpm-config during bootstrapping (replacing a dir with a symlink is
# problematic in RPM land).
{ type = "spec-prepend-lines", section = "%install", lines = ["mkdir -p %{buildroot}/usr/lib/rpm", "ln -sf redhat %{buildroot}/usr/lib/rpm/azurelinux"] },
{ type = "spec-prepend-lines", section = "%files", lines = ["/usr/lib/rpm/azurelinux"] },

#Create a symlink pkg-config: /usr/bin/<arch>-azurelinux-linux-gnu-pkg-config -> /usr/bin/<arch>-redhat-linux-gnu-pkg-config.
{ type = "spec-prepend-lines", section = "%install", lines = ["mkdir -p %{buildroot}/usr/bin", "for arch in x86_64 aarch64; do", " ln -sf ${arch}-redhat-linux-gnu-pkg-config %{buildroot}/usr/bin/${arch}-azurelinux-linux-gnu-pkg-config", "done"] },
{ type = "spec-prepend-lines", section = "%files", lines = ["/usr/bin/*-azurelinux-linux-gnu-pkg-config"] },

#
# Overlays for non-spec files.
#

# Remove the symlink that we can't easily fix up (the spec changes above avoid using it).
{ type = "file-remove", file = "redhat-annobin-cc1" },

# Apply file renames *first*: fedora/redhat -> azurelinux
{ type = "file-rename", file = "macros.fedora-misc-srpm", replacement = "macros.azurelinux-misc-srpm" },
{ type = "file-rename", file = "macros.fedora-misc", replacement = "macros.azurelinux-misc" },
{ type = "file-rename", file = "redhat-annobin-plugin-select.sh", replacement = "azurelinux-annobin-plugin-select.sh" },
{ type = "file-rename", file = "redhat-annobin-select-annobin-built-plugin", replacement = "azurelinux-annobin-select-annobin-built-plugin" },
{ type = "file-rename", file = "redhat-annobin-select-gcc-built-plugin", replacement = "azurelinux-annobin-select-gcc-built-plugin" },
{ type = "file-rename", file = "redhat-hardened-cc1", replacement = "azurelinux-hardened-cc1" },
{ type = "file-rename", file = "redhat-hardened-clang-ld.cfg", replacement = "azurelinux-hardened-clang-ld.cfg" },
{ type = "file-rename", file = "redhat-hardened-clang.cfg", replacement = "azurelinux-hardened-clang.cfg" },
{ type = "file-rename", file = "redhat-hardened-ld-errors", replacement = "azurelinux-hardened-ld-errors" },
{ type = "file-rename", file = "redhat-hardened-ld", replacement = "azurelinux-hardened-ld" },
{ type = "file-rename", file = "STAGE2-redhat-rpm-config", replacement = "STAGE2-azurelinux-rpm-config" },

# Update all references to the Fedora version of this package to the Azure Linux one.
{ type = "file-search-replace", file = "**/*", regex = "redhat-rpm-config", replacement = "azurelinux-rpm-config" },
# Update all references to the vendor-specific dir under /usr/lib/rpm.
{ type = "file-search-replace", file = "**/*", regex = "/usr/lib/rpm/redhat", replacement = "/usr/lib/rpm/azurelinux" },

# Update vendor macro + textual references in macros files.
# Update vendor macro.
{ type = "file-search-replace", file = "macros", regex = "%_vendor.*", replacement = "%_vendor azurelinux" },
{ type = "file-search-replace", file = "macros", regex = "redhat", replacement = "azurelinux" },

# Remove dist.sh file; we'll replace it wholesale with our own version.
{ type = "file-remove", file = "dist.sh" },
# Add our own version of dist.sh customized for Azure Linux.
{ type = "file-add", file = "dist.sh", source = "dist.sh" },

# Additional replacements of the distro name in macros files.
{ type = "file-search-replace", file = "rpmrc", regex = "fedora", replacement = "azurelinux" },
{ type = "file-search-replace", file = "macros.azurelinux-misc", regex = "fedora", replacement = "azurelinux" },
{ type = "file-search-replace", file = "macros.azurelinux-misc-srpm", regex = "/lib/swidtag/fedoraproject.org", replacement = "/lib/swidtag/microsoft.com" },
{ type = "file-search-replace", file = "macros.azurelinux-misc-srpm", regex = "[Ff]edora", replacement = "azurelinux" },
# Update annobin references.
{ type = "file-search-replace", file = "azurelinux-annobin-plugin-select.sh", regex = "redhat-annobin", replacement = "azurelinux-annobin" },
{ type = "file-search-replace", file = "buildflags.md", regex = "redhat-annobin", replacement = "azurelinux-annobin" },
# Update redhat-hardened references.
{ type = "file-search-replace", file = "STAGE2-azurelinux-rpm-config", regex = "redhat-hardened", replacement = "azurelinux-hardened" },
{ type = "file-search-replace", file = "buildflags.md", regex = "redhat-hardened", replacement = "azurelinux-hardened" },
# Targeted adjustments in some macros files.
{ type = "file-search-replace", file = "macros.fedora-misc-srpm", regex = "/lib/swidtag/fedoraproject.org", replacement = "/lib/swidtag/microsoft.com" },
{ type = "file-search-replace", file = "macros.fedora-misc-srpm", regex = "[Ff]edora", replacement = "azurelinux" },
]
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All overlays in this file are missing the required description field. According to the repository hygiene rules (see .github/copilot-instructions.md:55), every overlay MUST include a description field explaining why the change is needed. Each overlay should be converted from inline array syntax to the table-of-arrays syntax (using [[components.azurelinux-rpm-config.overlays]]) with a description field added to each one.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reubeno @dmcilvaney is this really needed, what copilot is asking for? ^

Comment on lines 29 to 31
#Create a symlink pkg-config: /usr/bin/<arch>-azurelinux-linux-gnu-pkg-config -> /usr/bin/<arch>-redhat-linux-gnu-pkg-config.
{ type = "spec-prepend-lines", section = "%install", lines = ["mkdir -p %{buildroot}/usr/bin", "for arch in x86_64 aarch64; do", " ln -sf ${arch}-redhat-linux-gnu-pkg-config %{buildroot}/usr/bin/${arch}-azurelinux-linux-gnu-pkg-config", "done"] },
{ type = "spec-prepend-lines", section = "%files", lines = ["/usr/bin/*-azurelinux-linux-gnu-pkg-config"] },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddstreet Here is what I'm not sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this pkg isn't what provides the *-redhat-linux-gnu-pkg-config files, sure. I think all the bootstrapping workarounds should be confined to a single package, and if we're doing it here for the /usr/lib/rpm/redhat symlink i think we should add all the workarounds in this package. i hope that after bootstrapping, we can remove most/all of the workarounds, so if they are all in this package it'll make removing them later much easier. so this looks fine to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these overlays, then, need to be removed after we bootstrap. we need to very clearly annotate those -- i.e., with TODOs or similar.

Copy link
Contributor

@ddstreetmicrosoft ddstreetmicrosoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this LGTM with the caveat that i'd like to see all or most of the workarounds removed after we finish bootstrapping our own full repo of packages.

also, copilot is complaining about needing description for all the overlays, which i'm not sure if we need or not, but i'll mark this review as 'request changes' until we can get an answer to that

Comment on lines 29 to 31
#Create a symlink pkg-config: /usr/bin/<arch>-azurelinux-linux-gnu-pkg-config -> /usr/bin/<arch>-redhat-linux-gnu-pkg-config.
{ type = "spec-prepend-lines", section = "%install", lines = ["mkdir -p %{buildroot}/usr/bin", "for arch in x86_64 aarch64; do", " ln -sf ${arch}-redhat-linux-gnu-pkg-config %{buildroot}/usr/bin/${arch}-azurelinux-linux-gnu-pkg-config", "done"] },
{ type = "spec-prepend-lines", section = "%files", lines = ["/usr/bin/*-azurelinux-linux-gnu-pkg-config"] },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this pkg isn't what provides the *-redhat-linux-gnu-pkg-config files, sure. I think all the bootstrapping workarounds should be confined to a single package, and if we're doing it here for the /usr/lib/rpm/redhat symlink i think we should add all the workarounds in this package. i hope that after bootstrapping, we can remove most/all of the workarounds, so if they are all in this package it'll make removing them later much easier. so this looks fine to me.

Comment on lines 9 to 51
{ type = "spec-set-tag", tag = "Name", value = "azurelinux-rpm-config" },
# Set this distro's URL.
{ type = "spec-set-tag", tag = "URL", value = "https://aka.ms/azurelinux" },
# Set our version.
{ type = "spec-update-tag", tag = "Version", value = "1004" },
# Provide compatibility with Fedora's upstream version.
{ type = "spec-add-tag", tag = "Provides", value = "redhat-rpm-config = %{version}-%{release}" },
# Make sure this package takes precedence over any Fedora variant.
# Make sure this package takes precedence over (and would replace) any Fedora variant.
# Note that Fedora's version of redhat-rpm-config has a version equal to 300 + the release number
# (e.g., 343 for Fedora 43).
{ type = "spec-add-tag", tag = "Obsoletes", value = "redhat-rpm-config < 1000" },
# Global search-and-replace in spec file: {fedora,redhat}->azurelinux
{ type = "spec-search-replace", regex = "(fedora|redhat)", replacement = "azurelinux" },
# Remove symlink; replace it with a dynamically constructed one in the spec.
# We need to change how we generate a symlink and the tag referencing the checked-in one.
{ type = "spec-search-replace", regex = '^.*:\s*azurelinux-annobin-cc1\s*$', replacement = "" },
{ type = "spec-append-lines", section = "%prep", lines = ["ln -sfr azurelinux-annobin-select-annobin-built-plugin azurelinux-annobin-cc1"] },
{ type = "spec-add-tag", tag = "Conflicts", value = "redhat-rpm-config < 1000" },

# Create symlink for our own name: /usr/lib/rpm/azurelinux -> /usr/lib/rpm/redhat
# Note that we don't do the reverse to avoid conflicts with upstream Fedora
# redhat-rpm-config during bootstrapping (replacing a dir with a symlink is
# problematic in RPM land).
{ type = "spec-prepend-lines", section = "%install", lines = ["mkdir -p %{buildroot}/usr/lib/rpm", "ln -sf redhat %{buildroot}/usr/lib/rpm/azurelinux"] },
{ type = "spec-prepend-lines", section = "%files", lines = ["/usr/lib/rpm/azurelinux"] },

#Create a symlink pkg-config: /usr/bin/<arch>-azurelinux-linux-gnu-pkg-config -> /usr/bin/<arch>-redhat-linux-gnu-pkg-config.
{ type = "spec-prepend-lines", section = "%install", lines = ["mkdir -p %{buildroot}/usr/bin", "for arch in x86_64 aarch64; do", " ln -sf ${arch}-redhat-linux-gnu-pkg-config %{buildroot}/usr/bin/${arch}-azurelinux-linux-gnu-pkg-config", "done"] },
{ type = "spec-prepend-lines", section = "%files", lines = ["/usr/bin/*-azurelinux-linux-gnu-pkg-config"] },

#
# Overlays for non-spec files.
#

# Remove the symlink that we can't easily fix up (the spec changes above avoid using it).
{ type = "file-remove", file = "redhat-annobin-cc1" },

# Apply file renames *first*: fedora/redhat -> azurelinux
{ type = "file-rename", file = "macros.fedora-misc-srpm", replacement = "macros.azurelinux-misc-srpm" },
{ type = "file-rename", file = "macros.fedora-misc", replacement = "macros.azurelinux-misc" },
{ type = "file-rename", file = "redhat-annobin-plugin-select.sh", replacement = "azurelinux-annobin-plugin-select.sh" },
{ type = "file-rename", file = "redhat-annobin-select-annobin-built-plugin", replacement = "azurelinux-annobin-select-annobin-built-plugin" },
{ type = "file-rename", file = "redhat-annobin-select-gcc-built-plugin", replacement = "azurelinux-annobin-select-gcc-built-plugin" },
{ type = "file-rename", file = "redhat-hardened-cc1", replacement = "azurelinux-hardened-cc1" },
{ type = "file-rename", file = "redhat-hardened-clang-ld.cfg", replacement = "azurelinux-hardened-clang-ld.cfg" },
{ type = "file-rename", file = "redhat-hardened-clang.cfg", replacement = "azurelinux-hardened-clang.cfg" },
{ type = "file-rename", file = "redhat-hardened-ld-errors", replacement = "azurelinux-hardened-ld-errors" },
{ type = "file-rename", file = "redhat-hardened-ld", replacement = "azurelinux-hardened-ld" },
{ type = "file-rename", file = "STAGE2-redhat-rpm-config", replacement = "STAGE2-azurelinux-rpm-config" },

# Update all references to the Fedora version of this package to the Azure Linux one.
{ type = "file-search-replace", file = "**/*", regex = "redhat-rpm-config", replacement = "azurelinux-rpm-config" },
# Update all references to the vendor-specific dir under /usr/lib/rpm.
{ type = "file-search-replace", file = "**/*", regex = "/usr/lib/rpm/redhat", replacement = "/usr/lib/rpm/azurelinux" },

# Update vendor macro + textual references in macros files.
# Update vendor macro.
{ type = "file-search-replace", file = "macros", regex = "%_vendor.*", replacement = "%_vendor azurelinux" },
{ type = "file-search-replace", file = "macros", regex = "redhat", replacement = "azurelinux" },

# Remove dist.sh file; we'll replace it wholesale with our own version.
{ type = "file-remove", file = "dist.sh" },
# Add our own version of dist.sh customized for Azure Linux.
{ type = "file-add", file = "dist.sh", source = "dist.sh" },

# Additional replacements of the distro name in macros files.
{ type = "file-search-replace", file = "rpmrc", regex = "fedora", replacement = "azurelinux" },
{ type = "file-search-replace", file = "macros.azurelinux-misc", regex = "fedora", replacement = "azurelinux" },
{ type = "file-search-replace", file = "macros.azurelinux-misc-srpm", regex = "/lib/swidtag/fedoraproject.org", replacement = "/lib/swidtag/microsoft.com" },
{ type = "file-search-replace", file = "macros.azurelinux-misc-srpm", regex = "[Ff]edora", replacement = "azurelinux" },
# Update annobin references.
{ type = "file-search-replace", file = "azurelinux-annobin-plugin-select.sh", regex = "redhat-annobin", replacement = "azurelinux-annobin" },
{ type = "file-search-replace", file = "buildflags.md", regex = "redhat-annobin", replacement = "azurelinux-annobin" },
# Update redhat-hardened references.
{ type = "file-search-replace", file = "STAGE2-azurelinux-rpm-config", regex = "redhat-hardened", replacement = "azurelinux-hardened" },
{ type = "file-search-replace", file = "buildflags.md", regex = "redhat-hardened", replacement = "azurelinux-hardened" },
# Targeted adjustments in some macros files.
{ type = "file-search-replace", file = "macros.fedora-misc-srpm", regex = "/lib/swidtag/fedoraproject.org", replacement = "/lib/swidtag/microsoft.com" },
{ type = "file-search-replace", file = "macros.fedora-misc-srpm", regex = "[Ff]edora", replacement = "azurelinux" },
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reubeno @dmcilvaney is this really needed, what copilot is asking for? ^

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.

3 participants