build: When parsing distro from /etc/os-release, try $ID_LIKE first

The current code for working out the distro uses the ID entry from
/etc/os-release, and then we map those strings into a smaller set of
values (basically, what package manager to use).  However it was
suggested that we should try ID_LIKE first so that distros which act
like other distros would work.  On an Arch Linux 32 system:

ID=arch32
ID_LIKE=arch

See-also: https://github.com/libguestfs/libguestfs/issues/81
Thanks: S D Rausty
This commit is contained in:
Richard W.M. Jones
2022-05-22 18:36:11 +01:00
parent 4418e6345a
commit 63b722b6c0

View File

@@ -102,8 +102,16 @@ AC_ARG_WITH([distro],
AC_MSG_RESULT([$DISTRO (manually specified)])
],[
if test -f /etc/os-release; then
( . /etc/os-release && echo $ID | tr '@<:@:lower:@:>@' '@<:@:upper:@:>@' ) >&AS_MESSAGE_LOG_FD
DISTRO="`. /etc/os-release && echo $ID | tr '@<:@:lower:@:>@' '@<:@:upper:@:>@'`"
echo "/etc/os-release:" >&AS_MESSAGE_LOG_FD
cat /etc/os-release >&AS_MESSAGE_LOG_FD
DISTRO="$(
. /etc/os-release
if test -n "$ID_LIKE"; then
echo $ID_LIKE | tr '@<:@:lower:@:>@' '@<:@:upper:@:>@'
else
echo $ID | tr '@<:@:lower:@:>@' '@<:@:upper:@:>@'
fi
)"
AS_CASE([$DISTRO],
[FEDORA | RHEL | CENTOS | ALMALINUX | CLOUDLINUX | ROCKY],
[DISTRO=REDHAT],
@@ -116,6 +124,7 @@ AC_ARG_WITH([distro],
fi
]
)
AC_SUBST([DISTRO])
AM_CONDITIONAL([HAVE_RPM],
[AS_CASE([$DISTRO], [REDHAT | SUSE | OPENMANDRIVA | MAGEIA ], [true],
[*], [false])])
@@ -125,7 +134,6 @@ AM_CONDITIONAL([HAVE_DPKG],
AM_CONDITIONAL([HAVE_PACMAN],
[AS_CASE([$DISTRO], [ARCHLINUX | FRUGALWARE | ARTIX], [true],
[*], [false])])
AC_SUBST([DISTRO])
dnl Add extra packages to the appliance.
AC_ARG_WITH([extra-packages],