diff options
Diffstat (limited to '')
-rwxr-xr-x | bin/sbuild-qemu-boot | 2 | ||||
-rwxr-xr-x | bin/sbuild-qemu-update | 16 | ||||
-rw-r--r-- | lib/Sbuild/Build.pm | 2 | ||||
-rw-r--r-- | lib/Sbuild/ChrootUnshare.pm | 4 |
4 files changed, 19 insertions, 5 deletions
diff --git a/bin/sbuild-qemu-boot b/bin/sbuild-qemu-boot index 1fd93ae..7a411e0 100755 --- a/bin/sbuild-qemu-boot +++ b/bin/sbuild-qemu-boot @@ -274,7 +274,7 @@ def main(): '-fw_cfg', f'name=opt/sbuild-qemu/tty-cols,string={termsize.columns}', ]) - args.append(image) + args.extend(['-drive', f'file={image},discard=unmap,if=virtio']) print(' '.join(str(a) for a in args)) if parsed_args.noexec: diff --git a/bin/sbuild-qemu-update b/bin/sbuild-qemu-update index 6e08274..2de7ab5 100755 --- a/bin/sbuild-qemu-update +++ b/bin/sbuild-qemu-update @@ -180,6 +180,12 @@ def update_interaction(child, quiet): child.expect('root@host:~# ') child.sendline('sync') child.expect('root@host:~# ') + child.sendline('mount -o remount,discard /') + child.expect('root@host:~# ') + child.sendline('fstrim /') + child.expect('root@host:~# ') + child.sendline('sync') + child.expect('root@host:~# ') # Don't recall what issue this solves, but it solves it child.sendline('sleep 1') child.expect('root@host:~# ') @@ -257,7 +263,7 @@ def main(): '-m', '1024', '-smp', '1', '-nographic', - image, + '-drive', f'file={image},discard=unmap,if=virtio', ]) if parsed_args.extra_args: args.extend(parsed_args.extra_args) @@ -278,6 +284,14 @@ def main(): except pexpect.TIMEOUT: print("Update timed out. Consider using --timeout.", file=sys.stderr) child.terminate() + child.wait() + + try: + subprocess.check_call(["qemu-img", "convert", "-O", "qcow2", image, f"{image}.tmp"]) + except subprocess.CalledProcessError as err: + print(f"Error converting image: {err}", file=sys.stderr) + return + os.replace(f"{image}.tmp", image) if __name__ == '__main__': diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm index 7a23a85..0deabbd 100644 --- a/lib/Sbuild/Build.pm +++ b/lib/Sbuild/Build.pm @@ -827,7 +827,7 @@ sub run_fetch_install_packages { $self->set('Install End Time', $self->get('Install Start Time')); my @coredeps = @{$self->get_conf('CORE_DEPENDS')}; if ($self->get_conf('CHROOT_MODE') eq 'unshare') { - push(@coredeps, 'dumb-init'); + push(@coredeps, 'dumb-init:native'); } if ($self->get('Host Arch') ne $self->get('Build Arch')) { my $crosscoredeps = $self->get_conf('CROSSBUILD_CORE_DEPENDS'); diff --git a/lib/Sbuild/ChrootUnshare.pm b/lib/Sbuild/ChrootUnshare.pm index 81e90ca..f4b9c41 100644 --- a/lib/Sbuild/ChrootUnshare.pm +++ b/lib/Sbuild/ChrootUnshare.pm @@ -407,7 +407,7 @@ sub useradd { my $rootdir = $self->get('Session ID'); my @idmap = read_subuid_subgid; my @unshare_cmd = get_unshare_cmd({IDMAP => \@idmap}); - return system(@unshare_cmd, "/usr/sbin/useradd", "--root", $rootdir, @args); + return system(@unshare_cmd, "/usr/sbin/useradd", "--no-log-init", "--prefix", $rootdir, @args); } sub groupadd { @@ -416,7 +416,7 @@ sub groupadd { my $rootdir = $self->get('Session ID'); my @idmap = read_subuid_subgid; my @unshare_cmd = get_unshare_cmd({IDMAP => \@idmap}); - return system(@unshare_cmd, "/usr/sbin/groupadd", "--root", $rootdir, @args); + return system(@unshare_cmd, "/usr/sbin/groupadd", "--prefix", $rootdir, @args); } 1; |