Merge pull request #2224 from stb-tester/bootloader-refactorings
Bootloader probing and construction refactoring
This commit is contained in:
commit
7bc53f0063
|
|
@ -373,7 +373,9 @@ Boston, MA 02111-1307, USA.
|
||||||
<term><varname>bootloader</varname></term>
|
<term><varname>bootloader</varname></term>
|
||||||
<listitem><para>Configure the bootloader that OSTree uses when
|
<listitem><para>Configure the bootloader that OSTree uses when
|
||||||
deploying the sysroot. This may take the values
|
deploying the sysroot. This may take the values
|
||||||
<literal>bootloader=none</literal> or <literal>bootloader=auto</literal>.
|
<literal>bootloader=none</literal>, <literal>bootloader=auto</literal>,
|
||||||
|
<literal>bootloader=grub2</literal>, <literal>bootloader=syslinux</literal>,
|
||||||
|
<literal>bootloader=uboot</literal> or <literal>bootloader=zipl</literal>.
|
||||||
Default is <literal>auto</literal>.
|
Default is <literal>auto</literal>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
|
|
@ -388,6 +390,11 @@ Boston, MA 02111-1307, USA.
|
||||||
then OSTree will generate a config for the bootloader found. For
|
then OSTree will generate a config for the bootloader found. For
|
||||||
example, <literal>grub2-mkconfig</literal> is run for the grub2 case.
|
example, <literal>grub2-mkconfig</literal> is run for the grub2 case.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
A specific bootloader type may also be explicitly requested by choosing
|
||||||
|
<literal>grub2</literal>, <literal>syslinux</literal>, <literal>uboot</literal> or
|
||||||
|
<literal>zipl</literal>.
|
||||||
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,28 @@ typedef enum {
|
||||||
_OSTREE_FEATURE_YES,
|
_OSTREE_FEATURE_YES,
|
||||||
} _OstreeFeatureSupport;
|
} _OstreeFeatureSupport;
|
||||||
|
|
||||||
|
/* Possible values for the sysroot.bootloader configuration variable */
|
||||||
|
typedef enum {
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_AUTO = 0,
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_NONE,
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_GRUB2,
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_SYSLINUX,
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_UBOOT,
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_ZIPL,
|
||||||
|
/* Non-exhaustive */
|
||||||
|
} OstreeCfgSysrootBootloaderOpt;
|
||||||
|
|
||||||
|
static const char* const CFG_SYSROOT_BOOTLOADER_OPTS_STR[] = {
|
||||||
|
/* This must be kept in the same order as the enum */
|
||||||
|
"auto",
|
||||||
|
"none",
|
||||||
|
"grub2",
|
||||||
|
"syslinux",
|
||||||
|
"uboot",
|
||||||
|
"zipl",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OstreeRepo:
|
* OstreeRepo:
|
||||||
*
|
*
|
||||||
|
|
@ -193,7 +215,7 @@ struct OstreeRepo {
|
||||||
guint64 payload_link_threshold;
|
guint64 payload_link_threshold;
|
||||||
gint fs_support_reflink; /* The underlying filesystem has support for ioctl (FICLONE..) */
|
gint fs_support_reflink; /* The underlying filesystem has support for ioctl (FICLONE..) */
|
||||||
gchar **repo_finders;
|
gchar **repo_finders;
|
||||||
gchar *bootloader; /* Configure which bootloader to use. */
|
OstreeCfgSysrootBootloaderOpt bootloader; /* Configure which bootloader to use. */
|
||||||
|
|
||||||
OstreeRepo *parent_repo;
|
OstreeRepo *parent_repo;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1048,7 +1048,6 @@ ostree_repo_finalize (GObject *object)
|
||||||
g_mutex_clear (&self->txn_lock);
|
g_mutex_clear (&self->txn_lock);
|
||||||
g_free (self->collection_id);
|
g_free (self->collection_id);
|
||||||
g_strfreev (self->repo_finders);
|
g_strfreev (self->repo_finders);
|
||||||
g_free (self->bootloader);
|
|
||||||
|
|
||||||
g_clear_pointer (&self->remotes, g_hash_table_destroy);
|
g_clear_pointer (&self->remotes, g_hash_table_destroy);
|
||||||
g_mutex_clear (&self->remotes_lock);
|
g_mutex_clear (&self->remotes_lock);
|
||||||
|
|
@ -3186,7 +3185,7 @@ reload_sysroot_config (OstreeRepo *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
{ g_autofree char *bootloader = NULL;
|
g_autofree char *bootloader = NULL;
|
||||||
|
|
||||||
if (!ot_keyfile_get_value_with_default_group_optional (self->config, "sysroot",
|
if (!ot_keyfile_get_value_with_default_group_optional (self->config, "sysroot",
|
||||||
"bootloader", "auto",
|
"bootloader", "auto",
|
||||||
|
|
@ -3197,17 +3196,17 @@ reload_sysroot_config (OstreeRepo *self,
|
||||||
* binary "x" in /usr/lib/ostree/bootloaders/x). See:
|
* binary "x" in /usr/lib/ostree/bootloaders/x). See:
|
||||||
* https://github.com/ostreedev/ostree/issues/1719
|
* https://github.com/ostreedev/ostree/issues/1719
|
||||||
* https://github.com/ostreedev/ostree/issues/1801
|
* https://github.com/ostreedev/ostree/issues/1801
|
||||||
* Also, dedup these strings with the bootloader implementations
|
|
||||||
*/
|
*/
|
||||||
if (!(g_str_equal (bootloader, "auto") || g_str_equal (bootloader, "none")
|
for (int i = 0; CFG_SYSROOT_BOOTLOADER_OPTS_STR[i]; i++)
|
||||||
|| g_str_equal (bootloader, "zipl")))
|
{
|
||||||
return glnx_throw (error, "Invalid bootloader configuration: '%s'", bootloader);
|
if (g_str_equal (bootloader, CFG_SYSROOT_BOOTLOADER_OPTS_STR[i]))
|
||||||
|
{
|
||||||
g_free (self->bootloader);
|
self->bootloader = (OstreeCfgSysrootBootloaderOpt) i;
|
||||||
self->bootloader = g_steal_pointer (&bootloader);
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return glnx_throw (error, "Invalid bootloader configuration: '%s'", bootloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -6323,7 +6322,7 @@ ostree_repo_get_default_repo_finders (OstreeRepo *self)
|
||||||
* Get the bootloader configured. See the documentation for the
|
* Get the bootloader configured. See the documentation for the
|
||||||
* "sysroot.bootloader" config key.
|
* "sysroot.bootloader" config key.
|
||||||
*
|
*
|
||||||
* Returns: bootloader configuration for the sysroot
|
* Returns: (transfer none): bootloader configuration for the sysroot
|
||||||
* Since: 2019.2
|
* Since: 2019.2
|
||||||
*/
|
*/
|
||||||
const gchar *
|
const gchar *
|
||||||
|
|
@ -6331,7 +6330,7 @@ ostree_repo_get_bootloader (OstreeRepo *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (OSTREE_IS_REPO (self), NULL);
|
g_return_val_if_fail (OSTREE_IS_REPO (self), NULL);
|
||||||
|
|
||||||
return self->bootloader;
|
return CFG_SYSROOT_BOOTLOADER_OPTS_STR[self->bootloader];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@
|
||||||
#include "ostree-repo-private.h"
|
#include "ostree-repo-private.h"
|
||||||
#include "ostree-sysroot-private.h"
|
#include "ostree-sysroot-private.h"
|
||||||
#include "ostree-sepolicy-private.h"
|
#include "ostree-sepolicy-private.h"
|
||||||
#include "ostree-bootloader-zipl.h"
|
|
||||||
#include "ostree-deployment-private.h"
|
#include "ostree-deployment-private.h"
|
||||||
#include "ostree-core-private.h"
|
#include "ostree-core-private.h"
|
||||||
#include "ostree-linuxfsutil.h"
|
#include "ostree-linuxfsutil.h"
|
||||||
|
|
@ -2561,7 +2560,6 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
|
||||||
gboolean bootloader_is_atomic = FALSE;
|
gboolean bootloader_is_atomic = FALSE;
|
||||||
SyncStats syncstats = { 0, };
|
SyncStats syncstats = { 0, };
|
||||||
g_autoptr(OstreeBootloader) bootloader = NULL;
|
g_autoptr(OstreeBootloader) bootloader = NULL;
|
||||||
const char *bootloader_config = NULL;
|
|
||||||
if (!requires_new_bootversion)
|
if (!requires_new_bootversion)
|
||||||
{
|
{
|
||||||
if (!create_new_bootlinks (self, self->bootversion,
|
if (!create_new_bootlinks (self, self->bootversion,
|
||||||
|
|
@ -2593,29 +2591,8 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
|
||||||
return glnx_throw_errno_prefix (error, "Remounting /boot read-write");
|
return glnx_throw_errno_prefix (error, "Remounting /boot read-write");
|
||||||
}
|
}
|
||||||
|
|
||||||
OstreeRepo *repo = ostree_sysroot_repo (self);
|
|
||||||
|
|
||||||
bootloader_config = ostree_repo_get_bootloader (repo);
|
|
||||||
|
|
||||||
g_debug ("Using bootloader configuration: %s", bootloader_config);
|
|
||||||
|
|
||||||
if (g_str_equal (bootloader_config, "auto"))
|
|
||||||
{
|
|
||||||
if (!_ostree_sysroot_query_bootloader (self, &bootloader, cancellable, error))
|
if (!_ostree_sysroot_query_bootloader (self, &bootloader, cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
else if (g_str_equal (bootloader_config, "none"))
|
|
||||||
{
|
|
||||||
/* No bootloader specified; do not query bootloaders to run. */
|
|
||||||
}
|
|
||||||
else if (g_str_equal (bootloader_config, "zipl"))
|
|
||||||
{
|
|
||||||
/* Because we do not mark zipl as active by default, lets creating one here,
|
|
||||||
* which is basically the same what _ostree_sysroot_query_bootloader() does
|
|
||||||
* for other bootloaders if being activated.
|
|
||||||
* */
|
|
||||||
bootloader = (OstreeBootloader*) _ostree_bootloader_zipl_new (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
bootloader_is_atomic = bootloader != NULL && _ostree_bootloader_is_atomic (bootloader);
|
bootloader_is_atomic = bootloader != NULL && _ostree_bootloader_is_atomic (bootloader);
|
||||||
|
|
||||||
|
|
@ -2646,6 +2623,7 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
|
||||||
(bootloader_is_atomic ? "Transaction complete" : "Bootloader updated"),
|
(bootloader_is_atomic ? "Transaction complete" : "Bootloader updated"),
|
||||||
requires_new_bootversion ? "yes" : "no",
|
requires_new_bootversion ? "yes" : "no",
|
||||||
new_deployments->len - self->deployments->len);
|
new_deployments->len - self->deployments->len);
|
||||||
|
const gchar *bootloader_config = ostree_repo_get_bootloader (ostree_sysroot_repo (self));
|
||||||
ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_COMPLETE_ID),
|
ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_COMPLETE_ID),
|
||||||
"MESSAGE=%s", msg,
|
"MESSAGE=%s", msg,
|
||||||
"OSTREE_BOOTLOADER=%s", bootloader ? _ostree_bootloader_get_name (bootloader) : "none",
|
"OSTREE_BOOTLOADER=%s", bootloader ? _ostree_bootloader_get_name (bootloader) : "none",
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#include "ostree-bootloader-uboot.h"
|
#include "ostree-bootloader-uboot.h"
|
||||||
#include "ostree-bootloader-syslinux.h"
|
#include "ostree-bootloader-syslinux.h"
|
||||||
#include "ostree-bootloader-grub2.h"
|
#include "ostree-bootloader-grub2.h"
|
||||||
|
#include "ostree-bootloader-zipl.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:ostree-sysroot
|
* SECTION:ostree-sysroot
|
||||||
|
|
@ -1324,6 +1325,34 @@ ostree_sysroot_repo (OstreeSysroot *self)
|
||||||
return self->repo;
|
return self->repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static OstreeBootloader*
|
||||||
|
_ostree_sysroot_new_bootloader_by_type (
|
||||||
|
OstreeSysroot *sysroot,
|
||||||
|
OstreeCfgSysrootBootloaderOpt bl_type)
|
||||||
|
{
|
||||||
|
switch (bl_type)
|
||||||
|
{
|
||||||
|
case CFG_SYSROOT_BOOTLOADER_OPT_NONE:
|
||||||
|
/* No bootloader specified; do not query bootloaders to run. */
|
||||||
|
return NULL;
|
||||||
|
case CFG_SYSROOT_BOOTLOADER_OPT_GRUB2:
|
||||||
|
return (OstreeBootloader*) _ostree_bootloader_grub2_new (sysroot);
|
||||||
|
case CFG_SYSROOT_BOOTLOADER_OPT_SYSLINUX:
|
||||||
|
return (OstreeBootloader*) _ostree_bootloader_syslinux_new (sysroot);
|
||||||
|
case CFG_SYSROOT_BOOTLOADER_OPT_UBOOT:
|
||||||
|
return (OstreeBootloader*) _ostree_bootloader_uboot_new (sysroot);
|
||||||
|
case CFG_SYSROOT_BOOTLOADER_OPT_ZIPL:
|
||||||
|
/* We never consider zipl as active by default, so it can only be created
|
||||||
|
* if it's explicitly requested in the config */
|
||||||
|
return (OstreeBootloader*) _ostree_bootloader_zipl_new (sysroot);
|
||||||
|
case CFG_SYSROOT_BOOTLOADER_OPT_AUTO:
|
||||||
|
/* "auto" is handled by ostree_sysroot_query_bootloader so we should
|
||||||
|
* never get here: Fallthrough */
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ostree_sysroot_query_bootloader:
|
* ostree_sysroot_query_bootloader:
|
||||||
* @sysroot: Sysroot
|
* @sysroot: Sysroot
|
||||||
|
|
@ -1337,32 +1366,38 @@ _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean is_active;
|
OstreeRepo *repo = ostree_sysroot_repo (sysroot);
|
||||||
g_autoptr(OstreeBootloader) ret_loader =
|
OstreeCfgSysrootBootloaderOpt bootloader_config = repo->bootloader;
|
||||||
(OstreeBootloader*)_ostree_bootloader_syslinux_new (sysroot);
|
|
||||||
if (!_ostree_bootloader_query (ret_loader, &is_active,
|
|
||||||
cancellable, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!is_active)
|
g_debug ("Using bootloader configuration: %s",
|
||||||
{
|
CFG_SYSROOT_BOOTLOADER_OPTS_STR[bootloader_config]);
|
||||||
g_object_unref (ret_loader);
|
|
||||||
ret_loader = (OstreeBootloader*)_ostree_bootloader_grub2_new (sysroot);
|
|
||||||
if (!_ostree_bootloader_query (ret_loader, &is_active,
|
|
||||||
cancellable, error))
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (!is_active)
|
|
||||||
{
|
|
||||||
g_object_unref (ret_loader);
|
|
||||||
ret_loader = (OstreeBootloader*)_ostree_bootloader_uboot_new (sysroot);
|
|
||||||
if (!_ostree_bootloader_query (ret_loader, &is_active, cancellable, error))
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (!is_active)
|
|
||||||
g_clear_object (&ret_loader);
|
|
||||||
|
|
||||||
ot_transfer_out_value(out_bootloader, &ret_loader);
|
g_autoptr(OstreeBootloader) ret_loader = NULL;
|
||||||
|
if (bootloader_config == CFG_SYSROOT_BOOTLOADER_OPT_AUTO)
|
||||||
|
{
|
||||||
|
OstreeCfgSysrootBootloaderOpt probe[] = {
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_SYSLINUX,
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_GRUB2,
|
||||||
|
CFG_SYSROOT_BOOTLOADER_OPT_UBOOT,
|
||||||
|
};
|
||||||
|
for (int i = 0; i < G_N_ELEMENTS (probe); i++)
|
||||||
|
{
|
||||||
|
g_autoptr(OstreeBootloader) bl = _ostree_sysroot_new_bootloader_by_type (
|
||||||
|
sysroot, probe[i]);
|
||||||
|
gboolean is_active = FALSE;
|
||||||
|
if (!_ostree_bootloader_query (bl, &is_active, cancellable, error))
|
||||||
|
return FALSE;
|
||||||
|
if (is_active)
|
||||||
|
{
|
||||||
|
ret_loader = g_steal_pointer (&bl);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret_loader = _ostree_sysroot_new_bootloader_by_type (sysroot, bootloader_config);
|
||||||
|
|
||||||
|
ot_transfer_out_value (out_bootloader, &ret_loader)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,58 +20,59 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
|
||||||
sysroot = ''
|
|
||||||
else:
|
|
||||||
sysroot = sys.argv[1]
|
|
||||||
|
|
||||||
bootloader = sys.argv[2]
|
def main(argv):
|
||||||
loaderpath = sysroot + '/boot/loader/entries'
|
_, sysroot, bootloader = argv
|
||||||
syslinuxpath = sysroot + '/boot/syslinux/syslinux.cfg'
|
|
||||||
|
|
||||||
if bootloader == "grub2":
|
if bootloader == "grub2":
|
||||||
sys.stdout.write('GRUB2 configuration validation not implemented.\n')
|
sys.stdout.write('GRUB2 configuration validation not implemented.\n')
|
||||||
sys.exit(0)
|
return 0
|
||||||
|
else:
|
||||||
|
return validate_syslinux(sysroot)
|
||||||
|
|
||||||
|
|
||||||
def fatal(msg):
|
def fatal(msg):
|
||||||
sys.stderr.write(msg)
|
sys.stderr.write(msg)
|
||||||
sys.stderr.write('\n')
|
sys.stderr.write('\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def entry_get_version(entry):
|
|
||||||
return int(entry['version'])
|
|
||||||
|
|
||||||
def get_ostree_option(optionstring):
|
def get_ostree_option(optionstring):
|
||||||
for o in optionstring.split():
|
for o in optionstring.split():
|
||||||
if o.startswith('ostree='):
|
if o.startswith('ostree='):
|
||||||
return o[8:]
|
return o[8:]
|
||||||
raise ValueError('ostree= not found')
|
raise ValueError('ostree= not found in %r' % (optionstring,))
|
||||||
|
|
||||||
entries = []
|
|
||||||
syslinux_entries = []
|
|
||||||
|
|
||||||
# Parse loader configs
|
def parse_loader_configs(sysroot):
|
||||||
for fname in os.listdir(loaderpath):
|
loaderpath = sysroot + '/boot/loader/entries'
|
||||||
|
entries = []
|
||||||
|
|
||||||
|
# Parse loader configs
|
||||||
|
for fname in os.listdir(loaderpath):
|
||||||
path = os.path.join(loaderpath, fname)
|
path = os.path.join(loaderpath, fname)
|
||||||
with open(path) as f:
|
|
||||||
entry = {}
|
entry = {}
|
||||||
|
with open(path) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if (line == '' or line.startswith('#')):
|
if (line == '' or line.startswith('#')):
|
||||||
continue
|
continue
|
||||||
s = line.find(' ')
|
k, v = line.split(' ', 1)
|
||||||
assert s > 0
|
|
||||||
k = line[0:s]
|
|
||||||
v = line[s+1:]
|
|
||||||
entry[k] = v
|
entry[k] = v
|
||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
entries.sort(key=entry_get_version, reverse=True)
|
entries.sort(key=lambda e: int(e['version']), reverse=True)
|
||||||
|
return entries
|
||||||
|
|
||||||
# Parse SYSLINUX config
|
|
||||||
with open(syslinuxpath) as f:
|
def validate_syslinux(sysroot):
|
||||||
in_ostree_config = False
|
syslinuxpath = sysroot + '/boot/syslinux/syslinux.cfg'
|
||||||
|
|
||||||
|
entries = parse_loader_configs(sysroot)
|
||||||
|
syslinux_entries = []
|
||||||
|
|
||||||
|
# Parse SYSLINUX config
|
||||||
|
with open(syslinuxpath) as f:
|
||||||
syslinux_entry = None
|
syslinux_entry = None
|
||||||
syslinux_default = None
|
|
||||||
for line in f:
|
for line in f:
|
||||||
try:
|
try:
|
||||||
k, v = line.strip().split(" ", 1)
|
k, v = line.strip().split(" ", 1)
|
||||||
|
|
@ -94,15 +95,11 @@ with open(syslinuxpath) as f:
|
||||||
if syslinux_entry is not None:
|
if syslinux_entry is not None:
|
||||||
syslinux_entries.append(syslinux_entry)
|
syslinux_entries.append(syslinux_entry)
|
||||||
|
|
||||||
if len(entries) != len(syslinux_entries):
|
if len(entries) != len(syslinux_entries):
|
||||||
fatal("Found {0} loader entries, but {1} SYSLINUX entries\n".format(len(entries), len(syslinux_entries)))
|
fatal("Found {0} loader entries, but {1} SYSLINUX entries\n".format(
|
||||||
|
len(entries), len(syslinux_entries)))
|
||||||
|
|
||||||
|
def assert_key_same_file(a, b, key):
|
||||||
def assert_eq(a, b):
|
|
||||||
assert a == b, "%r == %r" % (a, b)
|
|
||||||
|
|
||||||
|
|
||||||
def assert_key_same_file(a, b, key):
|
|
||||||
aval = a[key]
|
aval = a[key]
|
||||||
bval = b[key]
|
bval = b[key]
|
||||||
sys.stderr.write("aval: %r\nbval: %r\n" % (aval, bval))
|
sys.stderr.write("aval: %r\nbval: %r\n" % (aval, bval))
|
||||||
|
|
@ -119,14 +116,22 @@ def assert_key_same_file(a, b, key):
|
||||||
assert_eq(entry, s1)
|
assert_eq(entry, s1)
|
||||||
assert_eq(entry, s2)
|
assert_eq(entry, s2)
|
||||||
|
|
||||||
|
for i, (entry, syslinuxentry) in enumerate(zip(entries, syslinux_entries)):
|
||||||
for i,(entry,syslinuxentry) in enumerate(zip(entries, syslinux_entries)):
|
|
||||||
assert_key_same_file(entry, syslinuxentry, 'linux')
|
assert_key_same_file(entry, syslinuxentry, 'linux')
|
||||||
assert_key_same_file(entry, syslinuxentry, 'initrd')
|
assert_key_same_file(entry, syslinuxentry, 'initrd')
|
||||||
entry_ostree = get_ostree_option(entry['options'])
|
entry_ostree = get_ostree_option(entry['options'])
|
||||||
syslinux_ostree = get_ostree_option(syslinuxentry['options'])
|
syslinux_ostree = get_ostree_option(syslinuxentry['options'])
|
||||||
if entry_ostree != syslinux_ostree:
|
if entry_ostree != syslinux_ostree:
|
||||||
fatal("Mismatch on ostree option: {0} != {1}".format(entry_ostree, syslinux_ostree))
|
fatal("Mismatch on ostree option: {0} != {1}".format(
|
||||||
|
entry_ostree, syslinux_ostree))
|
||||||
|
|
||||||
sys.stdout.write('SYSLINUX configuration validated\n')
|
sys.stdout.write('SYSLINUX configuration validated\n')
|
||||||
sys.exit(0)
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def assert_eq(a, b):
|
||||||
|
assert a == b, "%r == %r" % (a, b)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main(sys.argv))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue