Skip to content

Commit

Permalink
Add Amazon Linux 2023 support
Browse files Browse the repository at this point in the history
amzn2023 is a RHEL derivative, so this is trivial
  • Loading branch information
elprans committed Oct 17, 2024
1 parent a023b27 commit d51319f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion metapkg/targets/linux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_specific_target(

like_set = set(like.split(" "))

if like_set & {"rhel", "fedora", "centos"}:
if like_set & {"rhel", "fedora", "centos", "amzn"}:
target = rpm.get_specific_target(distro_info, arch, libc)
elif like_set & {"debian", "ubuntu"}:
target = deb.get_specific_target(distro_info, arch, libc)
Expand Down
2 changes: 1 addition & 1 deletion metapkg/targets/macos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def machine_architecture_alias(self) -> str:
@property
def min_supported_version(self) -> str:
if self.machine_architecture_alias == "arm64":
return "10.15"
return "11.0"
else:
return "10.12"

Expand Down
31 changes: 31 additions & 0 deletions metapkg/targets/rpm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,27 @@ def install_build_deps(self, build: rpmbuild.Build, spec: str) -> None:
)


class AmazonLinuxTarget(RHEL7OrNewerTarget):
def __init__(
self, distro_info: distro.InfoDict, arch: str, libc: str
) -> None:
super().__init__(distro_info, arch, libc)
self.distro["codename"] = (
f'amzn{self.distro["version_parts"]["major"]}'
)

def install_build_deps(self, build: rpmbuild.Build, spec: str) -> None:
tools.cmd(
"dnf",
"builddep",
"-y",
spec,
cwd=str(build.get_spec_root(relative_to="fsroot")),
stdout=build._io.output.stream,
stderr=subprocess.STDOUT,
)


def get_specific_target(
distro_info: distro.InfoDict, arch: str, libc: str
) -> BaseRPMTarget:
Expand All @@ -336,5 +357,15 @@ def get_specific_target(
else:
return FedoraTarget(distro_info, arch, libc)

elif distro_info["id"] == "amzn":
ver = int(distro_info["version_parts"]["major"])
if ver < 2023:
raise NotImplementedError(
f'{distro_info["id"]} {distro_info["version"]} '
f"is not supported"
)
else:
return AmazonLinuxTarget(distro_info, arch, libc)

else:
raise NotImplementedError(f'{distro_info["id"]} is not supported')

0 comments on commit d51319f

Please sign in to comment.