#!/bin/sh
#
# postinst script for the Debian GNU/Linux r-base-core package
# This version originally written by Douglas Bates <bates@stat.wisc.edu>

set -e

#DEBHELPER#
    
    
case "$1" in
    configure)
	if [ -x /usr/bin/paperconf ]
	then
	    perl -pi -e \
	    '$P=`/usr/bin/paperconf`,chop $P,s:a4:$P: if /{R_PAPERSIZE/' /usr/bin/R
	fi

	if [ -x /usr/bin/update-menus ] 
	then 
	    update-menus 
	fi

	# edd 03 Apr 2003  cf Section 10.1.2 of Debian Policy
	if [ ! -e /usr/local/lib/R ]
	then
	    if mkdir /usr/local/lib/R 2>/dev/null
	    then 
		chown root:staff /usr/local/lib/R
		chmod 2775 /usr/local/lib/R
	    fi
	fi
	if [ ! -e /usr/local/lib/R/site-library ]
	then
	    if mkdir /usr/local/lib/R/site-library 2>/dev/null
	    then 
		chown root:staff /usr/local/lib/R/site-library
		chmod 2775 /usr/local/lib/R/site-library
	    fi
	fi
    ;;
    abort-upgrade|abort-remove|abort-deconfigure)
    ;;
    *)
	echo "postinst called with unknown argument \`$1'" >&2
    ;;
esac
