# $Id: PKGBUILD 82 2009-07-17 19:56:55Z aaron $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Alois Belaska <lloyd@centrum.cz>

pkgname=sqlitemanager
pkgver=1.2.0
pkgrel=3
pkgdesc="Multilingual web based tool to manage SQLite database"
arch=('i686' 'x86_64')
license=('GPL')
depends=('php')
backup=(etc/httpd/sqadmin/config.db srv/www/sqadmin/include/config.inc.php)
url='http://sourceforge.net/projects/sqlitemanager'
source=(http://downloads.sourceforge.net/sqlitemanager/SQLiteManager-$pkgver.tar.gz)
md5sums=('cb938d51f9cd61e8954dcf296528b883')

build() {
  cd $startdir/src/SQLiteManager-$pkgver
  
  mkdir -p $startdir/pkg/srv/www/sqadmin/dbs
  mkdir -p $startdir/pkg/etc/httpd/sqadmin

  mv include/config.db $startdir/pkg/etc/httpd/sqadmin
  mv include/user_defined.inc.php include/user_defined.inc.php.orig
  rm -f INSTALL TODO CHANGES LICENCE test.sqlite*

  echo -e "<?\n\
define(\"SQLiteDb\", \"/etc/httpd/sqadmin/config.db\");\n\
define(\"DEFAULT_DB_PATH\", \"/srv/www/sqadmin/dbs\");\n\
?>\n" >  include/user_defined.inc.php
  
  cp -R * $startdir/pkg/srv/www/sqadmin || return 1
  
  chown -R nobody:nobody $startdir/pkg/srv/www/sqadmin
  chmod -R 600 $startdir/pkg/srv/www/sqadmin
  find $startdir/pkg/srv/www/sqadmin -type d | xargs chmod 700

  chown -R nobody:nobody $startdir/pkg/etc/httpd/sqadmin
  chmod -R 600 $startdir/pkg/etc/httpd/sqadmin
  find $startdir/pkg/etc/httpd/sqadmin -type d | xargs chmod 700
}