Pino Toscano
2017-Sep-25 12:29 UTC
[Libguestfs] [PATCH] build: improve and simplify distro detection
Add a --with-distro=ID argument for configure, so it is possible to manually specify the distro to use for the packages (in case os-release does not provide ID=.., or the ID is not recognized yet). In the case when --with-distro is not set, keep doing the autodetection, but using os-release only, i.e. dropping the checks for all the other -release files -- since there is --with-distro, older distros with no os-release can still be used. --- m4/guestfs_appliance.m4 | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/m4/guestfs_appliance.m4 b/m4/guestfs_appliance.m4 index fbba3373f..4993f57a1 100644 --- a/m4/guestfs_appliance.m4 +++ b/m4/guestfs_appliance.m4 @@ -94,31 +94,25 @@ dnl names vary slightly across distros. (See dnl appliance/packagelist.in, appliance/excludefiles.in, dnl appliance/hostfiles.in) AC_MSG_CHECKING([which Linux distro for package names]) -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:@:>@'`" - AS_CASE([$DISTRO], - [FEDORA | RHEL | CENTOS],[DISTRO=REDHAT], - [OPENSUSE | SLED | SLES],[DISTRO=SUSE], - [ARCH],[DISTRO=ARCHLINUX]) -elif test -f /etc/debian_version; then - DISTRO=DEBIAN - if grep -q 'DISTRIB_ID=Ubuntu' /etc/lsb-release 2>&AS_MESSAGE_LOG_FD; then - DISTRO=UBUNTU - fi -elif test -f /etc/arch-release; then - DISTRO=ARCHLINUX -elif test -f /etc/SuSE-release; then - DISTRO=SUSE -elif test -f /etc/frugalware-release; then - DISTRO=FRUGALWARE -elif test -f /etc/mageia-release; then - DISTRO=MAGEIA -else -dnl fallback option - DISTRO=REDHAT -fi -AC_MSG_RESULT([$DISTRO]) +AC_ARG_WITH([distro], + [AS_HELP_STRING([--with-distro="DISTRO_ID"], + [distro ID @<:@default=ID in /etc/os-release@:>@])],[ + DISTRO="$withval" + 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:@:>@'`" + AS_CASE([$DISTRO], + [FEDORA | RHEL | CENTOS],[DISTRO=REDHAT], + [OPENSUSE | SLED | SLES],[DISTRO=SUSE], + [ARCH],[DISTRO=ARCHLINUX]) + AC_MSG_RESULT([$DISTRO (from /etc/os-release)]) + else + AC_MSG_ERROR([/etc/os-release not available, please specify the distro using --with-distro=DISTRO]) + fi + ] +) AC_SUBST([DISTRO]) dnl Add extra packages to the appliance. -- 2.13.5
Cedric Bosdonnat
2017-Sep-25 20:42 UTC
Re: [Libguestfs] [PATCH] build: improve and simplify distro detection
On Mon, 2017-09-25 at 14:29 +0200, Pino Toscano wrote:> Add a --with-distro=ID argument for configure, so it is possible to > manually specify the distro to use for the packages (in case os-release > does not provide ID=.., or the ID is not recognized yet). > > In the case when --with-distro is not set, keep doing the autodetection, > but using os-release only, i.e. dropping the checks for all the other > -release files -- since there is --with-distro, older distros with no > os-release can still be used.sounds good to me. I'm traveling this week, thus I surely won't have time to try it out. -- Cedric> --- > m4/guestfs_appliance.m4 | 44 +++++++++++++++++++------------------------- > 1 file changed, 19 insertions(+), 25 deletions(-) > > diff --git a/m4/guestfs_appliance.m4 b/m4/guestfs_appliance.m4 > index fbba3373f..4993f57a1 100644 > --- a/m4/guestfs_appliance.m4 > +++ b/m4/guestfs_appliance.m4 > @@ -94,31 +94,25 @@ dnl names vary slightly across distros. (See > dnl appliance/packagelist.in, appliance/excludefiles.in, > dnl appliance/hostfiles.in) > AC_MSG_CHECKING([which Linux distro for package names]) > -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:@:>@'`" > - AS_CASE([$DISTRO], > - [FEDORA | RHEL | CENTOS],[DISTRO=REDHAT], > - [OPENSUSE | SLED | SLES],[DISTRO=SUSE], > - [ARCH],[DISTRO=ARCHLINUX]) > -elif test -f /etc/debian_version; then > - DISTRO=DEBIAN > - if grep -q 'DISTRIB_ID=Ubuntu' /etc/lsb-release 2>&AS_MESSAGE_LOG_FD; then > - DISTRO=UBUNTU > - fi > -elif test -f /etc/arch-release; then > - DISTRO=ARCHLINUX > -elif test -f /etc/SuSE-release; then > - DISTRO=SUSE > -elif test -f /etc/frugalware-release; then > - DISTRO=FRUGALWARE > -elif test -f /etc/mageia-release; then > - DISTRO=MAGEIA > -else > -dnl fallback option > - DISTRO=REDHAT > -fi > -AC_MSG_RESULT([$DISTRO]) > +AC_ARG_WITH([distro], > + [AS_HELP_STRING([--with-distro="DISTRO_ID"], > + [distro ID @<:@default=ID in /etc/os-release@:>@])],[ > + DISTRO="$withval" > + 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:@:>@'`" > + AS_CASE([$DISTRO], > + [FEDORA | RHEL | CENTOS],[DISTRO=REDHAT], > + [OPENSUSE | SLED | SLES],[DISTRO=SUSE], > + [ARCH],[DISTRO=ARCHLINUX]) > + AC_MSG_RESULT([$DISTRO (from /etc/os-release)]) > + else > + AC_MSG_ERROR([/etc/os-release not available, please specify the distro using --with-distro=DISTRO]) > + fi > + ] > +) > AC_SUBST([DISTRO]) > > dnl Add extra packages to the appliance.
Cedric Bosdonnat
2017-Oct-04 12:45 UTC
[Libguestfs] [PATCH] build: improve and simplify distro detection
On Mon, 2017-09-25 at 14:29 +0200, Pino Toscano wrote:> Add a --with-distro=ID argument for configure, so it is possible to > manually specify the distro to use for the packages (in case os-release > does not provide ID=.., or the ID is not recognized yet). > > In the case when --with-distro is not set, keep doing the autodetection, > but using os-release only, i.e. dropping the checks for all the other > -release files -- since there is --with-distro, older distros with no > os-release can still be used.ACK. At least it avoids depending on something else to compute the appliance files. -- Cedric> --- > ?m4/guestfs_appliance.m4 | 44 +++++++++++++++++++------------------------- > ?1 file changed, 19 insertions(+), 25 deletions(-) > > diff --git a/m4/guestfs_appliance.m4 b/m4/guestfs_appliance.m4 > index fbba3373f..4993f57a1 100644 > --- a/m4/guestfs_appliance.m4 > +++ b/m4/guestfs_appliance.m4 > @@ -94,31 +94,25 @@ dnl names vary slightly across distros.??(See > ?dnl appliance/packagelist.in, appliance/excludefiles.in, > ?dnl appliance/hostfiles.in) > ?AC_MSG_CHECKING([which Linux distro for package names]) > -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:@:>@'`" > -????AS_CASE([$DISTRO], > -????????????[FEDORA | RHEL | CENTOS],[DISTRO=REDHAT], > -????????????[OPENSUSE | SLED | SLES],[DISTRO=SUSE], > -????????????[ARCH],[DISTRO=ARCHLINUX]) > -elif test -f /etc/debian_version; then > -????DISTRO=DEBIAN > -????if grep -q 'DISTRIB_ID=Ubuntu' /etc/lsb-release 2>&AS_MESSAGE_LOG_FD; then > -????????DISTRO=UBUNTU > -????fi > -elif test -f /etc/arch-release; then > -????DISTRO=ARCHLINUX > -elif test -f /etc/SuSE-release; then > -????DISTRO=SUSE > -elif test -f /etc/frugalware-release; then > -????DISTRO=FRUGALWARE > -elif test -f /etc/mageia-release; then > -????DISTRO=MAGEIA > -else > -dnl fallback option > -????DISTRO=REDHAT > -fi > -AC_MSG_RESULT([$DISTRO]) > +AC_ARG_WITH([distro], > +????[AS_HELP_STRING([--with-distro="DISTRO_ID"], > +????????????????????[distro ID @<:@default=ID in /etc/os-release@:>@])],[ > +????????DISTRO="$withval" > +????????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:@:>@'`" > +????????????AS_CASE([$DISTRO], > +????????????????????[FEDORA | RHEL | CENTOS],[DISTRO=REDHAT], > +????????????????????[OPENSUSE | SLED | SLES],[DISTRO=SUSE], > +????????????????????[ARCH],[DISTRO=ARCHLINUX]) > +????????????AC_MSG_RESULT([$DISTRO (from /etc/os-release)]) > +????????else > +????????????AC_MSG_ERROR([/etc/os-release not available, please specify the distro using --with-distro=DISTRO]) > +????????fi > +????] > +) > ?AC_SUBST([DISTRO]) > ? > ?dnl Add extra packages to the appliance.
Possibly Parallel Threads
- [PATCH] build: improve distro check
- Re: [PATCH] appliance: read ID_LIKE from os-release as a fallback
- [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