[Libguestfs] [PATCH v2] appliance: use ID_LIKE as a fallback for SUSE distro detection

Daniel P. Berrange berrange at redhat.com
Fri Sep 1 09:59:36 UTC 2017


On Fri, Sep 01, 2017 at 11:25:17AM +0200, Cédric Bosdonnat wrote:
> All SUSE distros have a ID_LIKE=suse, including the fake one used
> for building that has a ID=Dummy value. Without reading ID_LIKE
> on SUSE distros, the generated appliance packagelist is not correct.
> 
> This fix reads ID_LIKE as a fallback if ID contains nothing.
> ---
>  m4/guestfs_appliance.m4 | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/m4/guestfs_appliance.m4 b/m4/guestfs_appliance.m4
> index fbba3373f..788afbd36 100644
> --- a/m4/guestfs_appliance.m4
> +++ b/m4/guestfs_appliance.m4
> @@ -99,8 +99,16 @@ if test -f /etc/os-release; then
>      DISTRO="`. /etc/os-release && echo $ID | tr '@<:@:lower:@:>@' '@<:@:upper:@:>@'`"
>      AS_CASE([$DISTRO],
>              [FEDORA | RHEL | CENTOS],[DISTRO=REDHAT],
> -            [OPENSUSE | SLED | SLES],[DISTRO=SUSE],
> +            [OPENSUSE | SLED | SLES | SUSE],[DISTRO=SUSE],
>              [ARCH],[DISTRO=ARCHLINUX])
> +    dnl All SUSE-based distros have ID_LIKE containing 'suse', check for it if
> +    dnl ID wasn't helpful.
> +    if test -z "$DISTRO"; then
> +        DISTRO_LIKE="`. /etc/os-release && echo $ID_LIKE`"
> +        if echo $DISTRO_LIKE | tr " " "\n" | grep -i "^SUSE$"; then
> +            DISTRO=SUSE
> +        fi
> +    fi

If you generalized this ID_LIKE handling so that it accepted any
of the distros handled by the "ID" var, then it would make it more
portable. For example, if ID_LIKE were handled generically, there
would have been no need to add the 'CENTOS' entry, as centos
declares ID_LIKE="rhel fedora".  This would make the code likely
to work on all RHEL/Fedora/SUSE derivative distros


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the Libguestfs mailing list