#!/bin/sh

# Copyright © 2015 Jakub Wilk <jwilk@jwilk.net>
#
# This file is part of pdf2djvu.
#
# pdf2djvu is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# pdf2djvu is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

pkgs_base='
build-essential
djvulibre-bin
libdjvulibre-dev
libexiv2-dev
libgraphicsmagick++-dev
libpoppler-dev
pkg-config
uuid-dev
'
pkgs_autotools='
autoconf
automake
gettext
libtool
'
pkgs_tests='
python-nose
'
pkgs_prepare_tests='
python-imaging
texlive-base
texlive-fonts-recommended
texlive-xetex
fonts-linuxlibertine
'
pkgs="$pkgs_base"

usage()
{
    printf '%s [--vcs] [--tests]\n' "$0"
}

args=$(getopt -n "$0" -o 'h' --long 'help,vcs,tests' -- "$@")
if [ $? -ne 0 ]
then
    usage >&2
    exit 1
fi
opt_vcs=
opt_tests=
eval set -- "$args"
while true
do
    case "$1" in
        -h|--help) usage; exit 0;;
        --vcs) opt_vcs=y; shift;;
        --tests) opt_tests=y ; shift;;
        --) shift; break;;
        *) printf '%s: internal error (%s)\n' "$0" "$1" >&2; exit 1;;
    esac
done

[ "$opt_tests" ] && pkgs="$pkgs $pkgs_tests"
[ "$opt_vcs" ] && pkgs="$pkgs $pkgs_autotools"
[ "$opt_vcs" ] && [ "$opt_tests" ] && pkgs="$pkgs $pkgs_prepare_tests"

PS4='# '
set -e
(
    set -x
    apt-get install $pkgs
)
if ! dpkg -L libpoppler-dev | grep -q -E '/GfxState[.]h$'
then
(
    set -x
    apt-get install libpoppler-private-dev
)
fi

# vim:ts=4 sts=4 sw=4 et
