mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
inspect: use os-release for CoreOS
Look for /lib/os-release in the /usr partition and try to use it, if present, before using lsb-release later on. This should not change the final result of the inspection, while using the os-release detection method also for CoreOS. Update the phony CoreOS image to use os-release instead, uploading the version found in the current stable version.
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
<root>/dev/sda5</root>
|
||||
<name>linux</name>
|
||||
<distro>coreos</distro>
|
||||
<product_name>CoreOS 647.0.0</product_name>
|
||||
<major_version>647</major_version>
|
||||
<minor_version>0</minor_version>
|
||||
<product_name>CoreOS 899.13.0</product_name>
|
||||
<major_version>899</major_version>
|
||||
<minor_version>13</minor_version>
|
||||
<hostname>coreos.invalid</hostname>
|
||||
<format>installed</format>
|
||||
<mountpoints>
|
||||
|
||||
@@ -196,6 +196,8 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char *filename)
|
||||
distro = OS_DISTRO_ARCHLINUX;
|
||||
else if (VALUE_IS ("centos"))
|
||||
distro = OS_DISTRO_CENTOS;
|
||||
else if (VALUE_IS ("coreos"))
|
||||
distro = OS_DISTRO_COREOS;
|
||||
else if (VALUE_IS ("debian"))
|
||||
distro = OS_DISTRO_DEBIAN;
|
||||
else if (VALUE_IS ("fedora"))
|
||||
@@ -1055,6 +1057,16 @@ guestfs_int_check_coreos_usr (guestfs_h *g, struct inspect_fs *fs)
|
||||
|
||||
fs->type = OS_TYPE_LINUX;
|
||||
fs->distro = OS_DISTRO_COREOS;
|
||||
|
||||
if (guestfs_is_file_opts (g, "/lib/os-release",
|
||||
GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
|
||||
r = parse_os_release (g, fs, "/lib/os-release");
|
||||
if (r == -1) /* error */
|
||||
return -1;
|
||||
if (r == 1) /* ok - detected the release from this file */
|
||||
goto skip_release_checks;
|
||||
}
|
||||
|
||||
if (guestfs_is_file_opts (g, "/share/coreos/lsb-release",
|
||||
GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
|
||||
r = parse_lsb_release (g, fs, "/share/coreos/lsb-release");
|
||||
@@ -1062,6 +1074,8 @@ guestfs_int_check_coreos_usr (guestfs_h *g, struct inspect_fs *fs)
|
||||
return -1;
|
||||
}
|
||||
|
||||
skip_release_checks:;
|
||||
|
||||
/* Determine the architecture. */
|
||||
check_architecture (g, fs);
|
||||
|
||||
|
||||
@@ -21,12 +21,17 @@
|
||||
export LANG=C
|
||||
set -e
|
||||
|
||||
# lsb-release file.
|
||||
cat > archlinux.release <<'EOF'
|
||||
DISTRIB_ID=CoreOS
|
||||
DISTRIB_RELEASE=647.0.0
|
||||
DISTRIB_CODENAME="Red Dog"
|
||||
DISTRIB_DESCRIPTION="CoreOS 647.0.0"
|
||||
# os-release file.
|
||||
cat > coreos.release <<'EOF'
|
||||
NAME=CoreOS
|
||||
ID=coreos
|
||||
VERSION=899.13.0
|
||||
VERSION_ID=899.13.0
|
||||
BUILD_ID=2016-03-23-0120
|
||||
PRETTY_NAME="CoreOS 899.13.0"
|
||||
ANSI_COLOR="1;32"
|
||||
HOME_URL="https://coreos.com/"
|
||||
BUG_REPORT_URL="https://github.com/coreos/bugs/issues"
|
||||
EOF
|
||||
|
||||
# Create a disk image.
|
||||
@@ -69,15 +74,16 @@ mkdir-p /usr/share/coreos/
|
||||
ln-s usr/bin /bin
|
||||
ln-s usr/lib64 /lib64
|
||||
ln-s lib64 /lib
|
||||
ln-s lib64 /usr/lib
|
||||
mkdir /root
|
||||
mkdir /home
|
||||
|
||||
write /etc/coreos/update.conf "GROUP=stable"
|
||||
upload archlinux.release /usr/share/coreos/lsb-release
|
||||
ln-s ../usr/share/coreos/lsb-release /etc/lsb-release
|
||||
upload coreos.release /usr/lib/os-release
|
||||
ln-s ../usr/lib/os-release /etc/os-release
|
||||
write /etc/hostname "coreos.invalid"
|
||||
|
||||
EOF
|
||||
|
||||
rm archlinux.release
|
||||
rm coreos.release
|
||||
mv coreos.img-t coreos.img
|
||||
|
||||
Reference in New Issue
Block a user