#!/bin/bash
################################################################################
#
# newman - installs manual pages to install path with new name
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006, 2008 Yaakov Selkowitz
# Provided by the Cygwin Ports project <http://cygwinports.dotsrc.org/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport 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.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <http://www.gnu.org/licenses/>.
#
# $Id: newman 4155 2008-08-07 04:58:41Z yselkowitz $
#
################################################################################
set -e

mandir=/usr/share/man

if [ ! -e ${1} ]
then
	error "file ${1} does not exist"
fi

case ${2} in
	*.1|*.1m|*.1x|*.1.bz2|*.1.gz)
		mansection=1
		;;
	*.3|*.3pm|*.3t)
		mansection=3
		;;
	*.4)
		mansection=4
		;;
	*.5)
		mansection=5
		;;
	*.6|*.6x)
		mansection=6
		;;
	*.7)
		mansection=7
		;;
	*.8)
		mansection=8
		;;
	*.n)
		mansection=n
		;;
	*)
		error "unknown man section"
		;;
esac

dodir ${mandir}/man${mansection}
/bin/install -m0644 ${1} ${D}${mandir}/man${mansection}/${2} || error "newman ${1} failed"
