add info about oficial slackbuild
[slackbuilds.git] / qemu / build / qemu.SlackBuild
blob754ca28dd837dcbe340146b843828291d62aaeae
1 #!/bin/bash
3 # Slackware build script for qemu
5 # Copyright 2009, 2010 Andrew Brouwers <abrouwers@gmail.com>
6 # Copyright 2013-2022 Edward W. Koenig, Vancouver, USA <kingbeowulf@linuxgalaxy.org>
7 # All rights reserved.
9 # Redistribution and use of this script, with or without modification, is
10 # permitted provided that the following conditions are met:
12 # 1. Redistributions of this script must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
16 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 # 20230701 bkw: Modified by SlackBuilds.org, BUILD=2:
27 # - add doinst to update desktop database and icon cache.
28 # Note: sbopkglint <= 0.9.0 complains about ELF binaries found in
29 # /usr/share/qemu (intended for the target systems). This is an error
30 # in sbopkglint, and will be fixed (no need to change anything here).
32 cd $(dirname $0) ; CWD=$(pwd)
34 PRGNAM=qemu
35 VERSION=${VERSION:-9.2.0}
36 BUILD=${BUILD:-1}
37 TAG=${TAG:-_r1w1s1}
38 PKGTYPE=${PKGTYPE:-txz}
40 KVMGROUP=${KVMGROUP:-users}
41 TARGETS=${TARGETS:-all}
42 VNC_ENABLE=${VNC_ENABLE:-yes}
43 AUDIODRIVERS=${AUDIODRIVERS:-pa,alsa,oss,sdl}
44 BRIDGE_HELPER_SETUID=${BRIDGE_HELPER_SETUID:-no}
45 SLIRP=${SLIRP:-=no}
47 if [ -z "$ARCH" ]; then
48 case "$( uname -m )" in
49 i?86) ARCH=i586 ;;
50 arm*) ARCH=arm ;;
51 *) ARCH=$( uname -m ) ;;
52 esac
55 if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
56 echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
57 exit 0
60 TMP=${TMP:-/tmp/build}
61 PKG=$TMP/package-$PRGNAM
62 OUTPUT=${OUTPUT:-/tmp}
64 if [ "$ARCH" = "i586" ]; then
65 SLKCFLAGS="-O2 -march=i586 -mtune=i686"
66 LIBDIRSUFFIX=""
67 KVMARCH="i386"
68 elif [ "$ARCH" = "i686" ]; then
69 SLKCFLAGS="-O2 -march=i686 -mtune=i686"
70 LIBDIRSUFFIX=""
71 KVMARCH="i386"
72 elif [ "$ARCH" = "x86_64" ]; then
73 SLKCFLAGS="-O2 -fPIC"
74 LIBDIRSUFFIX="64"
75 KVMARCH="x86_64"
76 else
77 SLKCFLAGS="-O2"
78 LIBDIRSUFFIX=""
81 # Needed to build man pages if built after plain "su"
82 export PATH=$PATH:/usr/share/texmf/bin
84 # Autodetect liburing support
85 uring="dis" ; if pkg-config --exists liburing ; then uring="en" ; fi
87 set -e
89 rm -rf $PKG
90 mkdir -p $TMP $PKG $OUTPUT
91 cd $TMP
92 rm -rf $PRGNAM-$VERSION
93 tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
94 cd $PRGNAM-$VERSION
95 chown -R root:root .
96 find -L . \
97 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
98 -o -perm 511 \) -exec chmod 755 {} + -o \
99 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
100 -o -perm 440 -o -perm 400 \) -exec chmod 644 {} + || true
102 # Remove double CFLAGS
103 sed -i "s|^\ \ CFLAGS=\"-O2\ | CFLAGS=\"|" configure
105 # Enable only x86* and arm emulation for qemu: if you want to build
106 # all the targets available use TARGETS=all
107 if [ "$TARGETS" = "all" ]; then
108 targets=""
109 else
110 targets="--target-list=$TARGETS"
113 # To omit VNC capability, use VNC_ENABLE=no
114 if [ "$VNC_ENABLE" = "yes" ]; then
115 with_vnc="--enable-vnc --enable-vnc-sasl --enable-vnc-jpeg"
116 else
117 with_vnc="--disable-vnc"
120 # To enable user mode networking use SLIRP=yes
121 if [ "$SLIRP" = "yes" ]; then
122 with_slirp="--enable-slirp"
123 else
124 with_slirp=""
127 CFLAGS="$SLKCFLAGS" \
128 CXXFLAGS="$SLKCFLAGS" \
129 ./configure \
130 --prefix=/usr \
131 --libdir=/usr/lib${LIBDIRSUFFIX} \
132 --sysconfdir=/etc \
133 --localstatedir=/var \
134 --docdir=/usr/doc/$PRGNAM-$VERSION \
135 --enable-gtk \
136 --enable-gtk-clipboard \
137 --enable-system \
138 --enable-kvm \
139 --disable-debug-info \
140 --enable-virtfs \
141 --enable-sdl \
142 --enable-malloc=jemalloc \
143 --enable-nettle \
144 --${uring}able-linux-io-uring \
145 --audio-drv-list=${AUDIODRIVERS} \
146 $with_slirp \
147 $with_vnc \
148 $targets
150 make V=1
151 make install DESTDIR=$PKG
153 # Remove empty /var
154 rm -rf $PKG/var
156 # install some udev rules for /dev/kvm
157 # Note: no udev rules for usb pasthrough when running qemu as non-root on linux hosts. See Section 2.11.2
158 # https://qemu.weilnetz.de/doc/qemu-doc.html
159 mkdir -p $PKG/lib/udev/rules.d/
160 sed "s/@GROUP@/$KVMGROUP/" $CWD/65-kvm.rules \
161 > $PKG/lib/udev/rules.d/65-kvm.rules
163 find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
164 | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
166 # create a symlink for qemu-kvm to support aqemu and such frontends
167 # even though qemu now has a gtk gui.
168 [ ! -z $KVMARCH ] && ln -s qemu-system-$KVMARCH $PKG/usr/bin/qemu-kvm
170 # set qemu-bridge-helper setuid if requested
171 if [ "$BRIDGE_HELPER_SETUID" = "yes" ]; then
172 chmod u+s $PKG/usr/libexec/qemu-bridge-helper
175 # move any generated man pages to their proper location
176 if [ -d $PKG/usr/share/man ]; then
177 mv $PKG/usr/share/man $PKG/usr
178 gzip -9 $PKG/usr/man/man?/*.?
181 # Add docs to the proper location
182 mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
183 cp -a COPYING* LICENSE MAINTAINERS README.rst docs/* \
184 $PKG/usr/doc/$PRGNAM-$VERSION
185 cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
187 mkdir -p $PKG/install
188 cat $CWD/slack-desc > $PKG/install/slack-desc
189 cat $CWD/doinst.sh > $PKG/install/doinst.sh
191 cd $PKG
192 /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
193 cd $OUTPUT
194 md5sum $PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE > $PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE.md5