# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer:
setvar pkgname = 'opennebula'
setvar pkgver = '4.9.80'
setvar pkgrel = '2'
setvar pkgdesc = ""Virtual management infrastructure as a service (IaaS) toolkit for cloud computing""
setvar url = ""http://opennebula.org""
setvar arch = """"
setvar license = ""Apache""
setvar depends = ""ruby-json ruby-sequel ruby-nokogiri ruby-sqlite ruby-mysql2 ruby-nokogiri
	ruby-rack14 ruby-sinatra ruby-thin ruby-crack ruby-thin ruby-net-ldap
	ruby-uuidtools ruby-curb ruby-amazon-ec2 ruby-io-console bash
	curl wget""
setvar depends_dev = ""xmlrpc-c-dev sqlite-dev openssl-dev libxml2-dev curl-dev""
setvar makedepends = ""$depends_dev scons ruby bash""
setvar install = ""opennebula.pre-install""
setvar pkgusers = 'oneadmin'
setvar pkggroups = 'oneadmin'
setvar subpackages = ""$pkgname-dev $pkgname-doc $pkgname-node-kvm:node_kvm""
setvar source = ""http://downloads.opennebula.org/packages/opennebula-$pkgver/opennebula-$pkgver.tar.gz
	opennebula.initd
	opennebula.confd
	getopt.patch
	ssh.config
	one_auth""

setvar _builddir = ""$srcdir"/opennebula-$pkgver"

proc prepare {
	local i
	cd $_builddir
	for i in $source {
		case (i) {
		*.patch { msg $i; patch -p1 -i "$srcdir"/$i || return 1}
		}
	}
}

proc build {
	cd $_builddir
	scons -j${JOBS:-2} || return 1
}

proc package {
	cd $_builddir"
	DESTDIR=$pkgdir" ./install.sh \
		-u $pkgusers -g $pkggroups || return 1
        install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname || return 1
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname || return 1
	install -o $pkgusers -g $pkggroups -d \
		"$pkgdir"/var/lib/one/.ssh \
		"$pkgdir"/var/lib/one/.one || return 1
	install -m600 -o $pkgusers -g $pkggroups -D \
		"$srcdir"/ssh.config \
		"$pkgdir"/var/lib/one/.ssh/config || return 1
	install -m600 -o $pkgusers -g $pkggroups -D \
		"$srcdir"/one_auth \
		"$pkgdir"/var/lib/one/.one/one_auth || return 1
	# set the default emulator
	echo -e "\nEMULATOR = /usr/bin/qemu-system-x86_64" >> \
		"$pkgdir"/etc/one/vmm_exec/vmm_exec_kvm.conf || return 1
}

proc node_kvm {
	setvar pkgdesc = ""KVM node for OpenNebula""
	setvar arch = ""noarch""
	setvar install = ""opennebula-node-kvm.pre-install""
	setvar depends = ""ruby openssh qemu-x86_64 libvirt-qemu procps bash""
	mkdir -p $subpkgdir
}

setvar md5sums = ""43ef6a658b5ae121ad4461178abdbd88  opennebula-4.9.80.tar.gz
44ecaf28b2f0293d55aa401e0ec49948  opennebula.initd
0b9c5ef240d1cb13d35b21c081e756ad  opennebula.confd
8f1a346b4020b7c3e2853f42cc38d35b  getopt.patch
37b82927bd6b0c1dd9cbde2a3728e719  ssh.config
3ae86352df192e0aae9fdee58532610e  one_auth""
setvar sha256sums = ""8e69dedd69001bce6d224661649bc3f5b1608bf87e69dd1ac5ff1e774745a3c9  opennebula-4.9.80.tar.gz
20ea2103ccd37988c1426a7e39f37c9923465e1769cc3669dc47751876f3266a  opennebula.initd
296d445dfaee90c114a5cd8ecb208c495a3a22dabde13ec9ece623368f5627a1  opennebula.confd
072ad62b3ef18eb3c9d33b47acb7a867d076c3083ce561bdbffcf98bb852d663  getopt.patch
e934a2b5083a04126e5948a6abf1adfa8e557bb086010453824b44282dafdc8b  ssh.config
4af1f964af87ed62f2b953e8b0269b2ad8dfbcba57b5eebddcb9e8f0cc4379da  one_auth""
setvar sha512sums = ""54aff34770a29262a4e3ef886957044489f4d4b1905e847522adff6ad1012df21e9c2caa46bc060fbbbb9d1ce23cb41768f28ca90af5c4e5844b054c0d0d7349  opennebula-4.9.80.tar.gz
2b87e93bce79325ecd57be053e08cc626bdec2bfd9048635452957efc88e5104cbbf74d3c2757e3e42738276b7bd37db2c9845e85570b7ff5f27117dad1d06e2  opennebula.initd
0b5c98642a74a804e36729f0a0abb5434a55ecaa5a9c29620f8940ba69b141f47fa1693a63bc22298e735bba61d3f0b15c82278b5d8071eeb19f02398332f6ae  opennebula.confd
7f39da47a89011bd368217bc7cb33a1647b49d43960bf47f22b742dfa109d04e9b18ad0827d5d3b4c05bd6b31d723322b9c899520fbb2db5b4217a38bab9eefe  getopt.patch
9da0adff52401e5bd50b25a0ec240e781257330f9084c55c6ca741c9179c29681ee6855bc3607d05949124559828f6fdd029b3ea01b881f472292c96489c64cf  ssh.config
8aaab56ae8c8bf7d1c06a47f4f3339c9e62486270b9ab00751dd21fabee19824f05b20b3d979741886539570e761fd3227acd5ef55a04a9273f0b706f93c813f  one_auth""