Blob Blame History Raw
#!/bin/sh
set -e

defaultpaper () {
   # This is always in millimeters.  If no locale is specified or
   # available, it will default to a4.
   w=$(locale width  2>/dev/null) || return 0
   h=$(locale height 2>/dev/null) || return 0

   # Try to find a matching paper size.  The data must be embedded here
   # (done automatically by debian/rules) because the rest of the package
   # may not have been unpacked at this stage.
   LC_ALL=C awk 'NF == 5 && int($2 + 0.5) == '"$w"' && int($4 + 0.5) == '"$h"' {
		    print $1;
		    exit;
		 }' <<__END_PAPERSPECS__
__BEGIN_PAPERSPECS__
__END_PAPERSPECS__
}

. /usr/share/debconf/confmodule

if [ -f /etc/papersize ]; then
   # Configuration file always takes priority.  Ignore comments.
   paper=`awk '$1 ~ /^[^#]/ { print $1 }' /etc/papersize`
elif db_get libpaper/defaultpaper && [ -n "$RET" ]; then
   # The answer is already in the database; don't touch it.
   paper=
else
   paper=`defaultpaper`
fi
if [ -n "$paper" ]; then
   db_set libpaper/defaultpaper "$paper"
fi

db_input medium libpaper/defaultpaper || true
db_go || true