From 682d3b087f465654306a8cf5bf5d1eaf4afdea28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20M=C3=BCller?= Date: Sun, 17 Oct 2021 16:46:32 +0200 Subject: [PATCH] [postcfg] deal with symlinks --- src/modules/postcfg/main.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/postcfg/main.py b/src/modules/postcfg/main.py index 013040380..8f5f3396d 100644 --- a/src/modules/postcfg/main.py +++ b/src/modules/postcfg/main.py @@ -3,7 +3,7 @@ # # === This file is part of Calamares - === # -# Copyright 2014 - 2019, Philip Müller +# Copyright 2014 - 2021, Philip Müller # Copyright 2016, Artoo # # Calamares is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ import libcalamares import subprocess +import os from shutil import copy2 from distutils.dir_util import copy_tree @@ -50,6 +51,13 @@ class ConfigController: def terminate(self, proc): target_env_call(['killall', '-9', proc]) + def remove_symlink(self, target): + for root, dirs, files in os.walk("/" + target): + for filename in files: + path = os.path.join(root, filename) + if os.path.islink(path): + os.unlink(path) + def copy_file(self, file): if exists("/" + file): copy2("/" + file, join(self.root, file)) @@ -96,9 +104,8 @@ class ConfigController: elif cpu_ucode == "GenuineIntel": self.remove_pkg("amd-ucode", "boot/amd-ucode.img") - # Remove calamares - self.remove_pkg("calamares", "usr/bin/calamares") - self.remove_pkg("calamares-git", "usr/bin/calamares") + # Remove symlinks before copying + self.remove_symlink('root') # Copy skel to root self.copy_folder('etc/skel', 'root') @@ -133,6 +140,10 @@ class ConfigController: self.rmdir("opt/mhwd") self.umount("etc/resolv.conf") + # Remove calamares + self.remove_pkg("calamares", "usr/bin/calamares") + self.remove_pkg("calamares-git", "usr/bin/calamares") + return None