Blame SOURCES/0139-p2v-Add-install-option-to-virt-p2v-make-disk-virt-p2.patch

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