mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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).
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -347,7 +347,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
|
||||
@@ -375,6 +374,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
|
||||
|
||||
@@ -798,10 +798,10 @@ On Fedora you can use the L<mock(1)> tool. For example:
|
||||
This will result in a F<virt-v2v-*.i686.rpm> file which can be
|
||||
unpacked to extract the 32 bit virt-p2v binary.
|
||||
|
||||
The binary may be copied to either F<p2v/virt-p2v.i686>, or
|
||||
F<$libexecdir/virt-p2v.i686> or F<$VIRT_P2V_DATA_DIR/virt-p2v.i686> as
|
||||
appropriate. This enables the L<virt-p2v-make-disk(1)> I<--arch>
|
||||
option.
|
||||
The binary may be compressed to either F<p2v/virt-p2v.i686.xz>, or
|
||||
F<$libdir/virt-p2v/virt-p2v.i686.xz> or
|
||||
F<$VIRT_P2V_DATA_DIR/virt-p2v.i686.xz> as appropriate. This enables
|
||||
the L<virt-p2v-make-disk(1)> I<--arch> option.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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/ \
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user