aboutsummaryrefslogtreecommitdiffstats
path: root/community/libvirt/APKBUILD
blob: 9ed575335f9f980a244f3b1e71f02ff210723258 (plain) (blame)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=libvirt
pkgver=7.0.0
_ver="${pkgver/_rc/-rc}"
pkgrel=0
pkgdesc="A virtualization API for several hypervisor and container systems"
url="https://libvirt.org/"
arch="all !mips !mips64 !s390x" # polkit
options="!check"
license="LGPL-2.1-or-later"
_daemon_deps="bridge-utils dmidecode dnsmasq ip6tables iptables"
_client_deps="pm-utils gnutls-utils netcat-openbsd"
depends="lvm2"
depends_dev="libtirpc-dev"
makedepends="augeas-dev cyrus-sasl-dev device-mapper
	e2fsprogs-dev gnutls-dev libcap-ng-dev libgpg-error-dev
	netcf-dev libnl3-dev libxml2-dev libxslt-dev libtasn1-dev
	lvm2-dev lxc-dev libgcrypt-dev parted-dev perl pkgconfig
	eudev-dev zlib-dev yajl-dev libpcap-dev curl-dev libpciaccess-dev
	polkit-dev readline-dev linux-headers jansson-dev
	$depends_dev perl-xml-xpath
	fuse-dev util-linux libxml2-utils bash-completion $_daemon_deps $_client_deps
	rpcsvc-proto py3-docutils meson ninja
	"
install="$pkgname.post-install"
subpackages="$pkgname-dbg $pkgname-static $pkgname-libs $pkgname-dev $pkgname-doc $pkgname-client $pkgname-daemon
	$pkgname-lang $pkgname-lxc $pkgname-qemu $pkgname-uml::noarch $pkgname-vbox
	$pkgname-bash-completion:bashcomp:noarch"
source="https://libvirt.org/sources/libvirt-$pkgver.tar.xz
	libvirt.confd
	libvirt.initd
	libvirt-guests.confd
	libvirt-guests.initd
	virtlogd.initd
	virtlockd.initd
	musl-fix-includes.patch
	stderr-fix.patch
	libvirt-fork-exec-deadlock.patch
	libvirt-6.0.0-fix_paths_in_libvirt-guests_sh.patch
	"
if [ "$CARCH" = "x86_64" ]; then
	subpackages="$subpackages $pkgname-xen"
	makedepends="$makedepends xen-dev zfs"
fi
subpackages="$subpackages $pkgname-common-drivers:_common_drivers"

# secfixes:
#   6.8.0-r0:
#     - CVE-2020-25637
#   6.6.0-r0:
#     - CVE-2020-14339
#   5.5.0-r0:
#     - CVE-2019-10168
#     - CVE-2019-10167
#     - CVE-2019-10166
#     - CVE-2019-10161

prepare() {
	default_prepare
	mkdir -p build
}

build() {
	cd build
	# qemu sets libexec dir to /usr/lib/qemu
	export ac_cv_path_QEMU_BRIDGE_HELPER="/usr/lib/qemu/qemu-bridge-helper"
	[ "$CARCH" = x86_64 ] && local _xen_opt="--with-libxl"
	[ "$CARCH" = x86_64 ] && local _zfs_opt="--with-storage-zfs"
	meson \
		--prefix=/usr \
		--libexec=/usr/lib/$_pkgname \
		--sysconfdir=/etc
	ninja
}

package() {
	cd build
	DESTDIR="$pkgdir" ninja install
	install -Dm755 $srcdir/$pkgname.initd $pkgdir/etc/init.d/libvirtd
	install -Dm644 $srcdir/$pkgname.confd $pkgdir/etc/conf.d/libvirtd
	install -Dm755 $srcdir/$pkgname.initd $pkgdir/etc/init.d/libvirt-guests
	install -Dm644 $srcdir/$pkgname.confd $pkgdir/etc/conf.d/libvirt-guests

	install -Dm755 $srcdir/virtlogd.initd $pkgdir/etc/init.d/virtlogd
	install -Dm755 $srcdir/virtlockd.initd $pkgdir/etc/init.d/virtlockd

	install -d "$pkgdir"/lib/modules-load.d
	echo "tun" > "$pkgdir"/lib/modules-load.d/libvirt.conf

	rm -rf "$pkgdir"/etc/sysconfig
	rm -rf "$pkgdir"/usr/lib/charset.alias
	rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true
}

dev() {
	default_dev
	mkdir -p "$subpkgdir"/usr/share/libvirt
	mv "$pkgdir"/usr/share/libvirt/api \
		"$subpkgdir"/usr/share/libvirt/
}

daemon() {
	cd "$builddir"
	pkgdesc="libvirt daemon package"
	depends="libvirt-client $_daemon_deps"
	replaces="libvirt"
	mkdir -p "$subpkgdir"/etc/$pkgname \
	 "$subpkgdir"/etc/logrotate.d \
	 "$subpkgdir"/usr/sbin
	mv "$pkgdir"/etc/init.d "$subpkgdir"/etc
	mv "$pkgdir"/etc/conf.d "$subpkgdir"/etc
	mv "$pkgdir"/lib/modules-load.d "$subpkgdir"/lib
	mv "$pkgdir"/etc/$pkgname/libvirtd.conf "$subpkgdir"/etc/libvirt/
	mv "$pkgdir"/usr/sbin/libvirtd "$subpkgdir"/usr/sbin/
	mv "$pkgdir"/etc/logrotate.d/libvirtd "$subpkgdir"/etc/logrotate.d/
}

