# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=ocfs2-tools
pkgver=1.6.4
pkgrel=2
pkgdesc="Oracle Cluster File System 2 utilities"
url="http://oss.oracle.com/projects/ocfs2-tools"
arch=""
license="GPL-2.0"
depends=
depends_dev="e2fsprogs-dev glib-dev ncurses-dev readline-dev"
makedepends="$depends_dev"
install=
subpackages="$pkgname-dev $pkgname-doc"
source="http://oss.oracle.com/projects/ocfs2-tools/dist/files/source/v${pkgver%.*}/$pkgname-$pkgver.tar.gz
	build.patch
	$pkgname.initd
	$pkgname.confd
	$pkgname.cluster-conf
	ocfs2-tools-1.6-operations-missing-include.patch
	ocfs2-tools-1.6.4-umode_t.patch"

_builddir="$srcdir"/$pkgname-$pkgver

prepare() {
	cd "$_builddir"
	update_config_sub || return 1
	local i
	for i in ../*.patch
	do
		msg "Applying patch $i"
		patch -p1 -i $i || return 1
	done

	sed -i 's%sys/raw.h%linux/raw.h%' fswreck/include/main.h || return 1
	sed -i 's%sys/raw.h%linux/raw.h%' debugfs.ocfs2/include/main.h || return 1
	sed -i 's%sys/raw.h%linux/raw.h%' o2info/operations.c || return 1
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--enable-ocfs2console=yes \
		--enable-dynamic-fsck=yes \
		--enable-dynamic-ctl=yes \
		--disable-glibtest \
		|| return 1
	make -j1 || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install

	# remove the 2 lines below (and this) if there is no init.d script
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/o2cb
	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/o2cb
	install -m644 -D "$srcdir"/$pkgname.cluster-conf "$pkgdir"/etc/ocfs2/cluster.conf
}

md5sums="2e94423507b63fcc08f93c094e789be8  ocfs2-tools-1.6.4.tar.gz
c938040f0e77a4bb23e952c8f99b6cc5  build.patch
bf827283ab0c5de69df2eacbcb598b79  ocfs2-tools.initd
d81b6ab068ec92a137b58c9ad56c4637  ocfs2-tools.confd
189e433cf001465f1565faae2e6e10ac  ocfs2-tools.cluster-conf
f1d6bd7f02e69b31b8a103d18c7209f6  ocfs2-tools-1.6-operations-missing-include.patch
cd4710efdb07660459fda1b514cfa8a6  ocfs2-tools-1.6.4-umode_t.patch"
sha256sums="dda9db208312e3e5f4f55ee77e66e7b35b9cc10421bc02065a6c168e42b24755  ocfs2-tools-1.6.4.tar.gz
8e6a51ff12f1f08945102af0008c83e843aa20b25649adc157be92f27c2a3a42  build.patch
c8852f8434c27d34996891fe404c495eaacc06b6e1df0f07fbf2b1675bda1b26  ocfs2-tools.initd
9e090d955f51cdb32f9dd7eb20fec326b793daa90fd7df02a6e437fa00d269b7  ocfs2-tools.confd
5e79d4eaac95fd81f833ca9e08f19f741e88f6c86ebf1b5c91465974b6a8b11f  ocfs2-tools.cluster-conf
f82b6d5f5a97b9ae139ca041a60c3553a07dcf1f3821a12ae1d8c17492eff1f9  ocfs2-tools-1.6-operations-missing-include.patch
a4ba2f4aaa16018a08da9cea689c1f7d9d890691a53b74ceb3eddd6a8bebbc41  ocfs2-tools-1.6.4-umode_t.patch"
sha512sums="3b5b834e23467736b2fc522449f3d86b9a4b4764a66ec6812e4ecf497f8d43c2fb1aba1955c6030336d88463e720a5ace0b7cde48853cf3b482c6727ed86a649  ocfs2-tools-1.6.4.tar.gz
6a6b872fe0bb9ef8f3866881619145551ac4b77811082b24be08ecf351d22cd9dd6b239a2c6c962606a0282c5cb16e96ff5aac30a18c04fdf1bc0d1945841018  build.patch
e6fd44358ba5a38446a8bea60c493f4ef9b7a2d7c0076116e91f0edabb66da1fd90be884a46052592f69e338887d4df5c7b7c0b01fadf837fdbc7906a96de52a  ocfs2-tools.initd
e510f08a9adc2d7c07e7b8a4d2c503c5a130a156ab1bf1cf45d8480dd94490968f718e966d0bae090a883ff36768e17971415f9905bd5dcf8632f16f7c0b931e  ocfs2-tools.confd
f844e5389e0b42d6f91a1335bd2ef4d2666e5b883c999d05acd3bc63ad901bc5838aa4da35bb1d069463d7cc7dcfa277dbaa938b5953e8d420a37cfbb30f24f3  ocfs2-tools.cluster-conf
41b5e0d2eae738a8e05b6377e6dd4fc79592c6fc7b62dbc1ea6d7bd1fdb80122bc2f915748e64e30c9e964a1ebc73a65d81b5409fd499a959b3015d8c0683ead  ocfs2-tools-1.6-operations-missing-include.patch
7ec59c84a64d4e4cae0318a77e652d0172155fe4693c9dece0058ee1f92794bd3ed9c0ede230e98c3d635bd735b9bd83bd63a657db25575f1a6de7a50c407a4f  ocfs2-tools-1.6.4-umode_t.patch"
