Richard W.M. Jones
2016-Oct-10 19:17 UTC
[Libguestfs] [PATCH] p2v: Compress virt-p2v binary and store it in $libdir/virt-p2v (RHBZ#1382275).
Currently 'make install' installs the virt-p2v binary in /usr/libexec/virt-p2v on the host. It is never supposed to be run from there, even by another program, so use of /usr/libexec is incorrect. It is only supposed to be copied into USB keys / ISOs / etc created by virt-p2v-make-* scripts. The other problem with shipping a "naked" binary on the host is that packages built from that get all the dependencies of virt-p2v, for example Gtk. This is unnecessary just for running the command line scripts mentioned above. This changes the Makefile and scripts so that the binary is stored compressed in $libdir/virt-p2v/virt-p2v.xz. It is compressed to avoid exposing the dependencies. It is stored under $libdir since the binary is still architecture-dependent. A further change is that when we copy the binary into the virt-p2v ISO, it is now installed in /usr/bin instead of /usr/libexec. (And note that we always use /usr/bin, not $bindir, since this path should not need to be affected by the configuration of libguestfs). --- .gitignore | 2 +- p2v/Makefile.am | 24 ++++++++++++++---------- p2v/{launch-virt-p2v.in => launch-virt-p2v} | 5 ++--- p2v/p2v.ks.in | 4 ++-- p2v/virt-p2v-make-disk.in | 29 ++++++++++++++--------------- p2v/virt-p2v-make-disk.pod | 4 ++-- p2v/virt-p2v-make-kickstart.in | 15 ++++----------- p2v/virt-p2v-make-kickstart.pod | 2 +- p2v/virt-p2v-make-kiwi.in | 15 +++------------ p2v/virt-p2v-make-kiwi.pod | 2 +- 10 files changed, 44 insertions(+), 58 deletions(-) rename p2v/{launch-virt-p2v.in => launch-virt-p2v} (93%) diff --git a/.gitignore b/.gitignore index c4d6eda..a4be4ae 100644 --- a/.gitignore +++ b/.gitignore @@ -350,7 +350,6 @@ Makefile.in /p2v/dependencies.debian /p2v/dependencies.redhat /p2v/dependencies.suse -/p2v/launch-virt-p2v /p2v/stamp-test-virt-p2v-pxe-data-files /p2v/stamp-test-virt-p2v-pxe-hostkey /p2v/stamp-test-virt-p2v-pxe-kernel @@ -378,6 +377,7 @@ Makefile.in /p2v/virt-p2v-make-kickstart.1 /p2v/virt-p2v-make-kiwi /p2v/virt-p2v-make-kiwi.1 +/p2v/virt-p2v.xz /perl/_build /perl/bindtests.pl /perl/blib diff --git a/p2v/Makefile.am b/p2v/Makefile.am index 5cac334..9dbfa22 100644 --- a/p2v/Makefile.am +++ b/p2v/Makefile.am @@ -49,14 +49,25 @@ CLEANFILES += \ test-virt-p2v-pxe.vmlinuz \ test-virt-p2v-pxe.initramfs \ test-virt-p2v-pxe.sshd_config \ - virt-p2v.img + virt-p2v.img \ + virt-p2v.xz # Although virt-p2v is a regular binary, it is not usually installed # in /usr/bin since it only functions when contained in an ISO or PXE # image which is used to boot the physical machine (since otherwise # virt-p2v would not be able to get a consistent snapshot of the -# physical disks). -libexec_PROGRAMS = virt-p2v +# physical disks). Also we don't want the naked binary to appear on +# the host, which would cause various Gtk dependencies to be pulled +# in, so it must be compressed. +virtp2vlibdir = $(libdir)/virt-p2v +virtp2vlib_DATA = virt-p2v.xz + +virt-p2v.xz: virt-p2v + rm -f $@ $@-t + xz --best --keep --stdout $< > $@-t + mv $@-t $@ + +noinst_PROGRAMS = virt-p2v # Note that miniexpect comes from here: # http://git.annexia.org/?p=miniexpect.git;a=summary @@ -121,13 +132,6 @@ virtp2vdata_DATA = \ p2v.ks.in \ p2v.service -# Deal with stupid autotools libexecdir-not-expandable crap. -launch-virt-p2v: launch-virt-p2v.in - rm -f $@ $@-t - $(SED) 's,@''libexecdir@,$(libexecdir),g' < $< > $@-t - chmod 0555 $@-t - mv $@-t $@ - # Manual pages and HTML files for the website. man_MANS = \ virt-p2v.1 \ diff --git a/p2v/launch-virt-p2v.in b/p2v/launch-virt-p2v similarity index 93% rename from p2v/launch-virt-p2v.in rename to p2v/launch-virt-p2v index 454e9f4..908189c 100755 --- a/p2v/launch-virt-p2v.in +++ b/p2v/launch-virt-p2v @@ -1,5 +1,4 @@ #!/bin/bash - -# @configure_input@ # (C) Copyright 2014-2016 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify @@ -23,7 +22,7 @@ cmdline=$(</proc/cmdline) if [[ $cmdline == *p2v.server=* ]]; then # Non-GUI mode, don't run X. Just run virt-p2v directly. - exec @libexecdir@/virt-p2v --iso --colours + exec /usr/bin/virt-p2v --iso --colours else # GUI mode. Run xinit to start X. To save one script, we invoke @@ -45,7 +44,7 @@ else metacity & nm-applet & esac - exec @libexecdir@/virt-p2v --iso --colours + exec /usr/bin/virt-p2v --iso --colours else xinit "$0" run fi diff --git a/p2v/p2v.ks.in b/p2v/p2v.ks.in index 62a9d01..f4a6fcb 100644 --- a/p2v/p2v.ks.in +++ b/p2v/p2v.ks.in @@ -122,11 +122,11 @@ EOF # Base64-decoding of virt-p2v binary # md5(virt-p2v) = __MD5SUM_VIRT_P2V__ -base64 -d <<EOF | gzip -cd > __LIBEXECDIR__/virt-p2v +base64 -d <<EOF | gzip -cd > /usr/bin/virt-p2v __BASE64_VIRT_P2V__ EOF -chmod 0755 __LIBEXECDIR__/virt-p2v +chmod 0755 /usr/bin/virt-p2v # Update the default getty target to login automatically as root without # prompting for a password diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in index c5b5463..e99344a 100644 --- a/p2v/virt-p2v-make-disk.in +++ b/p2v/virt-p2v-make-disk.in @@ -22,17 +22,12 @@ unset CDPATH program="virt-p2v-make-disk" version="@PACKAGE_VERSION@" -# Deal with stupid autotools libexecdir-not-expandable crap. -prefix="@prefix@" -exec_prefix="@exec_prefix@" -libexecdir="@libexecdir@" - if [ -n "$VIRT_P2V_DATA_DIR" ]; then datadir="$VIRT_P2V_DATA_DIR" - host_libexecdir="$VIRT_P2V_DATA_DIR" + libdir="$VIRT_P2V_DATA_DIR" else datadir="@datadir@/virt-p2v" - host_libexecdir="@libexecdir@" + libdir="@libdir@/virt-p2v" fi # Parse the command line arguments. @@ -144,16 +139,16 @@ fi if [ -n "$arch" ]; then arch_option="--arch $arch" - virt_p2v_binary="$host_libexecdir/virt-p2v.$arch" + virt_p2v_xz_binary="$libdir/virt-p2v.$arch.xz" else - virt_p2v_binary="$host_libexecdir/virt-p2v" + virt_p2v_xz_binary="$libdir/virt-p2v.xz" fi -if [ ! -f "$virt_p2v_binary" ]; then - echo "$program: cannot find $virt_p2v_binary" +if [ ! -f "$virt_p2v_xz_binary" ]; then + echo "$program: cannot find $virt_p2v_xz_binary" if [ -n "$arch" ]; then echo "You used the '--arch' option, so it's likely that you will need to build" - echo "an virt-p2v.$arch binary yourself." + echo "a virt-p2v.$arch binary yourself." echo "See guestfs-building(1) section BUILDING i686 32 BIT VIRT-P2V for help." fi exit 1 @@ -167,6 +162,10 @@ cleanup () } trap cleanup INT QUIT TERM EXIT ERR +# Uncompress the virt-p2v binary into tmpdir. +virt_p2v_binary="$tmpdir/virt-p2v" +xzcat "$virt_p2v_xz_binary" > "$virt_p2v_binary" + # Variations depending on the target distro. The main difference # is in the list of distro packages we add to the base appliance. case "$osversion" in @@ -235,9 +234,9 @@ virt-builder "$osversion" \ --root-password password:p2v \ --upload "$datadir"/issue:/etc/issue \ --upload "$datadir"/issue:/etc/issue.net \ - --mkdir "$libexecdir" \ - --upload "$virt_p2v_binary":"$libexecdir"/virt-p2v \ - --chmod 0755:"$libexecdir"/virt-p2v \ + --mkdir /usr/bin \ + --upload "$virt_p2v_binary":/usr/bin/virt-p2v \ + --chmod 0755:/usr/bin/virt-p2v \ --upload "$datadir"/launch-virt-p2v:/usr/bin/ \ --chmod 0755:/usr/bin/launch-virt-p2v \ --upload "$datadir"/p2v.service:/etc/systemd/system/ \ diff --git a/p2v/virt-p2v-make-disk.pod b/p2v/virt-p2v-make-disk.pod index e88cfc1..28b563e 100644 --- a/p2v/virt-p2v-make-disk.pod +++ b/p2v/virt-p2v-make-disk.pod @@ -106,7 +106,7 @@ hypervisors. This option requires that you have built F<virt-p2v.$arch> (ie. usually F<virt-p2v.i686>) by some means, and that you install it next -to the ordinary F<virt-p2v> binary (eg. in libexecdir or +to the ordinary F<virt-p2v> binary (eg. in F<$libdir/virt-p2v/> or C<$VIRT_V2V_DATA_DIR>). This is outside the scope of this manual page, but you can find some tips in L<guestfs-building(1)/BUILDING i686 32 BIT VIRT-P2V>. @@ -169,7 +169,7 @@ Display version number and exit. =over 4 -=item F<$libexecdir/virt-p2v> +=item F<$libdir/virt-p2v/virt-p2v.xz> The L<virt-p2v(1)> binary which is copied into the bootable disk image. diff --git a/p2v/virt-p2v-make-kickstart.in b/p2v/virt-p2v-make-kickstart.in index 85217d5..529bfbe 100644 --- a/p2v/virt-p2v-make-kickstart.in +++ b/p2v/virt-p2v-make-kickstart.in @@ -103,17 +103,12 @@ fi set -e -# Deal with stupid autotools libexecdir-not-expandable crap. -prefix="@prefix@" -exec_prefix="@exec_prefix@" -libexecdir="@libexecdir@" - if [ -n "$VIRT_P2V_DATA_DIR" ]; then datadir="$VIRT_P2V_DATA_DIR" - host_libexecdir="$VIRT_P2V_DATA_DIR" + libdir="$VIRT_P2V_DATA_DIR" else datadir="@datadir@/virt-p2v" - host_libexecdir="@libexecdir@" + libdir="@libdir@" fi # Base64-encode the files that we need to embed into the kickstart. @@ -126,9 +121,9 @@ else base64_ssh_identity fi -# virt-p2v binary is too large unless we strip it and compress it. +# virt-p2v binary is too large unless we strip it and recompress it. tmpfile="$(mktemp -u)" -cp $host_libexecdir/virt-p2v $tmpfile +xzcat $libdir/virt-p2v > $tmpfile md5sum_virt_p2v="$(md5sum $tmpfile | @AWK@ '{print $1}')" strip --strip-all $tmpfile gzip -9 $tmpfile @@ -207,7 +202,6 @@ done < $depsfile -v "extra_packages=$extra_packages" \ -v "md5sum_virt_p2v=$md5sum_virt_p2v" \ -v "repos=$repos" \ - -v "libexecdir=$libexecdir" \ '{ gsub (/__PACKAGE_NAME__/, "@PACKAGE_NAME@"); gsub (/__PACKAGE_VERSION__/, "@PACKAGE_VERSION@"); @@ -221,7 +215,6 @@ done < $depsfile gsub (/__EXTRA_PACKAGES__/, gensub (/,/, "\n", "g", extra_packages)); gsub (/__MD5SUM_VIRT_P2V__/, md5sum_virt_p2v); gsub (/__REPOS__/, repos); - gsub (/__LIBEXECDIR__/, libexecdir); print; }' \ $datadir/p2v.ks.in > $output-t diff --git a/p2v/virt-p2v-make-kickstart.pod b/p2v/virt-p2v-make-kickstart.pod index 7e41c9d..808ed72 100644 --- a/p2v/virt-p2v-make-kickstart.pod +++ b/p2v/virt-p2v-make-kickstart.pod @@ -287,7 +287,7 @@ Display version number and exit. =over 4 -=item F<$libexecdir/virt-p2v> +=item F<$libdir/virt-p2v/virt-p2v.xz> The L<virt-p2v(1)> binary which is copied into the kickstart file. diff --git a/p2v/virt-p2v-make-kiwi.in b/p2v/virt-p2v-make-kiwi.in index dc7fce4..405b629 100644 --- a/p2v/virt-p2v-make-kiwi.in +++ b/p2v/virt-p2v-make-kiwi.in @@ -82,17 +82,12 @@ done set -e -# Deal with stupid autotools libexecdir-not-expandable crap. -prefix="@prefix@" -exec_prefix="@exec_prefix@" -libexecdir="@libexecdir@" - if [ -n "$VIRT_P2V_DATA_DIR" ]; then datadir="$VIRT_P2V_DATA_DIR" - host_libexecdir="$VIRT_P2V_DATA_DIR" + libdir="$VIRT_P2V_DATA_DIR" else datadir="@datadir@/virt-p2v" - host_libexecdir="@libexecdir@" + libdir="@libdir@/virt-p2v" fi # Dependencies. Since kiwi is SUSE-specific, only include @@ -204,9 +199,7 @@ cp $datadir/issue $output/root/etc/issue mkdir -p $output/root/usr/bin cp $datadir/launch-virt-p2v $output/root/usr/bin - -mkdir -p $output/root/$libexecdir -cp $host_libexecdir/virt-p2v $output/root/$libexecdir +xzcat $libdir/virt-p2v.xz > $output/root/usr/bin/virt-p2v if test "z$ssh_identity" != "z"; then mkdir -p $output/root/var/tmp @@ -218,7 +211,6 @@ fi @AWK@ \ -v "dependencies=$dependencies" \ -v "md5sum_virt_p2v=$md5sum_virt_p2v" \ - -v "libexecdir=$libexecdir" \ -v "branding=$branding" \ -v "release_pkg=$release_pkg" \ -v "base_pattern=$base_pattern" \ @@ -229,7 +221,6 @@ fi gsub (/__PACKAGE_VERSION__/, "@PACKAGE_VERSION@"); gsub (/__PACKAGE_VERSION_FULL__/, "@PACKAGE_VERSION_FULL@"); gsub (/<!--__DEPENDENCIES__-->/, dependencies); - gsub (/__LIBEXECDIR__/, libexecdir); gsub (/__BRANDING__/, branding); gsub (/__RELEASE_PKG__/, release_pkg); gsub (/__BASE_PATTERN__/, base_pattern); diff --git a/p2v/virt-p2v-make-kiwi.pod b/p2v/virt-p2v-make-kiwi.pod index 92556d9..0b5c35c 100644 --- a/p2v/virt-p2v-make-kiwi.pod +++ b/p2v/virt-p2v-make-kiwi.pod @@ -133,7 +133,7 @@ Display version number and exit. =over 4 -=item F<$libexecdir/virt-p2v> +=item F<$libdir/virt-p2v/virt-p2v.xz> The L<virt-p2v(1)> binary which is copied into the kiwi configuration. -- 2.9.3
Apparently Analagous Threads
- [PATCH] p2v: kiwi: make sure launch-virt-p2v is executable
- Re: [PATCH] p2v: kiwi: make sure launch-virt-p2v is executable
- [PATCH v2 0/4] virt-p2v support for openSUSE / SLES
- [PATCH v3 0/4] virt-p2v support for openSUSE / SLES
- [PATCH 0/4] virt-p2v support for openSUSE / SLES