### this file is sourced not run
PKGVER=4.0.2018.09
PKGBUILD=1
PKGARCH=x86_64

# source: james
DB_TARBALL=foomatic-db-4.0-20180930.tar.xz
DB_MD5SUM=2902d01c3c8be46bdc372319af5262f1
DB_SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$DB_TARBALL

DB_NONFREE_TARBALL=foomatic-db-nonfree-20180930.tar.gz
DB_NONFREE_MD5SUM=ebb7c40c1bf3c9b9afe57c2a74f36005
DB_NONFREE_SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$DB_NONFREE_TARBALL

ENGINE_TARBALL=foomatic-db-engine-4.0-20180930.tar.gz
ENGINE_MD5SUM=0487574f3dad875fb845fb241482f689
ENGINE_SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$ENGINE_TARBALL

# the source URL for all these packages are actuall here:
# http://www.openprinting.org/download/foomatic/
# but they get updated everyday, so we need to persistent copy

SLACKREQ='cups ghostscript'
SLACKDESC="foomatic: foomatic $PKGVER (Foomatic printer drivers)
foomatic: 
foomatic: Foomatic is a database-driven system for integrating free software 
foomatic: printer drivers with common spoolers under Unix. It supports CUPS, 
foomatic: LPRng, LPD, GNUlpr, Solaris LP, PPR, PDQ, CPS, and direct printing 
foomatic: with every free software printer driver known to us and every printer 
foomatic: known to work with these drivers.
foomatic: 
foomatic: https://wiki.linuxfoundation.org/openprinting/database/foomatic
foomatic: 
foomatic: 
"

### default pkg_download
### prepare
pkg_prepare() {
	SRC_URL=$DB_SRC_URL pkg_check $SRC_DIR $DB_TARBALL $DB_MD5SUM &&
	SRC_URL=$DB_NONFREE_SRC_URL pkg_check $SRC_DIR $DB_NONFREE_TARBALL $DB_NONFREE_MD5SUM &&
	SRC_URL=$ENGINE_SRC_URL pkg_check $SRC_DIR $ENGINE_TARBALL $ENGINE_MD5SUM &&
	tar -xf $SRC_DIR/$DB_TARBALL -C tmp &&
	tar -xf $SRC_DIR/$DB_NONFREE_TARBALL -C tmp &&
	tar -xf $SRC_DIR/$ENGINE_TARBALL -C tmp &&
	true
}

### default pkg_package
### build
pkg_build() {
	# first, the database
    cd /tmp/foomatic-db-2* &&
    ./configure --prefix=/usr &&
    make install &&

    # then the non-free database
    cd /tmp/foomatic-db-non* &&
    ./configure --prefix=/usr &&
    make install &&

    # lastly the engine
    cd /tmp/foomatic-db-en* &&
    ./configure $CONFFLAGS &&
    make && make install &&
    
	pkg_build_slackdesc
}


