question regarding building software from source

Hi,

First of all I apologize for the verbosity of below, I hope it’s not too much. I’m trying to learn something here so I’ve written down the steps I’ve done so far and hope that someone can point out a better/cleaner way of accomplishing my goal. This is all very new (and exciting).

I’m attempting to build QEMU 2.0.0 from source to have USB device passthrough working (working in QEMU 1.6.2 but broken in 2.0.0). The QEMU 2.0.0 package and sources are available in the Virtualization/openSUSE_13.1 repo. From what I’ve gathered USB passthrough is not working because QEMU was built without the --enable-libusb flag. This I was able to confirme by looking at the qemu.spec rpm spec. The build requirements list

%if 0%{?suse_version} > 1310
BuildRequires:  libusb-devel
%endif

and the ./configure invocation has

# %if 0%{?suse_version} > 1310
        --enable-libusb \
# %endif

This is apparently due to the libusb version provided with OpenSUSE 13.1 being 1.0.9, whereas QEMU’s configure requires 1.0.13, as I found in

# check for libusb
if test "$libusb" != "no" ; then
    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
        libusb="yes"
        ...
    else
        ...
    fi
fi

So I went ahead and downloaded the latest libusb sources (1.0.18) from SourceForge and ran

  332  cd libusb-1.0.18/
  333  make clean
  334  ./configure
  335  make
  336  sudo make install

to build and install libusb.

Then to build QEMU,

  1. I ran
zypper si qemu

to get the source package,
2) modified qemu.spec as

%if 0%{?suse_version} >= 1310
BuildRequires:  libusb-devel
%endif

and

%if 0%{?suse_version} >= 1310
        --enable-libusb \
%endif

as the libusb-devel package is actually named libusb-1_0-devel and we want to include --enable-libusb
3) but

sudo rpmbuild -bb /usr/src/packages/SPECS/qemu.spec

yields

+ ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64 --libexecdir=/usr/lib --localstatedir=/var '--extra-cflags=-O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables' --disable-strip --enable-system --disable-linux-user --enable-tools --enable-guest-agent --enable-pie --enable-docs '--audio-drv-list=pa alsa sdl oss' --enable-brlapi --enable-cap-ng --enable-curl --enable-curses --enable-gtk --with-gtkabi=3.0 --enable-kvm --enable-linux-aio --enable-modules --enable-sdl --with-sdlabi=1.2 --enable-smartcard-nss --enable-spice --enable-libusb --enable-usb-redir --enable-vde --enable-virtfs --enable-virtio-blk-data-plane --enable-vnc-jpeg --enable-vnc-png --enable-vnc-sasl --enable-vnc-tls --enable-vnc-ws --enable-xen

ERROR: User requested feature libusb
       configure was not able to find it.
       Install libusb devel

I downloaded libusb-1_0-devel and ran

unrpm libusb-1_0-devel-1.0.9-5.1.1.x86_64.rpm

and inside the rpm (minus the documentation):

ls -Rt *
lib64:
libusb-1.0.so  pkgconfig

lib64/pkgconfig:
libusb-1.0.pc

include/libusb-1.0:
libusb.h

So I manually replaced those files (.so shared library, .h hearders and .pc for pkg-config) on the system with the ones resulting from the above libusb 1.0.18 build process.

At that point QEMU still fails to build because it’s missing some bios files that fail to build or are missing

install: cannot stat '/usr/src/packages/BUILD/qemu-2.0.0/pc-bios/bios.bin': No such file or directory
make: *** [install] Error 1

I copied those from /usr/share/qemu and commented out the part in the rpm spec that rm’s the contents of the above stated path in BUILD. After that it builds and I have a bunch of rpms in /usr/src/packages/RPMS that I now need to figure out how to install.

Now, all this, while very educational (learnt about rpm specs, pkg-config, etc) doesn’t seem like the cleanest way to go about this. So I was hoping someone could comment so thing are leas prone to breaking down. Thanks for reading and for any comments. :slight_smile: