2010-05-11 15:18:43 +02:00
#!/bin/sh
2010-05-12 17:45:54 +02:00
# Slackware build script for qemu
2010-05-11 19:46:36 +02:00
2010-03-16 03:38:19 +01:00
# Copyright 2009, 2010 Andrew Brouwers <abrouwers@gmail.com>
2014-04-29 03:55:57 +02:00
# Copyright 2013, 2014 Edward Koenig, Vancouver, USA <kingbeowulf@gmail.com>
2010-05-11 19:46:36 +02:00
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2013-04-14 19:56:35 +02:00
# Changelog
# 1.0 27-FEB-2013 New SBo maintainer
# 1.0 07-MAR-2013 updated to 1.4, includes qemu-kvm; thanks to
# rworkman and ponce for script ideas.
# 1.1 28-MAR-2013 fix missing docs per C. Willing and
# add missing --libdir (patched in qemu-trivial upstream)
2013-10-26 22:40:36 +02:00
# 1.2 22-SEP-2013 updated to 1.6
2013-11-04 22:03:10 +01:00
# 1.3 03-NOV-2013 updated to 1.6.1
2014-04-29 03:55:57 +02:00
# 1.4 28-APR-2014 updated to 2.0.0 (thanks Callum Davies <calrogman@gmail.com>), added useful options,
# clean ups, libusb version check.
2014-08-17 01:49:34 +02:00
# 1.4a 04-MAY-2014 fixed typos thanks to sandb0y
2014-11-24 10:26:59 +01:00
# 1.5 10-AUG-2014 updated to new version, watch for legacy "gotchas"
# 1.6 18-NOV-2014 updated version, last of the 2.1 series, changed defaults per SBo list
# 1.6a 23-NOV-2014 added overlooked AUDIODRIVERS switch per SBo list
2015-01-03 06:02:06 +01:00
# 1.7 01-JAN-2015 updated to 2.2.0 ; build and link static libusb option (rw, tm, SBo list)
2015-04-28 02:49:43 +02:00
# 1.8 27-APR-2015 updated to version 2.3.0
2015-05-14 18:25:41 +02:00
# 1.9 14-MAY-2015 patched for "Venom" CVE-2015-3456 http://git.qemu.org/?p=qemu.git;a=commitdiff;h=e907746266721f305d67bc0718795fedee2e824c
2015-07-13 02:54:06 +02:00
# 2.0 11-JUL-2015 patched for Heap-based buffer overflow in the PCNET controller CVE-2015-3209 http://git.qemu.org/?p=qemu.git;a=commitdiff;h=9f7c594c006289ad41169b854d70f5da6e400a2a
2010-05-11 19:46:36 +02:00
PRGNAM=qemu
2015-04-28 02:49:43 +02:00
VERSION=${VERSION:-2.3.0}
2015-07-13 02:54:06 +02:00
BUILD=${BUILD:-3}
2010-05-11 19:46:36 +02:00
TAG=${TAG:-_SBo}
2010-05-12 17:45:54 +02:00
2014-04-29 03:55:57 +02:00
KVMGROUP=${KVMGROUP:-users}
TARGETS=${TARGETS:-some}
2014-11-19 14:19:32 +01:00
VNC_ENABLE=${VNC_ENABLE:-yes}
2014-11-24 10:26:59 +01:00
AUDIODRIVERS=${AUDIODRIVERS:-alsa,oss,sdl,esd}
2015-01-03 06:02:06 +01:00
LIBUSB=${LIBUSB:-no}
2014-04-29 03:55:57 +02:00
2010-06-04 07:16:35 +02:00
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
2010-05-11 19:46:36 +02:00
CWD=$(pwd)
2010-05-11 15:18:43 +02:00
TMP=${TMP:-/tmp/SBo}
2010-05-13 00:41:33 +02:00
PKG=$TMP/package-$PRGNAM
2010-05-11 15:18:43 +02:00
OUTPUT=${OUTPUT:-/tmp}
2010-05-12 17:45:54 +02:00
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
2013-04-14 19:56:35 +02:00
KVMARCH="i386"
2010-05-12 17:45:54 +02:00
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
2013-04-14 19:56:35 +02:00
KVMARCH="i386"
2010-05-12 17:45:54 +02:00
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
2013-04-14 19:56:35 +02:00
KVMARCH="x86_64"
2010-06-04 07:16:35 +02:00
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
2010-05-12 17:45:54 +02:00
fi
2013-04-14 19:56:35 +02:00
# Needed to build man pages if built after plain "su"
export PATH=$PATH:/usr/share/texmf/bin
2010-05-12 17:45:54 +02:00
set -e
2010-05-11 19:46:36 +02:00
rm -rf $PKG
2010-05-11 15:18:43 +02:00
mkdir -p $TMP $PKG $OUTPUT
2010-05-12 17:45:54 +02:00
cd $TMP
rm -rf $PRGNAM-$VERSION
2012-09-08 18:07:25 +02:00
tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2
2010-05-12 17:45:54 +02:00
cd $PRGNAM-$VERSION
2010-05-11 15:18:43 +02:00
chown -R root:root .
2013-11-25 12:23:31 +01:00
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
2014-08-17 01:49:34 +02:00
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
2010-05-11 15:18:43 +02:00
2013-04-14 19:56:35 +02:00
# Remove double CFLAGS
2014-04-29 03:55:57 +02:00
sed -i "s|^\ \ CFLAGS=\"-O2\ | CFLAGS=\"|" configure
# Enable only x86* and arm emulation for qemu: if you want to build
# all the targets available use TARGETS=all
if [ "$TARGETS" = "all" ]; then
targets=""
else
targets="--target-list=i386-softmmu,x86_64-softmmu,i386-linux-user,x86_64-linux-user,arm-softmmu,arm-linux-user,armeb-linux-user"
fi
2014-11-19 14:19:32 +01:00
# To omit VNC capability, use VNC_ENABLE=no
2014-04-29 03:55:57 +02:00
if [ "$VNC_ENABLE" = "yes" ]; then
with_vnc="--enable-vnc --enable-vnc-tls --enable-vnc-jpeg"
else
with_vnc="--disable-vnc"
fi
2015-01-03 06:02:06 +01:00
# Build libusb-1.0.19 statically so that usb passthrough will work;
# not needed if you upgrade the default libdir.
USBSTATIC=""
if [ "$LIBUSB" = "yes" ]; then
tar xf $CWD/libusb-1.0.19.tar.xz
cd libusb-1.0.19
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=$TMP/$PRGNAM-$VERSION/libusb-static \
--build=$ARCH-slackware-linux \
--disable-shared \
--enable-static
make install
cd ..
sed -i 's/--cflags libusb-1.0/\0 --static/' configure
sed -i 's/--libs libusb-1.0/\0 --static/' configure
USBSTATIC="$TMP/$PRGNAM-$VERSION/libusb-static/lib/pkgconfig"
fi
2015-05-14 18:25:41 +02:00
# patch Venom bug CVE-2015-3456
patch -p1 < $CWD/qemu_venom.patch
2015-07-13 02:54:06 +02:00
# patch PCNET controller bug CVE-2015-3209
patch -p1 < $CWD/qemu_pcnet.patch
2015-01-03 06:02:06 +01:00
PKG_CONFIG_PATH+="${USBSTATIC}" \
2010-05-12 17:45:54 +02:00
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
2013-04-14 19:56:35 +02:00
--libdir=/usr/lib${LIBDIRSUFFIX} \
2011-05-17 05:17:21 +02:00
--sysconfdir=/etc \
2013-10-26 22:40:36 +02:00
--localstatedir=/var \
--docdir=/usr/doc/$PRGNAM-$VERSION \
--enable-gtk \
2013-04-14 19:56:35 +02:00
--enable-system \
--enable-kvm \
--disable-debug-info \
2014-04-29 03:55:57 +02:00
--enable-virtfs \
--enable-sdl \
2014-11-24 10:26:59 +01:00
--audio-drv-list=${AUDIODRIVERS} \
2014-04-29 03:55:57 +02:00
$with_vnc \
2014-11-19 14:19:32 +01:00
$targets
2013-04-14 19:56:35 +02:00
2015-01-03 06:02:06 +01:00
# Make these first; otherwise make won't run in parallel.
make config-all-devices.mak config-all-disas.mak
2014-04-29 03:55:57 +02:00
2014-11-19 14:19:32 +01:00
make V=1
2010-05-12 17:45:54 +02:00
make install DESTDIR=$PKG
2015-01-03 06:02:06 +01:00
# Remove empty /var
rm -rf $PKG/var/run
2013-04-14 19:56:35 +02:00
# install some udev rules for /dev/kvm
mkdir -p $PKG/lib/udev/rules.d/
sed "s/@GROUP@/$KVMGROUP/" $CWD/65-kvm.rules \
> $PKG/lib/udev/rules.d/65-kvm.rules
2014-08-17 01:49:34 +02:00
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
2010-05-12 17:45:54 +02:00
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
2013-04-14 19:56:35 +02:00
# create a symlink for qemu-kvm to support aqemu and such frontends
2013-10-26 22:40:36 +02:00
# even though qemu now has a gtk gui.
2013-04-14 19:56:35 +02:00
[ ! -z $KVMARCH ] && ln -s qemu-system-$KVMARCH $PKG/usr/bin/qemu-kvm
2010-05-13 00:41:33 +02:00
# move any generated man pages to their proper location
if [ -d $PKG/usr/share/man ]; then
mv $PKG/usr/share/man $PKG/usr
gzip -9 $PKG/usr/man/man?/*.?
fi
2010-05-12 17:45:54 +02:00
2013-10-26 22:40:36 +02:00
# Add docs to the proper location
2010-05-11 19:46:36 +02:00
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
2014-05-05 05:40:42 +02:00
cp -a Changelog COPYING* CODING_STYLE HACKING LICENSE MAINTAINERS README qemu-*.html docs/* \
2013-10-26 22:40:36 +02:00
$PKG/usr/doc/$PRGNAM-$VERSION
2010-05-11 19:46:36 +02:00
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
2010-05-11 15:18:43 +02:00
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
2010-05-13 00:41:33 +02:00
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}