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

Pino Toscano ptoscano at redhat.com
Mon Sep 25 12:31:26 UTC 2017


On Friday, 1 September 2017 12:11:43 CEST Cedric Bosdonnat wrote:
> 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

While this is true, it adds way more complexity than this configure bit
actually requires.  Also, there is not a list of all the values of
$DISTRO that actually do something (see appliance/packagelist.in,
appliance/excludefiles.in, and appliance/hostfiles.in): thus, when
building on a derivative, ID= is most probably non-empty, but it won't
do much anyway.

Hence, building on a new distribution requires a minimum of manual work
to check things are built as expected, including regarding the package
selection.  Also, see last paragraph in this email.

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

As we discussed on IRC days ago, this problem is mostly because on SUSE
there was an unification of the build roots, and they added a
/etc/os-release file with no ID, and only ID_LIKE=suse.  I will just
mention that I see only downsides in this approach, but there is
nothing that can be done against it.
Is there a way to pull any package that will install a real os-release
for the distro?  That certainly will help...

Anyway, I decided to tackle, at least for libguestfs, the solution from
a different corner: have a --with-distro=ID to override the detection:
https://www.redhat.com/archives/libguestfs/2017-September/msg00205.html
This helps SUSE distros (that can just pass --with-distro=SUSE to
configure), and derivatives as well (that can pass
--with-distro=PARENT_DISTRO, to behave like the parent distro).

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20170925/6ddf872b/attachment.sig>


More information about the Libguestfs mailing list