From 94245ed6dbc64d32ad8da9788cef29dbe0732e6b Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Tue, 17 Jan 2023 10:26:11 +0100 Subject: Allow arbitrary image sizes --- bin/debvm-create | 20 +++++++++----------- tests/dist-upgrades.sh | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/bin/debvm-create b/bin/debvm-create index 95305a9..c58092c 100755 --- a/bin/debvm-create +++ b/bin/debvm-create @@ -11,7 +11,7 @@ debvm-create - Create a VM image for various Debian releases and architectures =head1 SYNOPSIS -B [B<-a> I] [B<-h> I] [B<-k> F] [B<-o> F] [B<-r> I] [B<-s> ] [B<-z> I] [B<--> I] +B [B<-a> I] [B<-h> I] [B<-k> F] [B<-o> F] [B<-r> I] [B<-s> ] [B<-z> I] [B<--> I] =head1 DESCRIPTION @@ -86,9 +86,10 @@ Without the hook, dependencies will pull the B package as needed, whic =back -=item B<-z> I, B<--size>=I +=item B<-z> I, B<--size>=I -Specify the minimum image size in giga bytes. +Specify the minimum image size as an integer and optional unit (example: 10K is 10*1024). +Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). The resulting image will be grown as a sparse file to this size if necessary. The default is 1 GB. @@ -112,7 +113,7 @@ set -u ARCHITECTURE=$(dpkg --print-architecture) IMAGE=rootfs.ext4 -SIZE=$((1024*1024*1024)) +SIZE=1G SKIP=, SSHKEY= SUITE=unstable @@ -130,7 +131,7 @@ die() { exit 1 } usage() { - die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-o output] [-r release] [-s task] [-z size_in_GB] [-- mmdebstrap options]" + die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-o output] [-r release] [-s task] [-z size] [-- mmdebstrap options]" } usage_error() { echo "error: $*" 1>&2 @@ -157,7 +158,7 @@ opt_release() { SUITE=$1 } opt_size() { - SIZE=$(($1*1024*1024*1024)) + SIZE=$1 } while getopts :a:h:k:o:r:s:z:-: OPTCHAR; do @@ -296,11 +297,8 @@ set -ex mmdebstrap "$@" -IMAGESIZE=$(stat -c %s "$IMAGE") -if test "$IMAGESIZE" -lt "$SIZE"; then - truncate -s "$SIZE" "$IMAGE" - /sbin/resize2fs "$IMAGE" -fi +truncate -s ">$SIZE" "$IMAGE" +/sbin/resize2fs "$IMAGE" /sbin/tune2fs -L debvm -i 0 -O extents,uninit_bg,dir_index,has_journal "$IMAGE" # Must fsck after tune2fs: https://ext4.wiki.kernel.org/index.php/UpgradeToExt4 /sbin/fsck.ext4 -fDp "$IMAGE" diff --git a/tests/dist-upgrades.sh b/tests/dist-upgrades.sh index 177712b..b90f17b 100755 --- a/tests/dist-upgrades.sh +++ b/tests/dist-upgrades.sh @@ -37,7 +37,7 @@ EOF chmod +x upgrade ssh-keygen -f "$SSH_KEYPATH" -N '' -debvm-create -k "$SSH_KEYPATH.pub" -r jessie -z 3 -- --customize-hook="copy-in upgrade /usr/local/bin" +debvm-create --sshkey="$SSH_KEYPATH.pub" -r jessie --size=3G -- --customize-hook="copy-in upgrade /usr/local/bin" SSH_PORT=2222 for RELEASE in stretch buster bullseye bookworm sid; do -- cgit v1.2.3 From efd7142c00191bbe06ff9f6a6995583d97cd4da3 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Tue, 17 Jan 2023 10:28:31 +0100 Subject: Add --skip=autologin --- bin/debvm-create | 10 +++++++++- share/customize-autologin.sh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/debvm-create b/bin/debvm-create index c58092c..8e6ca12 100755 --- a/bin/debvm-create +++ b/bin/debvm-create @@ -63,6 +63,12 @@ The following tasks may be skipped. =over 4 +=item B + +Skips adding a the customize-autologin.sh to B that configures +automatic root login on a serial console and also parses the C kernel +cmdline and passes it as C to B. + =item B skips installing a linux kernel image. @@ -289,7 +295,9 @@ if ! check_skip usrmerge; then set -- --hook-dir=/usr/share/mmdebstrap/hooks/maybe-merged-usr "$@" fi -set -- "--customize-hook=$SHARE_DIR/customize-autologin.sh" "$@" +if ! check_skip autologin; then + set -- "--customize-hook=$SHARE_DIR/customize-autologin.sh" "$@" +fi set -- "$SUITE" "$IMAGE" "$@" diff --git a/share/customize-autologin.sh b/share/customize-autologin.sh index b9a4a8b..4340650 100755 --- a/share/customize-autologin.sh +++ b/share/customize-autologin.sh @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT # # This is a mmdebstrap customize hook that configures automatic root login on a -# serial console. It also parses the debvm.term kernel cmdline and passes it as +# serial console. It also parses the TERM kernel cmdline and passes it as # TERM to agetty. set -eu -- cgit v1.2.3