APKBUILD 5.87 KB
Newer Older
Leonardo Arena's avatar
Leonardo Arena committed
1
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
Leonardo Arena's avatar
Leonardo Arena committed
2
pkgname=libvirt
Natanael Copa's avatar
Natanael Copa committed
3
pkgver=1.2.0
4
_ver="${pkgver/_rc/-rc}"
5
pkgrel=1
Leonardo Arena's avatar
Leonardo Arena committed
6 7
pkgdesc="A virtualization API for several hypervisor and container systems"
url="http://libvirt.org/"
Natanael Copa's avatar
Natanael Copa committed
8
arch="all"
Leonardo Arena's avatar
Leonardo Arena committed
9
license="LGPL"
10 11 12 13 14 15 16 17
_daemon_deps="bridge-utils dmidecode iptables"
_client_deps="pm-utils gnutls-utils netcat-openbsd"
depends=""
makedepends="augeas-dev bridge-utils cyrus-sasl-dev device-mapper
	e2fsprogs-dev gnutls-dev libcap-ng-dev libgpg-error-dev
	netcf-dev libnl-dev libxml2-dev libxslt-dev libtasn1-dev
	lvm2-dev lxc-dev gnutls-dev libgcrypt-dev parted-dev perl pkgconfig
	udev-dev zlib-dev yajl-dev libpcap-dev curl-dev libpciaccess-dev
18
	polkit-dev readline-dev libtirpc-dev
19 20
	$_daemon_deps $_client_deps
	"
21
install="$pkgname.post-install"
22
subpackages="$pkgname-dev $pkgname-doc $pkgname-client $pkgname-daemon
Natanael Copa's avatar
Natanael Copa committed
23
	$pkgname-lang $pkgname-lxc $pkgname-qemu $pkgname-uml $pkgname-vbox"
24
source="http://libvirt.org/sources/$pkgname-$pkgver.tar.gz
Leonardo Arena's avatar
Leonardo Arena committed
25
	libvirt.confd
26
	libvirt.initd
27
	uclibc-physmem.patch
28
	"
Leonardo Arena's avatar
Leonardo Arena committed
29

30
if [ "$CARCH" = "x86_64" ]; then
31 32 33
	subpackages="$subpackages $pkgname-xen"
	makedepends="$makedepends xen-dev"
fi
34
subpackages="$subpackages $pkgname-common-drivers:_common_drivers"
35

36
_builddir="$srcdir"/$pkgname-$pkgver
Leonardo Arena's avatar
Leonardo Arena committed
37

38
prepare() {
39
        cd "$_builddir" || return 1
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        for patch in $source; do
                case $patch in
                # we concider patches with uclibc in its name
                # only usefull on uclibc install
                *uclibc*.patch)
                        if [ "$ALPINE_LIBC" != "eglibc" ]; then
                                msg "Applying patch $patch"
                                patch -p1 -i "$srcdir"/$patch || return 1
                        fi
                        ;;
                *.patch)
                        msg "Applying patch $patch"
                        patch -p1 -i "$srcdir"/$patch || return 1
                        ;;
                esac
        done
56
}
Leonardo Arena's avatar
Leonardo Arena committed
57 58 59

build() {
	cd "$_builddir"
60 61
	export CFLAGS="$CFLAGS `pkgconf --cflags libtirpc`"
	export LDFLAGS="$LDFLAGS -lm `pkgconf --libs libtirpc`"
62 63 64 65
	local _xen_opt=
	if [ "$CARCH" = x86_64 ]; then
		_xen_opt="--with-libxl"
	fi
66 67 68 69
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
Leonardo Arena's avatar
Leonardo Arena committed
70 71 72
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
73
		--libexec=/usr/lib/"$pkgname" \
74
		$_xen_opt \
75
		--with-polkit \
76
		|| return 1
77
	make || return 1
Leonardo Arena's avatar
Leonardo Arena committed
78 79 80 81
}

package() {
	cd "$_builddir"
Natanael Copa's avatar
Natanael Copa committed
82
	make DESTDIR="$pkgdir" install || return 1
Natanael Copa's avatar
Natanael Copa committed
83
	find "$pkgdir" -name '*.la' -delete
Leonardo Arena's avatar
Leonardo Arena committed
84 85 86 87
	install -D -m755 $srcdir/$pkgname.initd $pkgdir/etc/init.d/libvirtd
	install -D -m755 $srcdir/$pkgname.confd $pkgdir/etc/conf.d/libvirtd
}

88 89 90 91 92 93 94
dev() {
	default_dev
	mkdir -p "$subpkgdir"/usr/share/libvirt
	mv "$pkgdir"/usr/share/libvirt/api \
		"$subpkgdir"/usr/share/libvirt/
}

