Improve Xen support (#1459)

* Enable some useful kernel configurations

* Add xe-guest-utilities for better Xen support

Add guest utilities and make sure the Xen guest daemon gets started
when running under Xen virtualization.
This commit is contained in:
Stefan Agner 2021-07-17 02:20:57 +02:00 committed by GitHub
parent 54fa9899eb
commit bdc9909117
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 669 additions and 2 deletions

View File

@ -15,6 +15,6 @@ jobs:
with: with:
dockerfile: Dockerfile dockerfile: Dockerfile
- name: Check shell scripts - name: Check shell scripts
uses: ludeeus/action-shellcheck@1.0.0 uses: ludeeus/action-shellcheck@1.1.0
with: with:
ignore: "buildroot" ignore: buildroot buildroot-external/package/xe-guest-utilities

View File

@ -11,3 +11,4 @@ source "$BR2_EXTERNAL_HASSOS_PATH/package/udisks2/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/eq3_char_loop/Config.in" source "$BR2_EXTERNAL_HASSOS_PATH/package/eq3_char_loop/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/generic_raw_uart/Config.in" source "$BR2_EXTERNAL_HASSOS_PATH/package/generic_raw_uart/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/rpi-rf-mod/Config.in" source "$BR2_EXTERNAL_HASSOS_PATH/package/rpi-rf-mod/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/xe-guest-utilities/Config.in"

View File

@ -46,6 +46,12 @@ CONFIG_PARAVIRT=y
CONFIG_PARAVIRT_SPINLOCKS=y CONFIG_PARAVIRT_SPINLOCKS=y
CONFIG_VIRT_DRIVERS=y CONFIG_VIRT_DRIVERS=y
CONFIG_XEN=y CONFIG_XEN=y
# CONFIG_XEN_DOM0 is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_SND_XEN_FRONTEND=y
CONFIG_XEN_PVCALLS_FRONTEND=m
CONFIG_XEN_WDT=y
CONFIG_DRM_XEN=y
CONFIG_HYPERVISOR_GUEST=y CONFIG_HYPERVISOR_GUEST=y
CONFIG_HYPERV=y CONFIG_HYPERV=y

View File

@ -76,6 +76,7 @@ BR2_PACKAGE_DOCKER_ENGINE=y
BR2_PACKAGE_DOCKER_CLI=y BR2_PACKAGE_DOCKER_CLI=y
BR2_PACKAGE_OPENVMTOOLS=y BR2_PACKAGE_OPENVMTOOLS=y
BR2_PACKAGE_QEMU_GUEST_AGENT=y BR2_PACKAGE_QEMU_GUEST_AGENT=y
BR2_PACKAGE_XE_GUEST_UTILITIES=y
BR2_PACKAGE_RAUC=y BR2_PACKAGE_RAUC=y
BR2_PACKAGE_RAUC_NETWORK=y BR2_PACKAGE_RAUC_NETWORK=y
BR2_PACKAGE_RNG_TOOLS=y BR2_PACKAGE_RNG_TOOLS=y

View File

@ -0,0 +1,7 @@
config BR2_PACKAGE_XE_GUEST_UTILITIES
depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
depends on BR2_TOOLCHAIN_HAS_THREADS
bool "Xen guest utilities"
help
Xen guest utilities for UNIX-like operating systems.

View File

@ -0,0 +1,9 @@
[Unit]
Description=Mount /proc/xen files
ConditionPathExists=/proc/xen
RefuseManualStop=true
[Mount]
What=xenfs
Where=/proc/xen
Type=xenfs

View File

@ -0,0 +1 @@
d /run/xenstored 0755 - - -

View File

@ -0,0 +1,13 @@
[Unit]
Description=Xen guest utility daemon
Requires=proc-xen.mount
ConditionVirtualization=xen
[Service]
PIDFile=/run/xe-daemon.pid
ExecStartPre=/usr/sbin/xe-linux-distribution /var/cache/xe-linux-distribution
ExecStart=/usr/sbin/xe-daemon -p /run/xe-daemon.pid
ExecStop=/usr/bin/pkill -TERM -F /run/xe-daemon.pid
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,57 @@
################################################################################
#
# xe-guest-utilities
#
################################################################################
XE_GUEST_UTILITIES_VERSION = 7.30.0
XE_GUEST_UTILITIES_SITE = $(call github,xenserver,xe-guest-utilities,v$(XE_GUEST_UTILITIES_VERSION))
XE_GUEST_UTILITIES_LICENSE = BSD-2-Clause
XE_GUEST_UTILITIES_LICENSE_FILES = LICENSE
XE_GUEST_UTILITIES_DEPENDENCIES = host-pkgconf
XE_GUEST_UTILITIES_XENSTORE_ALIAS = \
xenstore-ls \
xenstore-exists \
xenstore-chmod \
xenstore-rm \
xenstore-read \
xenstore-write \
xenstore-watch \
xenstore-list
define XE_GUEST_UTILITIES_BUILD_CMDS
cd $(@D); \
$(TARGET_MAKE_ENV) $(MAKE)
endef
define XE_GUEST_UTILITIES_INSTALL_TARGET_CMDS
$(INSTALL) -m 755 $(XE_GUEST_UTILITIES_PKGDIR)/xe-linux-distribution \
$(TARGET_DIR)/usr/sbin/xe-linux-distribution
$(INSTALL) -m 755 $(@D)/build/stage/usr/sbin/xe-daemon \
$(TARGET_DIR)/usr/sbin/xe-daemon
$(INSTALL) -m 755 $(@D)/build/stage/usr/bin/xenstore \
$(TARGET_DIR)/usr/bin/xenstore
$(foreach f,$(XE_GUEST_UTILITIES_XENSTORE_ALIAS), \
ln -sf xenstore $(TARGET_DIR)/usr/bin/$(f)
)
$(INSTALL) -D -m 644 $(@D)/mk/xen-vcpu-hotplug.rules \
$(TARGET_DIR)/usr/lib/udev/rules.d/10-xen-vcpu-hotplug.rules
endef
define XE_GUEST_UTILITIES_INSTALL_INIT_SYSTEMD
$(INSTALL) -D -m 0644 $(XE_GUEST_UTILITIES_PKGDIR)/proc-xen.mount \
$(TARGET_DIR)/usr/lib/systemd/system/proc-xen.mount
$(INSTALL) -D -m 0644 $(XE_GUEST_UTILITIES_PKGDIR)/tmpfile.conf \
$(TARGET_DIR)/usr/lib/tmpfiles.d/30-xenstored.conf
$(INSTALL) -D -m 0644 $(XE_GUEST_UTILITIES_PKGDIR)/xe-daemon.service \
$(TARGET_DIR)/usr/lib/systemd/system/xe-daemon.service
endef
$(eval $(golang-package))

View File

@ -0,0 +1,572 @@
#! /bin/sh
# Copyright (c) 2015, Citrix Systems
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Script to write information about the current distribution to stdout or a file.
# Information collected:
# - Distribution name
# - Distribution version (major and minor)
# - Kernel version (uname)
LANG="C"
export LANG
write_to_output()
{
local distro="$1"
local major="$2"
local minor="$3"
local name="$4"
local uname=$(uname -r)
if [ -n "${TEST_RESULT}" ] ; then
MAJOR=$major
MINOR=$minor
DISTRO=$distro
UNAME=$uname
NAME=$name
return 0
fi
echo "os_distro=\"${distro}\""
echo "os_majorver=\"${major}\""
echo "os_minorver=\"${minor}\""
echo "os_uname=\"${uname}\""
echo "os_name=\"${name}\""
return 0
}
identify_debian()
{
local debian_version="$1"
local major
local minor
# 3.1
# 4.0
# Ignores testing and unstable which contain ".*/sid".
if [ ! -f "${debian_version}" ] ; then
return 1
fi
eval $(awk -F. '/^[0-9]*\.[0-9]*/ \
{ print "major="$1 ; print "minor="$2 ; exit 0 }' \
"${debian_version}")
if [ -z "${major}" ] && [ -z "${minor}" ] && ! grep -q /sid "${debian_version}" ; then
return 1
fi
write_to_output "debian" "${major}" "${minor}" "Debian $(head -n 1 $debian_version)"
return 0
}
identify_redhat()
{
redhat_release="$1"
local distro
local major
local minor
local beta
# distro=rhel
# Red Hat Enterprise Linux AS release 3 (Taroon Update 6)
# Red Hat Enterprise Linux AS release 3 (Taroon Update 8)
# Red Hat Enterprise Linux AS release 4 (Nahant)
# Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
# Red Hat Enterprise Linux AS release 4 (Nahant Update 2)
# Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
# Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
# Red Hat Enterprise Linux Server release 4.92 (Tikanga)
# Red Hat Enterprise Linux Server release 5 (Tikanga)
# Red Hat Enterprise Linux Server release 5.1 Beta (Tikanga)
# Red Hat Enterprise Linux release 6.0 Beta (Santiago)
# distro=xe-ddk
# \@PRODUCT_BRAND\@ DDK release \@PRODUCT_VERSION\@-\@BUILD_NUMBER\@ (\@PRODUCT_NAME\@)
# Rio DDK release 0.5.6-2991c (xenenterprise)
# distro=xe-sdk
# \@PRODUCT_BRAND\@ SDK release \@PRODUCT_VERSION\@-\@BUILD_NUMBER\@ (\@PRODUCT_NAME\@)
# Rio SDK release 0.5.6-2991c (xenenterprise)
# distro=fedora
# Fedora Core release 3 (Heidelberg)
# distro=centos
# CentOS release 4.0 (Final)
# CentOS release 5 (Final)
# CentOS Linux release 7.0.1406 (Core)
# CentOS Stream release 8
# distro=rocky
# Rocky Linux release 8.3
# distro=scientific
# Scientific Linux release 6.5 (Carbon)
# distro=oracle
# Enterprise Linux Enterprise Linux Server release 5 (Carthage)
# Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)
# Oracle Linux Server release 5.6
# distro=almalinux
# AlmaLinux release 8.3 (Purple Manul)
if [ ! -f "${redhat_release}" ] ; then
return 1
fi
eval $(sed -nr \
's/^(.*) DDK release ([^-]*)(-(.*))? (.*)$/distro=xe-ddk;major=\2;minor=\4/gp;' \
"${redhat_release}")
eval $(sed -n \
-e 's/^\(.*\) SDK release \(.*\)-\(.*\) (.*)$/distro=xe-sdk;major=\2;minor=\3/gp;' \
-e 's/^Red Hat Enterprise Linux.* release \([0-9]*\) (.* Update \(.*\))$/distro=rhel;major=\1;minor=\2/gp;'\
-e 's/^Red Hat Enterprise Linux.* release \([0-9]*\) (.*)$/distro=rhel;major=\1/gp;' \
-e 's/^Red Hat Enterprise Linux.* release \([0-9]*\)\.\([0-9]*\) \([Bb]eta \)\?(.*)$/distro=rhel;major=\1;minor=\2;beta=\3;/gp;' \
-e 's/^Fedora.*release \([0-9]*\) (.*)$/distro=fedora;major=\1/gp;' \
-e 's/^CentOS release \([0-9]*\)\.\([0-9]*\) (.*)/distro=centos;major=\1;minor=\2/gp;' \
-e 's/^CentOS release \([0-9]*\) (.*)/distro=centos;major=\1/gp;' \
-e 's/^CentOS Linux release \([0-9]*\)\.\([0-9]*\).*$/distro=centos;major=\1;minor=\2/gp;' \
-e 's/^CentOS Stream release \([0-9]*\).*$/distro=centos;major=\1/gp;' \
-e 's/^Rocky Linux release \([0-9]*\)\.\([0-9]*\).*$/distro=rocky;major=\1;minor=\2/gp;' \
-e 's/^Enterprise Linux Enterprise Linux .* release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=oracle;major=\1;minor=\2;/gp;' \
-e 's/^Enterprise Linux Enterprise Linux .* release \([0-9]*\) (.*)$/distro=oracle;major=\1/gp;' \
-e 's/^Oracle Linux Server release \([0-9]*\)\.\([0-9]*\)$/distro=oracle;major=\1;minor=\2/gp;' \
-e 's/^Scientific Linux SL release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=scientific;major=\1;minor=\2;/gp;' \
-e 's/^Scientific Linux release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=scientific;major=\1;minor=\2;/gp;' \
-e 's/^AlmaLinux release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=almalinux;major=\1;minor=\2;/gp;' \
"${redhat_release}")
if [ -z "${major}" -o -z "${distro}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
# HACK to handle RHEL betas
if [ "${distro}" == "rhel" ] && [ ${minor} -gt 90 ] ; then
major=$(expr ${major} + 1 )
minor=0
beta=Beta
fi
if [ -n "${beta}" ] ; then
minor="${minor}beta"
fi
write_to_output "${distro}" "${major}" "${minor}" "$(head -n 1 ${redhat_release})"
}
identify_sles()
{
suse_release="$1"
local major
local minor
local _major
# SUSE LINUX Enterprise Server 9 (i586)
# VERSION = 9
#
# SUSE LINUX Enterprise Server 9 (i586)
# VERSION = 9
# PATCHLEVEL = 2
#
# SUSE LINUX Enterprise Server 9 (i586)
# VERSION = 9
# PATCHLEVEL = 3
#
# SUSE Linux Enterprise Server 10 (i586)
# VERSION = 10
#
# SUSE Linux Enterprise Server 10 (i586)
# VERSION = 10
# PATCHLEVEL = 1
#
# SUSE Linux Enterprise Server 11 (i586)
# VERSION = 11
# PATCHLEVEL = 0
#
# /etc/SuSE-release is deprecated and removed in SLE15, so use /etc/os-release to detect.
# NAME="SLES"
# VERSION="15"
# VERSION_ID="15"
# PRETTY_NAME="SUSE Linux Enterprise Server 15"
# ID="sles"
# ID_LIKE="suse"
# ANSI_COLOR="0;32"
# CPE_NAME="cpe:/o:suse:sles:15"
if [ ! -f "${suse_release}" ] ; then
return 1
fi
eval $(sed -n \
-e 's/^VERSION_ID="\([0-9]*\)\.\?\([0-9]*\)\?"$/major=\1;minor=\2;/gp' \
-e 's/^PRETTY_NAME="SUSE L\(inux\|INUX\) Enterprise \([a-zA-Z0-9_]*\) \([0-9]*\)\( SP[0-9]*\)\?"/_major=\3;_pretty_name=\0;/gp' \
-e 's/^SUSE L\(inux\|INUX\) Enterprise \([a-zA-Z0-9_]*\) \([0-9]*\) (.*)/_major=\3;_pretty_name="\0";/gp;' \
-e 's/^VERSION = \([0-9]*\)$/major=\1;/gp;' \
-e 's/^PATCHLEVEL = \([0-9]*\)$/minor=\1;/gp;' \
"${suse_release}")
if [ -z "${major}" -o -z "${_major}" ] ; then
return 1
fi
if [ "${major}" != "${_major}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
write_to_output "sles" "${major}" "${minor}" "${_pretty_name##*=}"
}
identify_lsb()
{
lsb_release="$1"
if [ ! -x "${lsb_release}" ] ; then
saved_IFS=$IFS
IFS=:
for i in $PATH ; do
if [ -x "${i}/${lsb_release}" ] ; then
lsb_release="${i}/${lsb_release}"
break
fi
done
IFS=$saved_IFS
fi
if [ -x "${lsb_release}" ] ; then
distro=$(${lsb_release} --short --id | tr 'A-Z' 'a-z')
description=$(${lsb_release} --short --description | sed -e 's/^"\(.*\)"$/\1/g')
release=$(${lsb_release} --short --release)
else
if [ -f /etc/lsb-release ] ; then
source /etc/lsb-release
distro="$DISTRIB_ID"
description="$DISTRIB_DESCRIPTION"
release="$DISTRIB_RELEASE"
else
return 1
fi
fi
if [ -z "${distro}" -o -z "${release}" ] ; then
return 1
fi
eval $(echo $release | awk -F. -- '{ subindex = index($0,"."); \
print "major=\"" $1 "\""; \
print "minor=\"" substr($0,subindex+1) "\"" }')
if [ -z "${major}" -o -z "${distro}" ] ; then
return 1
fi
write_to_output "${distro}" "${major}" "${minor}" "${description}"
}
identify_os_release()
{
os_release="$1"
local major
local minor
# Use /etc/os-release to detect.
# NAME="SLES"
# VERSION="15"
# VERSION_ID="15"
# PRETTY_NAME="SUSE Linux Enterprise Server 15"
# ID="sles"
# ID_LIKE="suse"
# ANSI_COLOR="0;32"
# CPE_NAME="cpe:/o:suse:sles:15"
if [ ! -f "${os_release}" ] ; then
return 1
fi
source "${os_release}"
eval $(echo "$VERSION_ID" | \
sed -n -e 's/^\([0-9]*\)\.\?\([0-9]*\).*$/major=\1;minor=\2;/gp')
major="${major:-unknown}"
minor="${minor:-unknown}"
write_to_output "${ID}" "${major}" "${minor}" "${PRETTY_NAME}"
}
identify_kylin()
{
kylin_release="$1"
local distro
local major
local minor
# distro
# NeoKylin Linux Security OS V5.0 (Update8)
# Neokylin Linux Security OS Server release V5 (Santiago)
# NeoKylin Linux Advanced Server release 6.5 (Berryllium)
# NeoKylin Linux Advanced Server release 7.0
if [ ! -f "${kylin_release}" ] ; then
return 1
fi
eval $(sed -rn \
's/^Neo[kK]ylin Linux[^0-9]+([0-9]+)\.?([0-9]+)?.*$/distro=neokylin;major=\1;minor=\2;/gp;' \
"${kylin_release}")
if [ -z "${major}" -o -z "${distro}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
write_to_output "${distro}" "${major}" "${minor}" "$(head -n 1 ${kylin_release})"
}
identify_asianux()
{
asianux_release="$1"
local distro
local major
local minor
# distro
# 'Asianux Server 4.5 (Final)'
# 'Asianux Server 4 (Hiranya SP2)'
# 'Asianux Server 4 (Hiranya SP4)'
if [ ! -f "${asianux_release}" ] ; then
return 1
fi
eval $(sed -rn \
's/^Asianux Server ([0-9]*)\.([0-9]*) .*$/distro=asianux;major=\1;minor=\2;/gp;'`
`'s/^Asianux Server ([0-9]*) \([^0-9]*([0-9]*)\)$/distro=asianux;major=\1;minor=\2;/gp;' \
"${asianux_release}")
if [ -z "${major}" -o -z "${distro}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
write_to_output "${distro}" "${major}" "${minor}" "$(head -n 1 ${asianux_release})"
}
identify_turbo()
{
turbo_release="$1"
local distro
local major
local minor
# distro
# GreatTurbo Enterprise Server release 12.2 (Theseus)
if [ ! -f "${turbo_release}" ] ; then
return 1
fi
eval $(sed -rn \
's/^GreatTurbo[^0-9]*([0-9]*)\.?([0-9]*)?.*$/distro=turbo;major=\1;minor=\2;/gp;' \
"${turbo_release}")
if [ -z "${major}" -o -z "${distro}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
write_to_output "${distro}" "${major}" "${minor}" "$(head -n 1 ${turbo_release})"
}
identify_linx()
{
linx_release="$1"
local distro
local major
local minor
# distro
# '6.0.60.4' corresponds to Linx Linux 6
# '6.0.80' corresponds to Linx Linux 8
if [ ! -f "${linx_release}" ] ; then
return 1
fi
eval $(sed -rn \
's/^6.0.([0-9])0.*$/distro=linx;major=\1;minor=0;/gp;' \
"${linx_release}")
if [ -z "${major}" -o -z "${distro}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
linx_osname="Linx Linux ${major}.${minor}"
write_to_output "${distro}" "${major}" "${minor}" "${linx_osname}"
}
identify_yinhe()
{
yinhe_release="$1"
local distro
local major
local minor
# distro
# Kylin 4.0
if [ ! -f "${yinhe_release}" ] ; then
return 1
fi
eval $(sed -rn \
's/^Kylin ([0-9]).([0-9])$/distro=yinhe;major=\1;minor=\2;/gp;' \
"${yinhe_release}")
if [ -z "${major}" -o -z "${distro}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
yinhe_osname="Yinhe Kylin Linux ${major}.${minor}"
write_to_output "${distro}" "${major}" "${minor}" "${yinhe_osname}"
}
identify_gooroom()
{
gooroom_release="$1"
local distro
local major
local minor
local description
if [ ! -f "${gooroom_release}" ] ; then
return 1
fi
eval $(sed -rn 's/^DISTRIB_ID=(.*)$/distro=\1;/gp;' ${gooroom_release})
if [ ${distro} != "Gooroom" ] ; then
return 1
fi
eval $(sed -rn 's/^DISTRIB_RELEASE=([0-9]).([0-9])$/major=\1;minor=\2;/gp;' ${gooroom_release})
if [ -z "${major}" ] ; then
return 1
fi
if [ -z "${minor}" ] ; then
minor=0
fi
eval $(sed -rn 's/^DISTRIB_DESCRIPTION=(.*)$/description=\1;/gp;' ${gooroom_release})
write_to_output "${distro}" "${major}" "${minor}" "${description}"
}
identify_boot2docker()
{
boot2docker_release="$1"
local major
local minor
if [ ! -f "${boot2docker_release}" ] ; then
return 1
fi
major=$(awk -F. '{printf("%s", $1)}' /etc/version)
minor=$(awk -F. '{printf("%s.%s", $2, $3)}' /etc/version)
write_to_output "boot2docker" "${major}" "${minor}" "boot2docker $(head -n 1 /etc/version)"
}
if [ $# -eq 1 ] ; then
exec 1>"$1"
fi
if [ -z "${TEST}" ] ; then
#identify kylin disto before redhat, as kylin has both kylin_release and redhat_release.
identify_asianux /etc/asianux-release && exit 0
identify_turbo /etc/turbo-release && exit 0
identify_kylin /etc/neokylin-release && exit 0
identify_redhat /etc/oracle-release && exit 0
identify_redhat /etc/enterprise-release && exit 0
#identify Rocky or AlmaLinux before CentOS and RHEL, as Rocky and AlmaLinux both have centos-release and redhat-release
identify_redhat /etc/rocky-release && exit 0
identify_redhat /etc/almalinux-release && exit 0
identify_redhat /etc/centos-release && exit 0
identify_redhat /etc/redhat-release && exit 0
#identify SuSE-release before, as previous version of SUSE or other distros also have os-release
identify_sles /etc/SuSE-release && exit 0
identify_sles /etc/os-release && exit 0
#identify Linx disto before debian, as Linx has both linx_release and debian_version.
identify_yinhe /etc/kylin-build && exit 0
identify_linx /etc/linx-release && exit 0
identify_gooroom /etc/lsb-release && exit 0
identify_lsb lsb_release && exit 0
identify_debian /etc/debian_version && exit 0
identify_boot2docker /etc/boot2docker && exit 0
identify_os_release /etc/os-release && exit 0
if [ $# -eq 1 ] ; then
rm -f "$1"
fi
exit 1
fi