Cédric Bosdonnat
2017-Sep-01 09:25 UTC
[Libguestfs] [PATCH v2] appliance: use ID_LIKE as a fallback for SUSE distro detection
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 elif test -f /etc/debian_version; then DISTRO=DEBIAN if grep -q 'DISTRIB_ID=Ubuntu' /etc/lsb-release 2>&AS_MESSAGE_LOG_FD; then -- 2.13.2
Daniel P. Berrange
2017-Sep-01 09:59 UTC
Re: [Libguestfs] [PATCH v2] appliance: use ID_LIKE as a fallback for SUSE distro detection
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 > + fiIf 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 :|
Cedric Bosdonnat
2017-Sep-01 10:11 UTC
Re: [Libguestfs] [PATCH v2] appliance: use ID_LIKE as a fallback for SUSE distro detection
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 distrosPino wasn't really found of that change, I'ld love to hear his take on that. -- Cedric
Seemingly Similar Threads
- [PATCH v2] appliance: use ID_LIKE as a fallback for SUSE distro detection
- Re: [PATCH v2] appliance: use ID_LIKE as a fallback for SUSE distro detection
- Re: [PATCH] appliance: read ID_LIKE from os-release as a fallback
- Re: [PATCH] appliance: read ID_LIKE from os-release as a fallback
- [PATCH] build: improve and simplify distro detection