From 636fdb3b8fe582d2ba5da2d8b04276335e8451ab Mon Sep 17 00:00:00 2001
From: Helmut Grohne <helmut@subdivi.de>
Date: Fri, 13 Jan 2023 09:38:40 +0100
Subject: debvm-create: remove --package option

This option was meant to make it convenient to add packages, but
mmdebstrap's --include provides the same convenience at more
flexibility. You can provide apt patterns there provided that you use
multiple --include options. So rather than duplicate this functionality
under a different name, just refer to mmdebstrap thus reinforcing the
notion of being a thin wrapper.

This also removes the convenience of overriding the kernel image. You
need to use --skip=kernel when passing --include=linux-image-something
to mmdebstrap now. This implements "explicit is better than implicit".
---
 bin/debvm-create         | 25 ++++++-------------------
 useraddhook/customize.sh |  2 +-
 2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/bin/debvm-create b/bin/debvm-create
index 59811e8..b34399b 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<-s> <task>] [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<-r> I<release>] [B<-s> <task>] [B<-z> I<size_in_GB>] [B<--> I<mmdebstrap options>]
 
 =head1 DESCRIPTION
 
@@ -54,13 +54,6 @@ By default, L<http://deb.debian.org/debian> is being used.
 Specify the file name of the resulting virtual machine image.
 By default, it is written to F<rootfs.ext4>.
 
-=item B<-p> I<package>, B<--package>=I<package>
-
-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 also C<--skip=kernel>.
-
 =item B<-r> I<release>, B<--release>=I<release>
 
 Use the given Debian release.
@@ -108,6 +101,7 @@ The default is 1 GB.
 
 All options beyond a double dash are passed to B<mmdebstrap> before the suite, target and mirror specification.
 This can be used to provide additional hooks for image customization.
+You can also request additional packages to be installed into the image using B<mmdebstrap>'s B<--include> option.
 
 =back
 
@@ -142,7 +136,7 @@ die() {
 	exit 1
 }
 usage() {
-	die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-m mirror] [-o output] [-p packages] [-r release] [-z size_in_GB] [-- mmdebstrap options]"
+	die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-m mirror] [-o output] [-r release] [-s task] [-z size_in_GB] [-- mmdebstrap options]"
 }
 usage_error() {
 	echo "error: $*" 1>&2
@@ -167,12 +161,6 @@ opt_sshkey() {
 opt_output() {
 	IMAGE=$1
 }
-opt_package() {
-	INCLUDE_PACKAGES="$INCLUDE_PACKAGES,$1"
-	case "$1" in linux-image*)
-		opt_skip kernel
-	;; esac
-}
 opt_release() {
 	SUITE=$1
 }
@@ -180,14 +168,13 @@ opt_size() {
 	SIZE=$(($1*1024*1024*1024))
 }
 
-while getopts :a:h:k:m:o:p:r:s:z:-: OPTCHAR; do
+while getopts :a:h:k:m:o:r:s:z:-: OPTCHAR; do
 	case "$OPTCHAR" in
 		a)	opt_architecture "$OPTARG"	;;
 		h)	opt_hostname "$OPTARG"		;;
 		k)	opt_sshkey "$OPTARG"		;;
 		m)	opt_mirror "$OPTARG"		;;
 		o)	opt_output "$OPTARG"		;;
-		p)	opt_package "$OPTARG"		;;
 		r)	opt_release "$OPTARG"		;;
 		s)	opt_skip "$OPTARG"		;;
 		z)	opt_size "$OPTARG"		;;
@@ -196,12 +183,12 @@ while getopts :a:h:k:m:o:p:r:s:z:-: OPTCHAR; do
 				help)
 					usage
 				;;
-				architecture|hostname|mirror|output|package|release|size|skip|sshkey)
+				architecture|hostname|mirror|output|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=*|skip=*|sshkey=*)
+				architecture=*|hostname=*|mirror=*|output=*|release=*|size=*|skip=*|sshkey=*)
 					"opt_${OPTARG%%=*}" "${OPTARG#*=}"
 				;;
 				*)
diff --git a/useraddhook/customize.sh b/useraddhook/customize.sh
index a4390bd..3bba263 100755
--- a/useraddhook/customize.sh
+++ b/useraddhook/customize.sh
@@ -13,7 +13,7 @@
 #
 # Example usage:
 #
-#     $ debvm-create -p sudo -k ~/.ssh/id_rsa.pub -- --hook-dir=.../useraddhook
+#     $ debvm-create -k ~/.ssh/id_rsa.pub -- --hook-dir=.../useraddhook --include sudo
 #     $ debvm-run -s 8022
 #     $ ssh -l user -p 8022 127.0.0.1 whoami
 #     user
-- 
cgit v1.2.3