Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ __ https://github.com/Truelite/nspawn-runner/issues/3
* ``nspawn_runner_chroot_suite``: suite to use for debootstrap
* ``nspawn_runner_maint_recreate``: set to true to always recreate the chroot
during maintenance. See `issue #4`__ for details.
* ``nspawn_runner_mirror``: mirror to use for debootstrap

__ https://github.com/Truelite/nspawn-runner/issues/4

Expand Down
16 changes: 9 additions & 7 deletions nspawn-runner
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class Chroot:

# Extract what we need from the variables
res: Dict[str, Any] = {}
for var in ("chroot_suite", "maint_recreate"):
for var in ("chroot_suite", "maint_recreate", "mirror"):
key = f"nspawn_runner_{var}"
if key not in pb_vars:
continue
Expand Down Expand Up @@ -514,36 +514,37 @@ class Chroot:
if suite is None:
log.error("%s: chroot_suite not found in playbook, and chroot does not exist", self.image_name)
return
self.create(suite)
mirror = config.get("mirror") or ""
self.create(suite, mirror)
self.run_playbook()


class OverlayChroot(Chroot):
"""
Chroot implemenation for traditional filesystems
"""
def create(self, suite: str):
def create(self, suite: str, mirror: str):
cmd = []
if EATMYDATA is not None:
cmd.append(EATMYDATA)
cmd += ["debootstrap", "--variant=minbase", "--include=git,dbus,systemd,python3",
suite, self.chroot_dir]
suite, self.chroot_dir, mirror]
run_cmd(cmd)


class BtrfsChroot(Chroot):
"""
Chroot implementation for btrfs fileystems
"""
def create(self, suite: str):
def create(self, suite: str, mirror: str):
# Create subvolume for chroot
run_cmd(["btrfs", "subvolume", "create", self.chroot_dir])

cmd = []
if EATMYDATA is not None:
cmd.append(EATMYDATA)
cmd += ["debootstrap", "--variant=minbase", "--include=git,dbus,systemd,python3",
suite, self.chroot_dir]
suite, self.chroot_dir, mirror]
run_cmd(cmd)

def _is_subvolume(self) -> bool:
Expand Down Expand Up @@ -746,7 +747,8 @@ class ChrootCreate(ChrootMixin, SetupMixin, Command):
suite = config.get("chroot_suite")
if suite is None:
suite = self.FALLBACK_SUITE
self.chroot.create(suite)
mirror = config.get("mirror") or ""
self.chroot.create(suite, mirror)
playbook = self.chroot.config_file_path()
if playbook is not None:
self.chroot.run_playbook(playbook)
Expand Down