From fee0969c6b069a620174238e3c0cfa06af12e4a8 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Sun, 8 Jan 2017 10:30:43 +0100 Subject: [PATCH] prepare: Check if file exists before removing it --- modules/prepare/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/prepare/main.py b/modules/prepare/main.py index dfeda02..dead861 100644 --- a/modules/prepare/main.py +++ b/modules/prepare/main.py @@ -45,10 +45,10 @@ def run(): boot_path = os.path.join(install_path, "boot", "vmlinuz-linux") shutil.copyfile("/run/archiso/bootmnt/liri/boot/x86_64/vmlinuz", boot_path) - sudoers_livemedia_path = os.path.join(install_path, "etc", "sudoers.d", "00-livemedia") - sudoers_installer_path = os.path.join(install_path, "etc", "sudoers.d", "10-installer") - os.unlink(sudoers_livemedia_path) - os.unlink(sudoers_installer_path) + for sudoers_filename in ("00-livemedia", "10-installer"): + sudoers_path = os.path.join(install_path, "etc", "sudoers.d", sudoers_filename) + if os.path.exists(sudoers_path): + os.unlink(sudoers_path) os_release = os.path.join(install_path, "usr", "lib", "os-release") try: