Skip to content

Instantly share code, notes, and snippets.

@reski-rukmantiyo
Forked from rpavlik/winvm.md
Last active January 11, 2023 16:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reski-rukmantiyo/82d0f4a3aa93be60f59ae1166b47ff23 to your computer and use it in GitHub Desktop.
Save reski-rukmantiyo/82d0f4a3aa93be60f59ae1166b47ff23 to your computer and use it in GitHub Desktop.
onboard-missing-libs-virt-v2v
#
# How to get Rhsrvy and pnp_wait for virt-v2v
#
# Activate Debug
# export LIBGUESTFS_TRACE=1
# export LIBGUESTFS_DEBUG=1
# export LIBVIRT_DEBUG=1
# We use Ubuntu 14.04 to build a native gcc for win32 with multilib support
#
# Based on:
# http://sourceforge.net/p/mingw-w64/wiki2/Native%20Win64%20compiler/
# http://sourceforge.net/p/mingw-w64/code/HEAD/tree/stable/v3.x/mingw-w64-doc/howto-build/mingw-w64-howto-build.txt?format=raw
#
# Cross compiling notes:
# - The minor version of gcc must match that of our cross compiler (4.8 in this case)
# - Important parameters: http://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
#
# Use ubuntu cross compiler
sudo apt-get install make gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
# Setup dir structure
BUILDROOT=~/mingw
SRC=$BUILDROOT/sources
DEST=$BUILDROOT/dest
mkdir -p $SRC
mkdir -p $DEST
# Get sources
cd $SRC
wget http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2
tar xjf binutils-2.24.tar.bz2
wget http://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v3.1.0.tar.bz2
tar xjf mingw-w64-v3.1.0.tar.bz2
wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.3/gcc-4.8.3.tar.bz2
tar xjf gcc-4.8.3.tar.bz2
# Get gcc dependencies
cd gcc-4.8.3
./contrib/download_prerequisites
# Make binutils
mkdir -p $BUILDROOT/binutils
cd $BUILDROOT/binutils
$SRC/binutils-2.24/configure --prefix=$DEST --with-sysroot=$DEST --target=i686-w64-mingw32 --enable-targets=i686-w64-mingw32,x86_64-w64-mingw32 #--enable-64-bit-bfd
make
make install
# Add path (required for building gcc later)
export PATH="$PATH:$DEST/bin"
# Build mingw headers
# Assumes we are building with x86_64-w64-mingw32 cross compiler!
mkdir -p $BUILDROOT/headers
cd $BUILDROOT/headers
$SRC/mingw-w64-v3.1.0/mingw-w64-headers/configure --prefix=$DEST/i686-w64-mingw32 --host=i686-w64-mingw32 --build=x86_64-w64-mingw32 #--build=i686-w64-mingw32
make
make install
# Symlink for gcc
ln -s $DEST/i686-w64-mingw32 $DEST/mingw
# Multilib symlink. Not sure if this is necessary for i686.
# ln -s $DEST/i686-w64-mingw32/lib $DEST/i686-w64-mingw32/lib64
# Building GCC
# Not sure about --disable-shared
mkdir -p $BUILDROOT/gcc
cd $BUILDROOT/gcc
$SRC/gcc-4.8.3/configure --target=i686-w64-mingw32 --prefix=$DEST --with-sysroot=$DEST --enable-targets=all --disable-shared --enable-languages=c,c++,fortran
make all-gcc
make install-gcc
# Building CRT (Mingw-w64 itself)
mkdir -p $BUILDROOT/crt
cd $BUILDROOT/crt
$SRC/mingw-w64-v3.1.0/configure --host=i686-w64-mingw32 --prefix=$DEST/i686-w64-mingw32 --with-sysroot=$DEST --enable-lib32 --enable-lib64
make
make install
# Finishing gcc
cd $BUILDROOT/gcc
make
make install

One time

  • Build rhsrvany using a windows toolchain like i686-w64-mingw32, and put the resulting rhsrvany.exe and pnp_wait.exe in /usr/share/virt-tools (or see https://salsa.debian.org/rpavlik/rhsrvany for a debian package of it)
    • git clone https://github.com/rwmjones/rhsrvany.git
    • cd rhsrvany
    • autoreconf -i -f
    • ./configure --host=i686-w64-mingw32 ./configure
    • make
    • sudo mkdir -p /usr/share/virt-tools
    • sudo cp RHSrvAny/rhsrvany.exe pnp_wait/pnp_wait.exe /usr/share/virt-tools
  • Download https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso and place in /usr/share/virtio-win/virtio-win.iso
    • sudo mkdir -p /usr/share/virtio-win
    • sudo wget -O /usr/share/virtio-win/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment