From b669633d637e1c48dbfa5323344eeede0c3c25fa Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 12 Feb 2013 10:47:52 -0500 Subject: [PATCH] gummiboot-builder.py: Handle the case where there's no /etc/machine-id. Bug hit by add^_ in IRC when installing from the livecd, as there's no /mnt/etc/machine-id --- .../boot/loader/gummiboot/gummiboot-builder.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/system/boot/loader/gummiboot/gummiboot-builder.py b/modules/system/boot/loader/gummiboot/gummiboot-builder.py index d490c4c8e78..0373695d363 100644 --- a/modules/system/boot/loader/gummiboot/gummiboot-builder.py +++ b/modules/system/boot/loader/gummiboot/gummiboot-builder.py @@ -6,6 +6,7 @@ import errno import subprocess import glob import tempfile +import errno def copy_if_not_exists(source, dest): known_paths.append(dest) @@ -26,7 +27,7 @@ def write_entry(generation, kernel, initrd): with open(tmp_path, 'w') as f: print >> f, "title NixOS" print >> f, "version Generation %d" % (generation) - print >> f, "machine-id %s" % (machine_id) + if machine_id is not None: print >> f, "machine-id %s" % (machine_id) print >> f, "linux %s" % (kernel) print >> f, "initrd %s" % (initrd) print >> f, "options %s" % (kernel_params) @@ -143,8 +144,14 @@ args = parser.parse_args() known_paths = [] mkdir_p("@efiSysMountPoint@/efi/nixos") mkdir_p("@efiSysMountPoint@/loader/entries") -with open("/etc/machine-id") as machine_file: - machine_id = machine_file.readlines()[0] +try: + with open("/etc/machine-id") as machine_file: + machine_id = machine_file.readlines()[0] +except IOError as e: + if e.errno != errno.ENOENT: + raise + machine_id = None + gens = get_generations("system") for gen in gens: add_entry(gen)