parent
b482182fce
commit
3e5fb84772
394
PR116.patch
Normal file
394
PR116.patch
Normal file
@ -0,0 +1,394 @@
|
||||
From 0f31c4c4b2cc5c475c26cc768f6d2c0812a7e3eb Mon Sep 17 00:00:00 2001
|
||||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Tue, 26 May 2015 22:28:29 -0400
|
||||
Subject: [PATCH 1/2] tests: Add a test script to cross-check loader config vs
|
||||
GRUB2
|
||||
|
||||
One can run this on a machine to validate things. I'd like to
|
||||
get this plugged into the actual OSTree tests as soon as we can
|
||||
figure out how to sanely run grub2-generate as non-root in
|
||||
our test suite.
|
||||
|
||||
Alternatively, this script can easily be run on a real install.
|
||||
---
|
||||
tests/grub2-entries-crosscheck.py | 105 ++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 105 insertions(+)
|
||||
create mode 100644 tests/grub2-entries-crosscheck.py
|
||||
|
||||
diff --git a/tests/grub2-entries-crosscheck.py b/tests/grub2-entries-crosscheck.py
|
||||
new file mode 100644
|
||||
index 0000000..d68394d
|
||||
--- /dev/null
|
||||
+++ b/tests/grub2-entries-crosscheck.py
|
||||
@@ -0,0 +1,105 @@
|
||||
+#!/usr/bin/python
|
||||
+#
|
||||
+# Copyright (C) 2015 Red Hat
|
||||
+#
|
||||
+# This library is free software; you can redistribute it and/or
|
||||
+# modify it under the terms of the GNU Lesser General Public
|
||||
+# License as published by the Free Software Foundation; either
|
||||
+# version 2 of the License, or (at your option) any later version.
|
||||
+#
|
||||
+# This library is distributed in the hope that it will be useful,
|
||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+# Lesser General Public License for more details.
|
||||
+#
|
||||
+# You should have received a copy of the GNU Lesser General Public
|
||||
+# License along with this library; if not, write to the
|
||||
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
+# Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+import os
|
||||
+import sys
|
||||
+
|
||||
+if len(sys.argv) == 1:
|
||||
+ loaderpath = '/boot/loader/entries'
|
||||
+ grub2path = '/boot/grub2/grub.cfg'
|
||||
+else:
|
||||
+ loaderpath = sys.argv[1]
|
||||
+ grub2path = sys.argv[2]
|
||||
+
|
||||
+def fatal(msg):
|
||||
+ sys.stderr.write(msg)
|
||||
+ sys.stderr.write('\n')
|
||||
+ sys.exit(1)
|
||||
+
|
||||
+def compare_entries_descending(a, b):
|
||||
+ return int(b['version']) - int(a['version'])
|
||||
+
|
||||
+def get_ostree_option(optionstring):
|
||||
+ for o in optionstring.split():
|
||||
+ if o.startswith('ostree='):
|
||||
+ return o[8:]
|
||||
+ raise ValueError('ostree= not found')
|
||||
+
|
||||
+entries = []
|
||||
+grub2_entries = []
|
||||
+
|
||||
+# Parse loader configs
|
||||
+for fname in os.listdir(loaderpath):
|
||||
+ path = os.path.join(loaderpath, fname)
|
||||
+ with open(path) as f:
|
||||
+ entry = {}
|
||||
+ for line in f:
|
||||
+ line = line.strip()
|
||||
+ if (line == '' or line.startswith('#')):
|
||||
+ continue
|
||||
+ s = line.find(' ')
|
||||
+ assert s > 0
|
||||
+ k = line[0:s]
|
||||
+ v = line[s+1:]
|
||||
+ entry[k] = v
|
||||
+ entries.append(entry)
|
||||
+ entries.sort(compare_entries_descending)
|
||||
+
|
||||
+# Parse GRUB2 config
|
||||
+with open(grub2path) as f:
|
||||
+ in_ostree_config = False
|
||||
+ grub2_entry = None
|
||||
+ for line in f:
|
||||
+ if line.startswith('### BEGIN /etc/grub.d/15_ostree ###'):
|
||||
+ in_ostree_config = True
|
||||
+ elif line.startswith('### END /etc/grub.d/15_ostree ###'):
|
||||
+ in_ostree_config = False
|
||||
+ if grub2_entry is not None:
|
||||
+ grub2_entries.append(grub2_entry)
|
||||
+ elif in_ostree_config:
|
||||
+ if line.startswith('menuentry '):
|
||||
+ if grub2_entry is not None:
|
||||
+ grub2_entries.append(grub2_entry)
|
||||
+ grub2_entry = {}
|
||||
+ elif line.startswith('linux'):
|
||||
+ parts = line.split()
|
||||
+ grub2_entry['linux'] = parts[1]
|
||||
+ grub2_entry['options'] = ' '.join(parts[2:])
|
||||
+ elif line.startswith('initrd'):
|
||||
+ grub2_entry['initrd'] = line.split()[1]
|
||||
+
|
||||
+if len(entries) != len(grub2_entries):
|
||||
+ fatal("Found {0} loader entries, but {1} GRUB2 entries\n".format(len(entries), len(grub2_entries)))
|
||||
+
|
||||
+def assert_matches_key(a, b, key):
|
||||
+ aval = a[key]
|
||||
+ bval = b[key]
|
||||
+ if aval != bval:
|
||||
+ fatal("Mismatch on {0}: {1} != {2}".format(key, aval, bval))
|
||||
+
|
||||
+for i,(entry,grub2entry) in enumerate(zip(entries, grub2_entries)):
|
||||
+ assert_matches_key(entry, grub2entry, 'linux')
|
||||
+ assert_matches_key(entry, grub2entry, 'initrd')
|
||||
+ entry_ostree = get_ostree_option(entry['options'])
|
||||
+ grub2_ostree = get_ostree_option(grub2entry['options'])
|
||||
+ if entry_ostree != grub2_ostree:
|
||||
+ fatal("Mismatch on ostree option: {0} != {1}".format(entry_ostree, grub2_ostree))
|
||||
+
|
||||
+sys.stdout.write('GRUB2 configuration validated\n')
|
||||
+sys.exit(0)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
|
||||
From 20bf7692a9a1a4777ebf9bc423945afcd9b2bae5 Mon Sep 17 00:00:00 2001
|
||||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Wed, 27 May 2015 20:08:44 -0400
|
||||
Subject: [PATCH 2/2] tests: Add a crosscheck for syslinux bootloader config
|
||||
generation
|
||||
|
||||
And actually wire this one up in admin-test.sh.
|
||||
---
|
||||
Makefile-tests.am | 4 ++
|
||||
tests/admin-test.sh | 24 ++++++--
|
||||
tests/syslinux-entries-crosscheck.py | 107 +++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 130 insertions(+), 5 deletions(-)
|
||||
create mode 100755 tests/syslinux-entries-crosscheck.py
|
||||
|
||||
diff --git a/Makefile-tests.am b/Makefile-tests.am
|
||||
index 7f4437c..955cef1 100644
|
||||
--- a/Makefile-tests.am
|
||||
+++ b/Makefile-tests.am
|
||||
@@ -75,6 +75,10 @@ insttest_DATA = tests/archive-test.sh \
|
||||
tests/corrupt-repo-ref.js \
|
||||
$(NULL)
|
||||
|
||||
+insttest_SCRIPTS += \
|
||||
+ tests/syslinux-entries-crosscheck.py \
|
||||
+ $(NULL)
|
||||
+
|
||||
gpginsttestdir = $(pkglibexecdir)/installed-tests/gpghome
|
||||
gpginsttest_DATA = tests/gpghome/secring.gpg \
|
||||
tests/gpghome/trustdb.gpg \
|
||||
diff --git a/tests/admin-test.sh b/tests/admin-test.sh
|
||||
index 4278e01..f7fbb92 100755
|
||||
--- a/tests/admin-test.sh
|
||||
+++ b/tests/admin-test.sh
|
||||
@@ -20,17 +20,20 @@ set -e
|
||||
|
||||
echo "1..10"
|
||||
|
||||
+function validate_bootloader() {
|
||||
+ (cd ${test_tmpdir};
|
||||
+ if test -f sysroot/boot/syslinux/syslinux.cfg; then
|
||||
+ $(dirname $0)/syslinux-entries-crosscheck.py sysroot
|
||||
+ fi)
|
||||
+}
|
||||
+
|
||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
|
||||
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
|
||||
export rev
|
||||
# This initial deployment gets kicked off with some kernel arguments
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status | tee status.txt
|
||||
-
|
||||
-assert_file_has_content status.txt 'Version: 1.0.10'
|
||||
-if test -f sysroot/boot/loader/syslinux.cfg; then
|
||||
- assert_file_has_content sysroot/boot/loader/syslinux.cfg 'TestOS 42 1.0.10'
|
||||
-fi
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok deploy command"
|
||||
|
||||
@@ -66,6 +69,7 @@ assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'option
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.1/etc/os-release 'NAME=TestOS'
|
||||
assert_file_has_content sysroot/ostree/boot.0/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok second deploy"
|
||||
|
||||
@@ -77,6 +81,7 @@ assert_not_has_dir sysroot/boot/loader.1
|
||||
assert_has_dir sysroot/ostree/boot.0.0
|
||||
assert_not_has_dir sysroot/ostree/boot.0.1
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok third deploy (swap)"
|
||||
|
||||
@@ -90,6 +95,7 @@ assert_has_file sysroot/boot/loader/entries/ostree-otheros-0.conf
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.1/etc/os-release 'NAME=TestOS'
|
||||
assert_file_has_content sysroot/ostree/deploy/otheros/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok independent deploy"
|
||||
|
||||
@@ -101,6 +107,7 @@ assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.2/etc/os-rele
|
||||
assert_has_file sysroot/boot/loader/entries/ostree-testos-2.conf
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/os-release 'NAME=TestOS'
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok fourth deploy (retain)"
|
||||
|
||||
@@ -116,6 +123,7 @@ assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/os-rele
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/a-new-config-file 'a new local config file'
|
||||
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/aconfigfile
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok deploy with modified /etc"
|
||||
|
||||
@@ -133,6 +141,7 @@ assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/new-
|
||||
# And persist /etc changes from before
|
||||
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/aconfigfile
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok upgrade bare"
|
||||
|
||||
@@ -145,6 +154,7 @@ newrev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildm
|
||||
assert_not_streq ${rev} ${newrev}
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok upgrade"
|
||||
|
||||
@@ -155,6 +165,7 @@ assert_file_has_content "${originfile}" "bacon:testos/buildmaster/x86_64-runtime
|
||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote list -u > remotes.txt
|
||||
assert_file_has_content remotes.txt 'bacon.*http://tasty.com'
|
||||
cp saved-origin ${originfile}
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok set-origin"
|
||||
|
||||
@@ -167,6 +178,7 @@ assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${rev}.0
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot undeploy 0
|
||||
assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${newrev}.0
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot status
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok undeploy"
|
||||
|
||||
@@ -178,6 +190,7 @@ echo "ok deploy with unknown OS"
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot deploy --os=testos --karg-append=console=/dev/foo --karg-append=console=/dev/bar testos:testos/buildmaster/x86_64-runtime
|
||||
${CMD_PREFIX} ostree admin --sysroot=sysroot deploy --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'console=/dev/foo.*console=/dev/bar'
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok deploy with multiple kernel args"
|
||||
|
||||
@@ -187,5 +200,6 @@ ${CMD_PREFIX} ostree admin --sysroot=sysroot upgrade --os=testos
|
||||
newrev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
|
||||
assert_not_streq ${origrev} ${newrev}
|
||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'console=/dev/foo.*console=/dev/bar'
|
||||
+validate_bootloader
|
||||
|
||||
echo "ok upgrade with multiple kernel args"
|
||||
diff --git a/tests/syslinux-entries-crosscheck.py b/tests/syslinux-entries-crosscheck.py
|
||||
new file mode 100755
|
||||
index 0000000..8b58ed4
|
||||
--- /dev/null
|
||||
+++ b/tests/syslinux-entries-crosscheck.py
|
||||
@@ -0,0 +1,107 @@
|
||||
+#!/usr/bin/python
|
||||
+#
|
||||
+# Copyright (C) 2015 Red Hat
|
||||
+#
|
||||
+# This library is free software; you can redistribute it and/or
|
||||
+# modify it under the terms of the GNU Lesser General Public
|
||||
+# License as published by the Free Software Foundation; either
|
||||
+# version 2 of the License, or (at your option) any later version.
|
||||
+#
|
||||
+# This library is distributed in the hope that it will be useful,
|
||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+# Lesser General Public License for more details.
|
||||
+#
|
||||
+# You should have received a copy of the GNU Lesser General Public
|
||||
+# License along with this library; if not, write to the
|
||||
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
+# Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+import os
|
||||
+import sys
|
||||
+
|
||||
+if len(sys.argv) == 1:
|
||||
+ sysroot = ''
|
||||
+else:
|
||||
+ sysroot = sys.argv[1]
|
||||
+
|
||||
+loaderpath = sysroot + '/boot/loader/entries'
|
||||
+syslinuxpath = sysroot + '/boot/syslinux/syslinux.cfg'
|
||||
+
|
||||
+def fatal(msg):
|
||||
+ sys.stderr.write(msg)
|
||||
+ sys.stderr.write('\n')
|
||||
+ sys.exit(1)
|
||||
+
|
||||
+def compare_entries_descending(a, b):
|
||||
+ return int(b['version']) - int(a['version'])
|
||||
+
|
||||
+def get_ostree_option(optionstring):
|
||||
+ for o in optionstring.split():
|
||||
+ if o.startswith('ostree='):
|
||||
+ return o[8:]
|
||||
+ raise ValueError('ostree= not found')
|
||||
+
|
||||
+entries = []
|
||||
+syslinux_entries = []
|
||||
+
|
||||
+# Parse loader configs
|
||||
+for fname in os.listdir(loaderpath):
|
||||
+ path = os.path.join(loaderpath, fname)
|
||||
+ with open(path) as f:
|
||||
+ entry = {}
|
||||
+ for line in f:
|
||||
+ line = line.strip()
|
||||
+ if (line == '' or line.startswith('#')):
|
||||
+ continue
|
||||
+ s = line.find(' ')
|
||||
+ assert s > 0
|
||||
+ k = line[0:s]
|
||||
+ v = line[s+1:]
|
||||
+ entry[k] = v
|
||||
+ entries.append(entry)
|
||||
+ entries.sort(compare_entries_descending)
|
||||
+
|
||||
+# Parse SYSLINUX config
|
||||
+with open(syslinuxpath) as f:
|
||||
+ in_ostree_config = False
|
||||
+ syslinux_entry = None
|
||||
+ syslinux_default = None
|
||||
+ for line in f:
|
||||
+ line = line.strip()
|
||||
+ if line.startswith('DEFAULT '):
|
||||
+ if syslinux_entry is not None:
|
||||
+ syslinux_default = line.split(' ', 1)[1]
|
||||
+ elif line.startswith('LABEL '):
|
||||
+ if syslinux_entry is not None:
|
||||
+ syslinux_entries.append(syslinux_entry)
|
||||
+ syslinux_entry = {}
|
||||
+ syslinux_entry['title'] = line.split(' ', 1)[1]
|
||||
+ elif line.startswith('KERNEL '):
|
||||
+ syslinux_entry['linux'] = line.split(' ', 1)[1]
|
||||
+ elif line.startswith('INITRD '):
|
||||
+ syslinux_entry['initrd'] = line.split(' ', 1)[1]
|
||||
+ elif line.startswith('APPEND '):
|
||||
+ syslinux_entry['options'] = line.split(' ', 1)[1]
|
||||
+ if syslinux_entry is not None:
|
||||
+ syslinux_entries.append(syslinux_entry)
|
||||
+
|
||||
+if len(entries) != len(syslinux_entries):
|
||||
+ fatal("Found {0} loader entries, but {1} SYSLINUX entries\n".format(len(entries), len(syslinux_entries)))
|
||||
+
|
||||
+def assert_matches_key(a, b, key):
|
||||
+ aval = a[key]
|
||||
+ bval = b[key]
|
||||
+ if aval != bval:
|
||||
+ fatal("Mismatch on {0}: {1} != {2}".format(key, aval, bval))
|
||||
+
|
||||
+for i,(entry,syslinuxentry) in enumerate(zip(entries, syslinux_entries)):
|
||||
+ assert_matches_key(entry, syslinuxentry, 'linux')
|
||||
+ assert_matches_key(entry, syslinuxentry, 'initrd')
|
||||
+ entry_ostree = get_ostree_option(entry['options'])
|
||||
+ syslinux_ostree = get_ostree_option(syslinuxentry['options'])
|
||||
+ if entry_ostree != syslinux_ostree:
|
||||
+ fatal("Mismatch on ostree option: {0} != {1}".format(entry_ostree, syslinux_ostree))
|
||||
+
|
||||
+sys.stdout.write('SYSLINUX configuration validated\n')
|
||||
+sys.exit(0)
|
||||
--
|
||||
1.8.3.1
|
||||
|
@ -1,11 +1,12 @@
|
||||
Summary: Tool for managing bootable, immutable filesystem trees
|
||||
Name: ostree
|
||||
Version: 2015.6
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
#VCS: git:git://git.gnome.org/ostree
|
||||
Source0: http://ftp.gnome.org/pub/GNOME/sources/ostree/%{version}/ostree-%{version}.tar.xz
|
||||
Source1: 91-ostree.preset
|
||||
Patch0: 0001-sysroot-Close-sysroot-fd-in-finalize.patch
|
||||
Patch1: PR116.patch
|
||||
License: LGPLv2+
|
||||
URL: http://live.gnome.org/OSTree
|
||||
|
||||
@ -119,6 +120,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu May 28 2015 Colin Walters <walters@redhat.com> - 2015.6-4
|
||||
- Add patch to ensure reliable bootloader ordering
|
||||
See: #1225088
|
||||
|
||||
* Thu Apr 30 2015 Colin Walters <walters@redhat.com> - 2015.6-3
|
||||
- Close sysroot fd in finalize to fix Anaconda
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1217578
|
||||
|
Loading…
Reference in New Issue
Block a user