#!/bin/sh

name="zgv"
title="zgv"
package="zgv"
version="5.5"
build="1"
noarch="n"
build_info="Standard build."

info="A picture viewer for Linux systems with VGA/SVGA."
info_pl="Przeglądarka obrazów dla Linuksów z VGA/SVGA."
desc="zgv is an svgalib-based viewer which views GIF, JPEG, PNG,
PBM/PGM/PPM, TIFF, BMP, TGA, PCX, mrf, XBM, and XPM files, with
a full-screen file selector front-end. It can be used as a simple
command, with 'zgv filename(s)', which bypasses the front-end. For
more on how zgv works and how to use it, do 'info zgv' or 'man zgv'
once it's installed."
desc_pl="zgv jest opartą na svgalib przeglądarką, która obsługuje formaty
GIF, JPEG, PNG, PBM/PGM/PPM, TIFF, BMP, TGA, PCX, mrf, XBM i XPM,
z pełnoekranowym interfejsem do wybierania plików. Może być użyty
prosto 'zgv nazwy_plików', co omija ten interfejs. Aby dowiedzieć
się więcej na temat, jak działa zgv i jak tego używać, użyj
'info zgv' lub 'man zgv', gdy go zainstalujesz."
category="viewer/graphic"
environment="console/svgalib"
contact="$name@packages.packware.gnu.pl"
vendor="The Packware Project"
vendor_id="pw"

requires=""
obsoletes=""
conflicts=""

docs_source="AUTHORS,COPYING,ChangeLog,INSTALL,NEWS,README*,SECURITY,TODO"
docs_cwd=""

strip_bin="y"
reset_own="y"
reset_dir="y"
reset_fil="y"
delete_cat="y"

. /usr/src/tgz/lib/builder.defs

add_source ftp://metalab.unc.edu/pub/Linux/apps/graphics/viewers/svga/$name-$version.tar.gz

# First, allow to build for other architectures.
replace_regexp $src1/src/Makefile '^CFLAGS = $(WARNOPTS)' 'CFLAGS = $(WARNOPTS) $(AM_CFLAGS)'

# Fix names of info files.
replace_regexp $src1/doc/zgv.texi '^@setfilename zgv$' '@setfilename zgv.info'
# Fix install script to handle new names.
replace_regexp $src1/doc/Makefile 'zgv zgv-' 'zgv.info zgv.info-'
# We don't want install script to register info files.
replace_regexp $src1/config.mk '^#INFO_DIR_UPDATE=no$' 'INFO_DIR_UPDATE=no'

# Thanks to this patch the cursor will move down after deleting item. Taken
# from PLD-SRPM.
apply_patch zgv-Dkey.patch 1
apply_patch zgv-noroot.pw.patch

# Disable /share infix.
replace_regexp $src1/config.mk '^SHARE_INFIX=/share$' '#SHARE_INFIX=/share'

# Executable must be setuid root.
change_mod main usr/bin/zgv u+s

install_option PREFIX=$pkg_main/usr

parent_package="$package"
write_info main

cd $src1

do_make
make info

mkdir -p $pkg_main/usr/bin
mkdir -p $pkg_main/usr/man/man1
mkdir -p $pkg_main/usr/info
mkdir -p $pkg_main/etc

do_install

# I'm not really sure what to do with info files. They don't work correctly at
# all and it's not simple to fix them. Remove, for now ('till they are fixed).
rm -rf $pkg_main/usr/info

cp doc/sample.zgvrc $pkg_main/etc/zgv.conf

make_docs

make_package main

clean_up
