Richard W.M. Jones
2022-May-22 17:41 UTC
[Libguestfs] [PATCH libguestfs] 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 --- m4/guestfs-appliance.m4 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/m4/guestfs-appliance.m4 b/m4/guestfs-appliance.m4 index 9e443f151d..4e63ef4356 100644 --- a/m4/guestfs-appliance.m4 +++ b/m4/guestfs-appliance.m4 @@ -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], -- 2.35.1
Richard W.M. Jones
2022-May-23 11:58 UTC
[Libguestfs] [PATCH libguestfs] build: When parsing distro from /etc/os-release, try $ID_LIKE first
On Sun, May 22, 2022 at 06:41:14PM +0100, Richard W.M. Jones wrote:> 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 > --- > m4/guestfs-appliance.m4 | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-)The bug reporter seems to have tested this and it works, so I pushed it (commit 63b722b6c094). Rich.> diff --git a/m4/guestfs-appliance.m4 b/m4/guestfs-appliance.m4 > index 9e443f151d..4e63ef4356 100644 > --- a/m4/guestfs-appliance.m4 > +++ b/m4/guestfs-appliance.m4 > @@ -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], > -- > 2.35.1 > > _______________________________________________ > Libguestfs mailing list > Libguestfs at redhat.com > https://listman.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top