summaryrefslogtreecommitdiff
path: root/libre/qemu-user-static/PKGBUILD
blob: 5080f5f7be846eda1449640787da73cf27ad68f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Maintainer (Arch:qemu): Tobias Powalowski <tpowa@archlinux.org>
# Contributor (Arch:qemu): Sébastien "Seblu" Luttringer <seblu@seblu.net>
# Maintainer: Luke Shumaker <lukeshu@parabola.nu>
# Contributor: Márcio Silva <coadde@hyperbola.info>

# "Do I need to rebuild?" : A flowchart
#
#                    ,--> pixman-static ------------------------------------,
#                    |      0.34.0-1.static2                                |
# qemu-user-static --+------------------------+----> pcre-static -----------+--> glibc
#  2.12.0-1.static1  |                        |        8.42-1.static1       |      2.27-3
#                    `--> glib2-static -------+----> libffi-static ---------+
#                           2.56.1-1.static1  |        3.2.1-2.static2      |
#                                             +----> libutil-linux-static --+
#                                             |        2.32-3.static1       |
#                                             `----> zlib ------------------'
#                                                      1:1.2.11-2

_pkgbase=qemu
pkgname=(qemu-user-static qemu-user-static-binfmt)
pkgdesc="A generic and open source machine emulator and virtualizer"
pkgver=2.12.0
pkgrel=1.static1
arch=(x86_64)
arch+=(i686 armv7h)
license=(GPL2 LGPL2.1)
url="http://wiki.qemu.org/"
makedepends=(pixman-static glib2-static pcre-static python2)
source=(https://download.qemu.org/qemu-$pkgver.tar.xz{,.sig}
        allow_elf64.patch)
sha256sums=('e69301f361ff65bf5dabd8a19196aeaa5613c1b5ae1678f0823bdf50e7d5c6fc'
            'SKIP'
            '59751f1ed26ea61b2a37ebee4be6979e584a450b611282138a0893aa9173e2e4')
validpgpkeys=('CEACC9E15534EBABB82D3FA03353C9CEF108B584')

case $CARCH in
  i?86) _corearch=i386 ;;
  x86_64) _corearch=x86_64 ;;
esac

prepare() {
  mkdir build-static
  mkdir -p extra-arch-static/usr/{bin,share/qemu}

  cd ${_pkgbase}-${pkgver}
  sed -i 's/vte-2\.90/vte-2.91/g' configure

  patch -p1 < ../allow_elf64.patch
}

build() {
  local flags=(
    --static
    --disable-system # disable building qemu-system-$CPU, we only want qemu-$CPU
    --disable-guest-agent # disable building qemu-ga
    --disable-tools # disable building the qemu-{io,nbd,img} tools
    --disable-blobs # disable installing firmware files used by system
    --disable-docs
    --disable-modules # modules imply dynamic linking

    # jemalloc-static isn't packaged
    --disable-jemalloc

    # These libraries are only used for system or tools, but even
    # though that's disabled, libqemuutil.a still tries to link
    # against them unless we specifically tell it not to (the linkage
    # would be removed at the final linker's tree-shaking).
    --disable-gcrypt
    --disable-nettle
  )
  _build static "${flags[@]}" \
    --audio-drv-list= \
    --disable-bluez \
    --disable-sdl \
    --disable-gtk \
    --disable-vte \
    --disable-opengl \
    --disable-virglrenderer
}

_build() (
  cd build-$1

  # qemu vs. make 4 == bad
  export ARFLAGS=rv

  # http://permalink.gmane.org/gmane.comp.emulators.qemu/238740
  export CFLAGS+=" -fPIC"

  ../${_pkgbase}-${pkgver}/configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib/qemu \
    --python=/usr/bin/python2 \
    --smbd=/usr/bin/smbd \
    --with-gtkabi=3.0 \
    --with-sdlabi=2.0 \
    --enable-modules \
    --enable-jemalloc \
    "${@:2}"

  make
)

package_qemu-user-static() {
  pkgdesc="QEMU user-mode emulation (static binaries)"

  provides=("qemu-static=$pkgver")
  replaces=(qemu-static)
  conflicts=(qemu-static)

  make -C build-static DESTDIR="$pkgdir" install "${@:2}"

  rm -vr -- \
     "$pkgdir"/usr/lib/ \
     "$pkgdir"/usr/share/

  local prog
  for prog in "$pkgdir"/usr/bin/*; do
    mv -nT -- "$prog" "${prog%-static}-static"
  done
}

package_qemu-user-static-binfmt() {
  pkgdesc="binfmt registration for QEMU user-mode emulation"
  depends=("qemu-user-static=$pkgver")

  provides=("binfmt-qemu-static=$pkgver")
  replaces=('binfmt-qemu-static')
  conflicts=('binfmt-qemu-static')

  cd ${_pkgbase}-${pkgver}

  install -d "$pkgdir"/usr/lib/binfmt.d

  ./scripts/qemu-binfmt-conf.sh \
       --qemu-path /usr/bin \
       --systemd ALL \
       --exportdir "$pkgdir"/usr/lib/binfmt.d \
       --credential yes

  # add the "-static" suffix
  sed -i 's/:[^:]*$/-static&/' --  "$pkgdir"/usr/lib/binfmt.d/*.conf
}