From 7708cc27dff5cd6836c855e3ec3df771617d473f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 27 Jun 2016 11:40:18 +0100 Subject: [PATCH] p2v: Add --install option to virt-p2v-make-disk, virt-p2v-make-kickstart. This allows you to install extra packages in the disk/ISO. The implementation of this option in virt-p2v-make-disk was particularly simple and followed naturally from the previous commit. (cherry picked from commit 2783f695ff425ba4ff9cd59f28bb6046a3bb1114) --- p2v/p2v.ks.in | 4 ++++ p2v/virt-p2v-make-disk.in | 7 ++++++- p2v/virt-p2v-make-disk.pod | 14 ++++++++++++++ p2v/virt-p2v-make-kickstart.in | 8 +++++++- p2v/virt-p2v-make-kickstart.pod | 14 ++++++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/p2v/p2v.ks.in b/p2v/p2v.ks.in index 384843d..62a9d01 100644 --- a/p2v/p2v.ks.in +++ b/p2v/p2v.ks.in @@ -76,6 +76,10 @@ dracut-live # The dependencies of virt-p2v. __DEPENDENCIES__ +# Extra packages requested by the user via the virt-p2v-make-kickstart +# --install option (if any). +__EXTRA_PACKAGES__ + %end # Post-install configuration. diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in index cbbc9ff..cc7ee93 100644 --- a/p2v/virt-p2v-make-disk.in +++ b/p2v/virt-p2v-make-disk.in @@ -24,7 +24,7 @@ version="@PACKAGE_VERSION@" TEMP=`getopt \ -o o:V \ - --long help,inject-ssh-identity:,no-warn-if-partition,output:,verbose,version \ + --long help,inject-ssh-identity:,install:,no-warn-if-partition,output:,verbose,version \ -n $program -- "$@"` if [ $? != 0 ]; then echo "$program: problem parsing the command line arguments" @@ -60,6 +60,11 @@ while true; do shift;; # virt-builder parameters that are passed through. + --install) + passthru[${#passthru[*]}]="$1" + passthru[${#passthru[*]}]="$2" + shift 2;; + --no-warn-if-partition) passthru[${#passthru[*]}]="$1" shift;; diff --git a/p2v/virt-p2v-make-disk.pod b/p2v/virt-p2v-make-disk.pod index 2e1bffb..514ddb0 100644 --- a/p2v/virt-p2v-make-disk.pod +++ b/p2v/virt-p2v-make-disk.pod @@ -52,6 +52,15 @@ Write a virt-p2v bootable virtual disk image, and boot it under qemu: where F would be the disk image of some guest that you want to convert (for testing only). +=head1 ADDING EXTRA PACKAGES + +You can install extra packages using the I<--install> option. This +can be useful for making a more fully-featured virt-p2v disk with +extra tools for debugging and troubleshooting. Give a list of +packages, separated by commas. For example: + + virt-p2v-make-disk -o /var/tmp/p2v.img --install tcpdump,traceroute + =head1 ADDING AN SSH IDENTITY You can inject an SSH identity (private key) file to the image using @@ -99,6 +108,11 @@ Display help. Add an SSH identity (private key) file into the image. See L above. +=item B<--install> pkg,pkg,... + +Add extra packages to the image. +See L above. + =item B<--no-warn-if-partition> Normally you should not write to a partition on a USB drive (ie. don't diff --git a/p2v/virt-p2v-make-kickstart.in b/p2v/virt-p2v-make-kickstart.in index 8a6e4d8..c57e212 100644 --- a/p2v/virt-p2v-make-kickstart.in +++ b/p2v/virt-p2v-make-kickstart.in @@ -24,7 +24,7 @@ version="@PACKAGE_VERSION@" TEMP=`getopt \ -o o:vV \ - --long help,inject-ssh-identity:,output:,proxy:,verbose,version \ + --long help,inject-ssh-identity:,install:,output:,proxy:,verbose,version \ -n $program -- "$@"` if [ $? != 0 ]; then echo "$program: problem parsing the command line arguments" @@ -41,6 +41,7 @@ usage () exit $1 } +extra_packages= output=p2v.ks proxy= ssh_identity= @@ -51,6 +52,9 @@ while true; do --inject-ssh-identity) ssh_identity="$2" shift 2;; + --install) + extra_packages="${extra_packages:+${extra_packages},}$2" + shift 2;; -o|--output) output="$2" shift 2;; @@ -186,6 +190,7 @@ done < $depsfile -v "base64_ssh_identity=$base64_ssh_identity" \ -v "base64_virt_p2v=$base64_virt_p2v" \ -v "dependencies=$dependencies" \ + -v "extra_packages=$extra_packages" \ -v "md5sum_virt_p2v=$md5sum_virt_p2v" \ -v "repos=$repos" \ -v "libexecdir=$libexecdir" \ @@ -199,6 +204,7 @@ done < $depsfile gsub (/__BASE64_SSH_IDENTITY__/, base64_ssh_identity); gsub (/__BASE64_VIRT_P2V__/, base64_virt_p2v); gsub (/__DEPENDENCIES__/, dependencies); + gsub (/__EXTRA_PACKAGES__/, gensub (/,/, "\n", "g", extra_packages)); gsub (/__MD5SUM_VIRT_P2V__/, md5sum_virt_p2v); gsub (/__REPOS__/, repos); gsub (/__LIBEXECDIR__/, libexecdir); diff --git a/p2v/virt-p2v-make-kickstart.pod b/p2v/virt-p2v-make-kickstart.pod index cea3787..7e41c9d 100644 --- a/p2v/virt-p2v-make-kickstart.pod +++ b/p2v/virt-p2v-make-kickstart.pod @@ -191,6 +191,15 @@ pxelinux starts up. =back +=head1 ADDING EXTRA PACKAGES + +You can install extra packages using the I<--install> option. This +can be useful for making a more fully-featured virt-p2v disk with +extra tools for debugging and troubleshooting. Give a list of +packages, separated by commas. For example: + + virt-p2v-make-kickstart [...] --install tcpdump,traceroute + =head1 ADDING AN SSH IDENTITY You can inject an SSH identity (private key) file to the kickstart and @@ -243,6 +252,11 @@ Display help. Add an SSH identity (private key) file into the kickstart. See L above. +=item B<--install> pkg,pkg,... + +Add extra packages to the kickstart C<%packages> section. +See L above. + =item B<-o> OUTPUT =item B<--output> OUTPUT -- 1.8.3.1