install: remove /mnt/pmbootstrap at the end

Don't include the /mnt/pmbootstrap directories in the images created
with "pmbootstrap install".

Reviewed-by: Pablo Correa Gómez <ablocorrea@hotmail.com>
Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230806184729.4891-3-ollieparanoid@postmarketos.org%3E
This commit is contained in:
Oliver Smith 2023-08-06 20:43:29 +02:00
parent fdbb8eebb8
commit 0ff6ad481d
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
5 changed files with 58 additions and 1 deletions

40
test/test_chroot_mount.py Normal file
View file

@ -0,0 +1,40 @@
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
""" Test pmb/chroot/mount.py """
import os
import pytest
import sys
import pmb_test # noqa
import pmb.chroot
@pytest.fixture
def args(tmpdir, request):
import pmb.parse
sys.argv = ["pmbootstrap", "init"]
args = pmb.parse.arguments()
args.log = args.work + "/log_testsuite.txt"
pmb.helpers.logging.init(args)
request.addfinalizer(pmb.helpers.logging.logfd.close)
return args
def test_chroot_mount(args):
suffix = "native"
mnt_dir = f"{args.work}/chroot_native/mnt/pmbootstrap"
# Run something in the chroot to have the dirs created
pmb.chroot.root(args, ["true"])
assert os.path.exists(mnt_dir)
assert os.path.exists(f"{mnt_dir}/packages")
# Umount everything, like in pmb.install.install_system_image
pmb.helpers.mount.umount_all(args, f"{args.work}/chroot_{suffix}")
# Remove all /mnt/pmbootstrap dirs
pmb.chroot.remove_mnt_pmbootstrap(args, suffix)
assert not os.path.exists(mnt_dir)
# Run again: it should not crash
pmb.chroot.remove_mnt_pmbootstrap(args, suffix)