[Libguestfs] [PATCH] build: improve distro check
Richard W.M. Jones
rjones at redhat.com
Fri Sep 2 14:32:32 UTC 2016
On Wed, Aug 31, 2016 at 06:08:34PM +0200, Pino Toscano wrote:
> Use /etc/os-release as first option, translating the distro name to the
> current identifier used. The other options (the release files) are left
> as following checks, avoiding them if any matches.
> ---
> m4/guestfs_appliance.m4 | 25 +++++++++++++++----------
> 1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/m4/guestfs_appliance.m4 b/m4/guestfs_appliance.m4
> index 8cff51e..b48da74 100644
> --- a/m4/guestfs_appliance.m4
> +++ b/m4/guestfs_appliance.m4
> @@ -94,24 +94,29 @@ 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])
> -DISTRO=REDHAT
> -if test -f /etc/debian_version; then
> +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
> -fi
> -if test -f /etc/arch-release; then
> +elif test -f /etc/arch-release; then
> DISTRO=ARCHLINUX
> -fi
> -if test -f /etc/SuSE-release; then
> +elif test -f /etc/SuSE-release; then
> DISTRO=SUSE
> -fi
> -if test -f /etc/frugalware-release; then
> +elif test -f /etc/frugalware-release; then
> DISTRO=FRUGALWARE
> -fi
> -if test -f /etc/mageia-release; then
> +elif test -f /etc/mageia-release; then
> DISTRO=MAGEIA
> +else
> +dnl fallback option
> + DISTRO=REDHAT
> fi
> AC_MSG_RESULT([$DISTRO])
> AC_SUBST([DISTRO])
> --
> 2.7.4
ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
More information about the Libguestfs
mailing list