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

Cedric Bosdonnat cbosdonnat at suse.com
Fri Sep 1 10:11:43 UTC 2017


On Fri, 2017-09-01 at 10:59 +0100, Daniel P. Berrange wrote:
> 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

Pino wasn't really found of that change, I'ld love to hear his take on that.

--
Cedric




More information about the Libguestfs mailing list