amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
500 stars 38 forks source link

[Bug] - Current Copr (Fedora) default configuration broken #643

Open tim77 opened 4 months ago

tim77 commented 4 months ago

Describe the bug Current Copr (Fedora) default configuration broken.

To Reproduce Steps to reproduce the behavior:

  1. Try to add Copr repo for Amazon Linux 2023. Example for testing purposes.
  2. sudo dnf copr enable atim/shadowsocks-rust
  3. See error:
    Error: It wasn't possible to enable this project.
    Repository 'epel-2023-x86_64' does not exist in project 'atim/shadowsocks-rust'.
    Available repositories: 'fedora-40-x86_64', 'fedora-37-aarch64', 'fedora-38-aarch64', 'epel-7-x86_64', 'fedora-rawhide-x86_64', 'fedora-37-x86_64', 'epel-9-aarch64', 'fedora-40-aarch64', 'amazonlinux-2023-aarch64', 'epel-8-aarch64', 'fedora-39-x86_64', 'fedora-38-x86_64', 'centos-stream-9-aarch64', 'amazonlinux-2023-x86_64', 'fedora-rawhide-aarch64', 'epel-8-x86_64', 'epel-9-x86_64', 'fedora-39-aarch64', 'centos-stream-9-x86_64'

Expected behavior Copr repo should successfully added without any additional tweaks.

Additional context Current configuration point to epel-2023-x86_64 but the correct one is amazonlinux-2023-x86_64.

daniejstriata commented 4 months ago

This issue is not with AL2023 itself. The repo you try to add, incorrectly requires EPEL9 as a dependency.

tim77 commented 4 months ago

The proper fix is the amazonlinux-release needs to ship a /usr/share/dnf/plugins/copr.vendor.conf file that forces the plugin to select Amazon Linux 2023.

daniejstriata commented 4 months ago

@tim77 You are correct. I was able to replicate it with another copr repo. It would appear that the dnf copr plugin is being used without considering that it is not on a Fedora/RHEL host.

elsaco commented 3 months ago

@tim77 what the error tells is that there's no epel-2023-x86_64 chroot in that repository. The copr plugin it trying to find the appropriate one for the current system and fails. If you look at copr.py beginning line number 438 you'll understand what's going on:

   def _guess_chroot(self):
        """ Guess which chroot is equivalent to this machine """
        # FIXME Copr should generate non-specific arch repo
        dist = self.chroot_config
        if dist is None or (dist[0] is False) or (dist[1] is False):
            dist = linux_distribution()
        # Get distribution architecture
        distarch = self.base.conf.substitutions['basearch']
        if any([name in dist for name in ["Fedora", "Fedora Linux"]]):
            if "Rawhide" in dist:
                chroot = ("fedora-rawhide-" + distarch)
            # workaround for enabling repos in Rawhide when VERSION in os-release
            # contains a name other than Rawhide
            elif "rawhide" in os_release_attr("redhat_support_product_version"):
                chroot = ("fedora-rawhide-" + distarch)
            else:
                chroot = ("fedora-{0}-{1}".format(dist[1], distarch))
        elif "Mageia" in dist:
            # Get distribution architecture (Mageia does not use $basearch)
            distarch = rpm.expandMacro("%{distro_arch}")
            # Set the chroot
            if "Cauldron" in dist:
                chroot = ("mageia-cauldron-{}".format(distarch))
            else:
                chroot = ("mageia-{0}-{1}".format(dist[1], distarch))
        elif "openSUSE" in dist:
            # Get distribution architecture (openSUSE does not use $basearch)
            distarch = rpm.expandMacro("%{_target_cpu}")
            # Set the chroot
            if "Tumbleweed" in dist:
                chroot = ("opensuse-tumbleweed-{}".format(distarch))
            else:
                chroot = ("opensuse-leap-{0}-{1}".format(dist[1], distarch))
        elif "CentOS Stream" in dist:
            chroot = ("centos-stream-{0}-{1}".format(dist[1], distarch))
        else:
            chroot = ("epel-%s-x86_64" % dist[1].split(".", 1)[0])
        return chroot

guess_chroot() starts with a list name dist and it populates it with ['amazonlinux', '2023']. The list is used to assemble a copr chroot for the running system. Since nothing matches it returns epel-2023-x86_64 causing the issue.

If another option is added before exiting the if statement then it works:

         elif "amazonlinux" in dist:
             chroot = ("{0}-{1}-{2}".format(dist[0], dist[1], distarch))

and dnf copr enable output:

Do you really want to enable copr.fedorainfracloud.org/atim/shadowsocks-rust? [y/N]: y
Repository successfully enabled.

Another test was setting a copr.vendor.conf with content:

[main]
distribution = amazonlinux
releasever = 2023

but it didn't work.