client() {
	cd "$builddir"
	pkgdesc="libvirt client package"
	depends="libvirt $_client_deps"
	replaces="libvirt"
	mkdir -p "$subpkgdir"/etc/$pkgname "$subpkgdir"/usr/bin \
		"$subpkgdir"/usr/lib
	mv "$pkgdir"/etc/$pkgname/$pkgname.conf "$subpkgdir"/etc/libvirt/
	mv "$pkgdir"/usr/bin/* "$subpkgdir"/usr/bin/
}

static() {
	pkgdesc="$pkgname static libraries"
	mkdir -p "$subpkgdir"/usr/lib
	cd "$pkgdir"
	for _lib in  $(find . -name '*.a'); do
		mkdir -p "$subpkgdir"/${_lib%/*}
		mv "$_lib" "$subpkgdir"/${_lib%/*}/
	done
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"
	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/bash-completion \
		"$subpkgdir"/usr/share/
}

_mv_driver() {
	local _name="$1" _drivers="$2" _pkg="$3"
	pkgdesc="$_name driver for libvirt"
	depends="$pkgname-daemon=$pkgver-r$pkgrel
		$pkgname-common-drivers=$pkgver-r$pkgrel"
	replaces="libvirt"
	if [ -n "$_pkg" ]; then
		install_if="$pkgname-daemon=$pkgver-r$pkgrel $_pkg"
	else
		install_if=
	fi
	local _dir=/usr/lib/libvirt/connection-driver
	mkdir -p "$subpkgdir"/$_dir \
		"$subpkgdir"/etc/libvirt \
		"$subpkgdir"/etc/logrotate.d
	local _d
	cd "$pkgdir"
	for _d in $_drivers; do
		find * -name "*$_d[.-]*" -o -name "*$_d" | while read _f; do
			mkdir -p "$subpkgdir"/${_f%/*}
			mv "$pkgdir"/$_f "$subpkgdir"/$_f
		done
	done
}

qemu() { _mv_driver "QEMU" qemu qemu; }
xen() { _mv_driver "XEN" "libxl xen" xen; }
lxc() { _mv_driver "LXC" lxc lxc; }
uml() { _mv_driver "UML" uml; }
vbox() { _mv_driver "VirtualBox" vbox; }

_common_drivers() {
	pkgdesc="Common libvirt daemon drivers"
	replaces="libvirt"
	mkdir -p "$subpkgdir"/usr/lib/libvirt \
		"$subpkgdir"/etc/libvirt/nwfilter
	mv "$pkgdir"/usr/lib/libvirt/connection-driver \
		"$subpkgdir"/usr/lib/libvirt/
	mv "$pkgdir"/etc/libvirt/nwfilter \
		"$subpkgdir"/etc/libvirt/
}

sha512sums="dd6db5ec4971cf4c6059795fd81d5a3a889b10740e34c3c92271eda1c683c99df2c8f923398065d8a7c4f987a20eb1da617d5297ba8ea5a31f154412af50c343  libvirt-7.0.0.tar.xz
c3647366e589f2134599baefcbd7ec480cbc0830c71f95cd903cacb28e463d4cd8d972fbd1db81aa17eef81c1f701bd3937c9b8eb71d56ee630e1ed8b89887e9  libvirt.confd
95debe7600826a6783334f5bf042fde81d0a01f2c599eb8d2f66e0597cf52116c13d4d5cf173784a360d134a7c44d9bf828e8f78f7e10a1ad9dada537aead480  libvirt.initd
78f419a89de7aabaad860903c24f1c070786fc1296d987e61dd537705b0e7f71a46c315888028f3826c3417e42861ca8471788be4ec5695e98427c5f18ae63fc  libvirt-guests.confd
ec2bc46d72afa61513983b777e2d49da618a35a4687bc75674b3a49ababd4e2e387661010d342fee86c7a73d259644985a263a6c2976e29a436d88921bb040b0  libvirt-guests.initd
f93313c387c21bafb760f599942f1cdecfe952af80af42a28e8525118e5a7fd512d9f909039d8b15f1a544957f1d70a0728c55de2bae41a87e5be6dbbb4f6208  virtlogd.initd
d8ef64d76e8be521a6551893cc7c6aa7e5d8c627a9aed87beefefc126798dc0f98bf420609b6afc027ad96cca347a1c5db8f703d09853efde4d1a6a35572fbf1  virtlockd.initd
dfe042c596028125bf8548115de2922683829c4716f6b0efb8efc38518670e3e848481661b9714bb0664c1022b87e8f3c0773611fe10187b0bc588e2336ada0c  musl-fix-includes.patch
d32551d56eae2c33bab7571964f76421336967918c293cd1d18fc66626a7ead3551b5672a9e3fc3d8b7bca82cc0abb17e428ee8271d04d73bc06fd16309918b3  stderr-fix.patch
ec1ff051331bee88b868275cc01a613c6b30bca6014c6dd74f0d48c40980615152497bce94b11c9f0e0644c92b937c949c3e52e023fbd865ab53c020e120cbc4  libvirt-fork-exec-deadlock.patch
dc80c9fc459207dd1ff77548054ea5a51c41a2d36e1b8917eca5f69293a86168af3da47466d8ff954a8b2e0ead9f28ed7d6c2c3671cf67d0ebb4039003a0dde2  libvirt-6.0.0-fix_paths_in_libvirt-guests_sh.patch"