From: Lennart Poettering Date: Wed, 7 Dec 2016 11:59:36 +0000 (+0100) Subject: mkosi: automatically reset /etc/machine-id to the empty file X-Git-Tag: v2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F39%2Fhead;p=thirdparty%2Fmkosi.git mkosi: automatically reset /etc/machine-id to the empty file --- diff --git a/mkosi b/mkosi index 0c3de8504..785686df0 100755 --- a/mkosi +++ b/mkosi @@ -761,6 +761,22 @@ def install_distribution(args, workspace, run_build_script): install[args.distribution](args, workspace, run_build_script) +def reset_machine_id(args, workspace): + + # Make /etc/machine-id an empty file. This way, on the next boot + # is either initialized and commited (if /etc is writable) or the + # image runs with a transient machine ID, that changes on each + # boot (if the image is read-only). + + print_step("Resetting machine ID...") + + machine_id = os.path.join(workspace, 'root', 'etc/machine-id') + + os.unlink(machine_id) + open(machine_id, "w+b").close() + + print_step("Resetting machine ID completed.") + def set_root_password(args, workspace): "Set the root account password, or just delete it so it's easy to log in" if args.password == '': @@ -1908,6 +1924,7 @@ def build_image(args, workspace, run_build_script): prepare_tree(args, workspace.name, run_build_script) mount_cache(args, workspace.name) install_distribution(args, workspace.name, run_build_script) + reset_machine_id(args, workspace.name) install_boot_loader(args, workspace.name) install_extra_trees(args, workspace.name) install_build_src(args, workspace.name, run_build_script)