95 96 97
daemon() {
	cd "$_builddir"
	pkgdesc="libvirt daemon package"
98
	depends="libvirt-client $_daemon_deps"
99 100 101 102 103 104
	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
105 106
	mv "$pkgdir"/etc/$pkgname/libvirtd.conf "$subpkgdir"/etc/libvirt/
	mv "$pkgdir"/usr/sbin/libvirtd "$subpkgdir"/usr/sbin/
107 108 109 110 111 112
	mv "$pkgdir"/etc/logrotate.d/libvirtd "$subpkgdir"/etc/logrotate.d/
}

client() {
	cd "$_builddir"
	pkgdesc="libvirt client package"
113
	depends="libvirt $_client_deps"
114
	replaces="libvirt"
115 116
	mkdir -p "$subpkgdir"/etc/$pkgname "$subpkgdir"/usr/bin \
		"$subpkgdir"/usr/lib
117 118
	mv "$pkgdir"/etc/$pkgname/$pkgname.conf "$subpkgdir"/etc/libvirt/
	mv "$pkgdir"/usr/bin/* "$subpkgdir"/usr/bin/
119 120 121
	mv "$pkgdir"/usr/lib/lib*.so.* "$subpkgdir"/usr/lib/ || return 1
}

122
_mv_driver() {
Natanael Copa's avatar
Natanael Copa committed
123
	local _name="$1" _drivers="$2" _pkg="$3"
124
	pkgdesc="$_name driver for libvirt"
125 126
	depends="$pkgname-daemon=$pkgver-r$pkgrel
		$pkgname-common-drivers=$pkgver-r$pkgrel"
127 128 129 130 131 132 133 134 135 136
	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
Natanael Copa's avatar
Natanael Copa committed
137
	local _d
138
	cd "$pkgdir"
Natanael Copa's avatar
Natanael Copa committed
139
	for _d in $_drivers; do
140 141 142 143
		find * -name "*$_d[.-]*" -o -name "*$_d" | while read _f; do
			mkdir -p "$subpkgdir"/${_f%/*}
			mv "$pkgdir"/$_f "$subpkgdir"/$_f || return 1
		done
Natanael Copa's avatar
Natanael Copa committed
144
	done
145 146
}

147 148 149 150 151
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; }
152

153 154 155 156 157 158 159 160 161
_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/
Natanael Copa's avatar
Natanael Copa committed
162 163
}

Natanael Copa's avatar
Natanael Copa committed
164
md5sums="f74f78059def4e68d69b975ad6e6c3e2  libvirt-1.2.0.tar.gz
Leonardo Arena's avatar
Leonardo Arena committed
165
1c84a7baeafe0a7f4e9d7ae5180311b7  libvirt.confd
Leonardo Arena's avatar
Leonardo Arena committed
166
d897df38c7e7fa1a297aa551108633c9  libvirt.initd
Natanael Copa's avatar
Natanael Copa committed
167
df9cbfaf8a6e520a4822914a300add4d  uclibc-physmem.patch"
Natanael Copa's avatar
Natanael Copa committed
168
sha256sums="a8e578ae7861db2ac5f454073293d2ef3229fd3f6c4f9029101763244db22ddd  libvirt-1.2.0.tar.gz
Natanael Copa's avatar
Natanael Copa committed
169 170
851ab3f9678f0fa9c3ee03f7fc7bd00c4ee86d5f0777eecf9eb1ffe3243adfd1  libvirt.confd
e9fad203434ffaa6afe524e42a9fb6594edad61cb02b1ca60a68d1a7fe0c31ab  libvirt.initd
Natanael Copa's avatar
Natanael Copa committed
171
807005a8669b7396c9af43ddb2534bb0f073f1e97a5c8b1d9eefc1949f3c2df8  uclibc-physmem.patch"
Natanael Copa's avatar
Natanael Copa committed
172
sha512sums="834274b0249eb39439d21cd9b494fa2acbaee9e5337557b8d57977b483f3e5d00fd0a6743f8f4a02e826114c15d2468ab0c9385e4e4c9537abba18da3d8c5fa6  libvirt-1.2.0.tar.gz
Natanael Copa's avatar
Natanael Copa committed
173 174
9aba6ab73219a635c64a340ee8887356e644445c9128734cbce73f5d54778378da2f10a190365ad88a7db8bc95b1fb17f0c6ca41fc41bb786c09e1afe84d65dc  libvirt.confd
f48c97f93ef4509a86eda6200b3aae5b2c0c6263403bde933b770fd62240dca27bc439bd29b440ea6a47c8337f8b4511230ed915cb5ff54d9a1cf311863f6fa1  libvirt.initd
Natanael Copa's avatar
Natanael Copa committed
175
4c885e72dcb11f8523a267917315d4874812eee289fb00075334c1728d0da9bd0e5db6c52d6e3c39bd3fe66d5ccadf9e26ec9dcaa855397e211b9bd1173ac72d  uclibc-physmem.patch"