chroot: detect existing root mounts better
This commit is contained in:
parent
4d03f238bb
commit
9c77e2ffe3
2 changed files with 4 additions and 5 deletions
|
@ -2,12 +2,11 @@ import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from shutil import rmtree
|
|
||||||
from typing import ClassVar
|
from typing import ClassVar
|
||||||
|
|
||||||
from constants import Arch
|
from constants import Arch
|
||||||
from exec.cmd import run_root_cmd
|
from exec.cmd import run_root_cmd
|
||||||
from exec.file import makedir, root_makedir
|
from exec.file import makedir, remove_file, root_makedir
|
||||||
from config.state import config
|
from config.state import config
|
||||||
|
|
||||||
from .abstract import Chroot, get_chroot
|
from .abstract import Chroot, get_chroot
|
||||||
|
@ -19,10 +18,10 @@ class BaseChroot(Chroot):
|
||||||
_copy_base: ClassVar[bool] = False
|
_copy_base: ClassVar[bool] = False
|
||||||
|
|
||||||
def create_rootfs(self, reset, pacman_conf_target, active_previously):
|
def create_rootfs(self, reset, pacman_conf_target, active_previously):
|
||||||
if reset:
|
if reset and os.path.exists(self.path):
|
||||||
logging.info(f'Resetting {self.name}')
|
logging.info(f'Resetting {self.name}')
|
||||||
for dir in glob(os.path.join(self.path, '*')):
|
for dir in glob(os.path.join(self.path, '*')):
|
||||||
rmtree(dir)
|
remove_file(dir, recursive=True)
|
||||||
makedir(config.get_path('chroots'))
|
makedir(config.get_path('chroots'))
|
||||||
root_makedir(self.get_path())
|
root_makedir(self.get_path())
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DeviceChroot(BuildChroot):
|
||||||
really_active.append(mnt)
|
really_active.append(mnt)
|
||||||
if really_active:
|
if really_active:
|
||||||
raise Exception(f'{self.name}: Chroot has submounts active: {really_active}')
|
raise Exception(f'{self.name}: Chroot has submounts active: {really_active}')
|
||||||
if os.path.ismount(self.path):
|
if os.path.ismount(self.path) or check_findmnt(self.path):
|
||||||
raise Exception(f'{self.name}: There is already something mounted at {self.path}, not mounting over it.')
|
raise Exception(f'{self.name}: There is already something mounted at {self.path}, not mounting over it.')
|
||||||
if os.path.exists(os.path.join(self.path, 'usr/bin')):
|
if os.path.exists(os.path.join(self.path, 'usr/bin')):
|
||||||
raise Exception(f'{self.name}: {self.path}/usr/bin exists, not mounting over existing rootfs.')
|
raise Exception(f'{self.name}: {self.path}/usr/bin exists, not mounting over existing rootfs.')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue