summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-01-13 09:28:24 +0100
committerHelmut Grohne <helmut@subdivi.de>2023-01-13 09:28:24 +0100
commit51c511409116cea70d61db5c6baf1325b31329c7 (patch)
tree2c21f578989eeaf5746652036e9f6b58a891a8bb
parent8d13bcead097b2052ad300e594d1bfb9183d0164 (diff)
parent59c77e0c3422287651c6e270917bcfa04a6c17a6 (diff)
downloaddebvm-51c511409116cea70d61db5c6baf1325b31329c7.tar.gz
Merge branch main into helmut
Resolve conflicts in debvm-create arising from adding --skip and moving the functionality to be skipped to share/customize-*.sh.
-rwxr-xr-xbin/debvm-create89
-rwxr-xr-xbin/debvm-run19
2 files changed, 87 insertions, 21 deletions
diff --git a/bin/debvm-create b/bin/debvm-create
index d4a291b..59811e8 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<debvm-create> [B<-a> I<architecture>] [B<-h> I<hostname>] [B<-k> F<sshkey>] [B<-m> I<mirror>] [B<-o> F<output>] [B<-p> I<package>] [B<-r> I<release>] [B<-z> I<size_in_GB>] [B<--> I<mmdebstrap options>]
+B<debvm-create> [B<-a> I<architecture>] [B<-h> I<hostname>] [B<-k> F<sshkey>] [B<-m> I<mirror>] [B<-o> F<output>] [B<-p> I<package>] [B<-r> I<release>] [B<-s> <task>] [B<-z> I<size_in_GB>] [B<--> I<mmdebstrap options>]
=head1 DESCRIPTION
@@ -59,13 +59,45 @@ By default, it is written to F<rootfs.ext4>.
Request additional packages to be installed into the virtual machine image.
This option can be specified multiple times and packages can be separated by a comma.
Package recommendations are not honoured.
-If a linux-image is passed here, it will replace the one selected by default.
+If a linux-image is passed here, it will also C<--skip=kernel>.
=item B<-r> I<release>, B<--release>=I<release>
Use the given Debian release.
By default, B<unstable> is being used.
+=item B<-s> I<task>, B<--skip>=I<task>
+
+Skip a particular task or feature.
+The option may be specified multiple times or list multiple tasks to be skipped by separating them with a comma.
+By default, no tasks are skipped.
+The following tasks may be skipped.
+
+=over 4
+
+=item B<kernel>
+
+skips installing a linux kernel image.
+This can be useful to install a custom kernel or to install a different kernel variant than is selected by default.
+
+=item B<packagelists>
+
+reduces the package lists inside the image.
+The B<available> database for B<dpkg> is not created.
+The package lists used by B<apt> are deleted.
+This generally produces a smaller image, but you need to run B<apt update> before installing packages and B<dpkg --set-selections> does not work.
+
+=item B<systemdnetwork>
+
+skips installing B<libnss-resolve> as well as automatic network configuration via B<systemd-networkd>.
+
+=item B<usrmerge>
+
+By default B<debvm> adds a hook to enable merged-/usr without the B<usrmerge> package given a sufficiently recent Debian release.
+Without the hook, dependencies will pull the B<usrmerge> package as needed, which may result in a larger installation.
+
+=back
+
=item B<-z> I<size_in_GB>, B<--size>=I<size_in_GB>
Specify the minimum image size in giga bytes.
@@ -93,6 +125,7 @@ IMAGE=rootfs.ext4
INCLUDE_PACKAGES=init
MIRROR="http://deb.debian.org/debian"
SIZE=$((1024*1024*1024))
+SKIP=,
SSHKEY=
SUITE=unstable
VMNAME=testvm
@@ -125,6 +158,9 @@ opt_hostname() {
opt_mirror() {
MIRROR=$1
}
+opt_skip() {
+ SKIP="$SKIP$1,"
+}
opt_sshkey() {
SSHKEY=$1
}
@@ -133,6 +169,9 @@ opt_output() {
}
opt_package() {
INCLUDE_PACKAGES="$INCLUDE_PACKAGES,$1"
+ case "$1" in linux-image*)
+ opt_skip kernel
+ ;; esac
}
opt_release() {
SUITE=$1
@@ -141,7 +180,7 @@ opt_size() {
SIZE=$(($1*1024*1024*1024))
}
-while getopts :a:h:k:m:o:p:r:z:-: OPTCHAR; do
+while getopts :a:h:k:m:o:p:r:s:z:-: OPTCHAR; do
case "$OPTCHAR" in
a) opt_architecture "$OPTARG" ;;
h) opt_hostname "$OPTARG" ;;
@@ -150,18 +189,19 @@ while getopts :a:h:k:m:o:p:r:z:-: OPTCHAR; do
o) opt_output "$OPTARG" ;;
p) opt_package "$OPTARG" ;;
r) opt_release "$OPTARG" ;;
+ s) opt_skip "$OPTARG" ;;
z) opt_size "$OPTARG" ;;
-)
case "$OPTARG" in
help)
usage
;;
- architecture|hostname|mirror|output|package|release|size|sshkey)
+ architecture|hostname|mirror|output|package|release|size|skip|sshkey)
test "$OPTIND" -gt "$#" && usage_error "missing argument for --$OPTARG"
"opt_$OPTARG" "$(nth_arg "$OPTIND" "$@")"
OPTIND=$((OPTIND+1))
;;
- architecture=*|hostname=*|mirror=*|output=*|package=*|release=*|size=*|sshkey=*)
+ architecture=*|hostname=*|mirror=*|output=*|package=*|release=*|size=*|skip=*|sshkey=*)
"opt_${OPTARG%%=*}" "${OPTARG#*=}"
;;
*)
@@ -186,6 +226,13 @@ if test -n "$SSHKEY" && ! test -f "$SSHKEY"; then
die "error: ssh keyfile '$SSHKEY' not found"
fi
+check_skip() {
+ case "$SKIP" in
+ *",$1,"*) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
case "$SUITE" in
jessie)
DEBVER=8
@@ -241,21 +288,19 @@ case "$ARCHITECTURE" in
;;
esac
-case ",$INCLUDE_PACKAGES," in
- *,linux-image-*)
- ;;
- *)
- INCLUDE_PACKAGES="$INCLUDE_PACKAGES,linux-image$KERNEL_SUFFIX"
- ;;
-esac
+if ! check_skip kernel; then
+ INCLUDE_PACKAGES="$INCLUDE_PACKAGES,linux-image$KERNEL_SUFFIX"
+fi
if test -n "$SSHKEY"; then
INCLUDE_PACKAGES="$INCLUDE_PACKAGES,openssh-server"
fi
-# add a DNS resolver
-INCLUDE_PACKAGES="$INCLUDE_PACKAGES,?exact-name(libnss-resolve)"
-set -- "--customize-hook=$SHARE_DIR/customize-resolved.sh" "$@"
+if ! check_skip systemdnetwork; then
+ # add a DNS resolver
+ INCLUDE_PACKAGES="$INCLUDE_PACKAGES,?exact-name(libnss-resolve)"
+ set -- "--customize-hook=$SHARE_DIR/customize-resolved.sh" "$@"
+fi
# construct mmdebstrap options as $@:
set -- \
@@ -277,8 +322,10 @@ set -- \
# allow password-less root login
set -- '--customize-hook=chroot "$1" passwd --delete root' "$@"
-# dhcp on all network interfaces
-set -- "--customize-hook=$SHARE_DIR/customize-networkd.sh" "$@"
+if ! check_skip systemdnetwork; then
+ # dhcp on all network interfaces
+ set -- "--customize-hook=$SHARE_DIR/customize-networkd.sh" "$@"
+fi
# add ssh key for root
if test -n "$SSHKEY"; then
@@ -288,8 +335,10 @@ if test -n "$SSHKEY"; then
"$@"
fi
-set -- --skip=cleanup/apt/lists "$@"
-set -- "--customize-hook=$SHARE_DIR/customize-dpkgavailable.sh" "$@"
+if ! check_skip packagelists; then
+ set -- --skip=cleanup/apt/lists "$@"
+ set -- "--customize-hook=$SHARE_DIR/customize-dpkgavailable.sh" "$@"
+fi
if test "$DEBVER" -le 8; then
# Use obsolete and expired keys.
@@ -298,7 +347,7 @@ if test "$DEBVER" -le 8; then
set -- --hook-dir=/usr/share/mmdebstrap/hooks/jessie-or-older "$@"
fi
-if test "$DEBVER" -ge 12; then
+if test "$DEBVER" -ge 12 && ! check_skip usrmerge; then
# Avoid the usrmerge package
set -- --hook-dir=/usr/share/mmdebstrap/hooks/merged-usr "$@"
fi
diff --git a/bin/debvm-run b/bin/debvm-run
index 4f7ff44..839653c 100755
--- a/bin/debvm-run
+++ b/bin/debvm-run
@@ -58,6 +58,23 @@ F<rootfs.ext4>, resulting in an ephemeral run.
debvm-run -s 8022 -i rootfs.ext4 -- -snapshot
+=head1 FAQ
+
+=over 8
+
+=item The debvm-run console renders wrong.
+
+Get C<echo $LINES $COLUMNS> from an other terminal and run C<stty rows $LINES cols $COLUMNS> in the console or use ssh.
+Another option is to run C<eval $(resize)>, which is available from the B<xterm> package.
+Also set C<$TERM> to the outside value.
+
+=item How can I kill debvm-run?
+
+The wrapped B<qemu> can be terminated by pressing Ctrl-a x.
+Refer to the B<qemu> manual page for more escape sequences.
+
+=back
+
=head1 LIMITATIONS
Due to the way kernel and bootloader are being extracted before running B<qemu>, one cannot upgrade a kernel and then just reboot.
@@ -132,7 +149,7 @@ while getopts :gi:s:-: OPTCHAR; do
usage_error "missing argument for -$OPTARG"
;;
'?')
- usage_erro "unrecognized option -$OPTARG"
+ usage_error "unrecognized option -$OPTARG"
;;
*)
die "internal error while parsing command options, please report a bug"