File PKGBUILD of Package openrc-devel

# Maintainer: artoo <flower_of_life@gmx.net>

# file vars for easy update
_Cgit=git-daemon.confd
_Igit=git-daemon-r1.initd
_Cmy=mysql-5.1.53-conf.d
_Imy=mysql-5.1.67-init.d-r1
_Csvn=svnserve.confd
_Isvn=svnserve.initd2

_pgs_ver=2.6
_dev_uri="http://dev.gentoo.org/~titanofold"

_gentoo_uri="http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86"

pkgbase=openrc-devel
pkgname=('git-openrc'
	'mysql-openrc'
	'postgresql-openrc'
	'subversion-openrc')
pkgver=20140705
pkgrel=1
pkgdesc="OpenRC init scripts"
arch=('any')
url="https://github.com/udeved/pkgbuilds"
license=('GPL2')
groups=('openrc' 'openrc-devel')
conflicts=('openrc'
	  'openrc-git'
	  'openrc-arch-services-git'
	  'initscripts'
	  'systemd-sysvcompat')
source=("${_gentoo_uri}/dev-vcs/git/files/${_Cgit}"
	"${_gentoo_uri}/dev-vcs/git/files/${_Igit}"
	"${_gentoo_uri}/dev-db/mysql-init-scripts/files/${_Cmy}"
	"${_gentoo_uri}/dev-db/mysql-init-scripts/files/${_Imy}"
	"${_gentoo_uri}/dev-vcs/subversion/files/${_Csvn}"
	"${_gentoo_uri}/dev-vcs/subversion/files/${_Isvn}"
	"${_dev_uri}/postgresql-initscript-${_pgs_ver}.tbz2")

pkgver() {
  date +%Y%m%d
}

_shebang='s|#!/sbin/runscript|#!/usr/bin/runscript|'
_runpath='s|/var/run|/run|g'
_binpath='s|/usr/sbin|/usr/bin|g'

package_git-openrc() {
  pkgdesc="OpenRC git-daemon init script"
  depends=('git' 'openrc-core')
  backup=('etc/conf.d/git-daemon')
  install=git.install

  install -Dm755 "${srcdir}/${_Cgit}" "${pkgdir}/etc/conf.d/git-daemon"
  install -Dm755 "${srcdir}/${_Igit}" "${pkgdir}/etc/init.d/git-daemon"

  local _p1='s|/var/git|/srv/git|'
  sed -e "${_p1}" -i "${pkgdir}/etc/conf.d/git-daemon"
  sed -e "${_shebang}" -e "${_binpath}" -e "${_runpath}" -i "${pkgdir}/etc/init.d/git-daemon"
}

package_mysql-openrc() {
  pkgdesc="OpenRC mysql init script"
  depends=('mysql' 'openrc-core')
  optdepends=('bind-openrc: bind initscript')
  backup=('etc/conf.d/mysql')
  install=mysql.install

  install -Dm755 "${srcdir}/${_Cmy}" "${pkgdir}/etc/conf.d/mysql"
  install -Dm755 "${srcdir}/${_Imy}" "${pkgdir}/etc/init.d/mysql"

  local _p1='s|/sbin/mysqld|/bin/mysqld|g'
  sed -e "${_shebang}" -e "${_p1}" -i "${pkgdir}/etc/init.d/mysql"
}

package_postgresql-openrc() {
  pkgdesc="OpenRC postgresql init script"
  depends=('postgresql' 'openrc-core')
  backup=('etc/conf.d/postgresql')
  install=postgresql.install

  install -Dm755 "${srcdir}/postgresql.confd" "${pkgdir}/etc/conf.d/postgresql"
  install -Dm755 "${srcdir}/postgresql.init" "${pkgdir}/etc/init.d/postgresql"

  local _p1='s|/var/lib/postgresql/@SLOT@/data|/var/lib/postgres/data|' \
	_p2='s|/etc/postgresql-@SLOT@/|/var/lib/postgres/data|'
  sed -e "${_p1}" -e "${_p2}" -i "${pkgdir}/etc/conf.d/postgresql"

  _p1='s|/usr/lib/postgresql-@SLOT@/bin/pg_ctl|/usr/bin/pg_ctl|'
  _p2='s|/usr/lib/postgresql-@SLOT@/bin/postgres|/usr/bin/postgres|'
  sed -e "${_shebang}" -e "${_p1}" -e "${_p2}" -i "${pkgdir}/etc/init.d/postgresql"
}

package_subversion-openrc() {
  pkgdesc="OpenRC svnserve init script"
  depends=('subversion' 'openrc-core')
  backup=('etc/conf.d/svn')
  install=subversion.install

  install -Dm755 "${srcdir}/${_Csvn}" "${pkgdir}/etc/conf.d/svn"
  install -Dm755 "${srcdir}/${_Isvn}" "${pkgdir}/etc/init.d/svn"

  local _p1='s|/var/svn|/srv/svn|g'
  sed -e "${_p1}" -i ${pkgdir}/etc/conf.d/svn
  local _p2='s|-apache|-http|g' \
	_p3='s|/run/svnserve.pid|/run/svnserve/svnserve.pid|g' \
	_p4='s/--make-pidfile//'
  sed -e "${_shebang}" -e "${_binpath}" -e "${_runpath}" -e "${_p1}" -e "${_p2}" -e "${_p3}" -e "${_p4}" -i "${pkgdir}/etc/init.d/svn"
}
sha256sums=('9bf02170dcf73e930a992adf44326ed7c27159d41a503ca4d9371861ee5030c9'
            '421e68201619bfbf7535d8b1a0030390b7ffab998e025f7cbd7e879c677c2819'
            '45da613841969adf564f9f2f08257f749539651ee2fae85266f59fdd7a6f8123'
            '6c60bf7746a63f0daac26e4de132e675d6aac9f04e2b4bc758776ab67f61146a'
            '45f2dc1a718aed885559e71d98112e670c92bd6b4f19c5cf593eced6cd2bbd97'
            '8f123253c3bfb9bbe87210a9e1facc7f52df371747dbc188396740a5cf4fa713'
            '0ab0e175a2ed735c330fd2e1c659c1130ae7217fea8d3804d5b5eb74c68ddac1')