IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=1.08
PROGNAME="kbd $VERSION"
DESC="\
kbd (keyboard maps and console fonts)                                  \n\
                                                                       \n\
Load and save keyboard mappings.  Needed if you are not using the US   \n\
keyboard map.  This package also contains utilities to change your     \n\
console fonts - if you install it you'll get a menu later on that lets \n\
you select from many different fonts.  If you like one, you can make   \n\
it your default font.  A new default font can be chosen at any time by \n\
typing 'fontconfig'."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=ftp://ftp.win.tue.nl/pub/home/aeb/linux-local/utils/kbd/
PKGNAME=kbd-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   tar -yxvf $CWD/kbd-$VERSION.tar.bz2
   cd kbd-$VERSION/
   # Apply a fix for the nl.map from the map's author:
   zcat $CWD/nl.diff.gz | patch -p1
   chown -R root.root .
#  ./configure --prefix=/usr --datadir=/usr/share/kbd --mandir=/usr/man
   ./configure --prefix=/usr 
   make
}

install() {
   make install prefix=/package-kbd/usr \
                DESTDIR=/package-kbd/usr \
                DATA_DIR=/package-kbd/usr/share/kbd \
                MAN_DIR=/package-kbd/usr/man

   mkdir -p /package-kbd/bin/
   ( cd /package-kbd/usr/bin
     mv loadkeys /package-kbd/bin/
     rm -f loadkeys ; ln -sf ../../bin/loadkeys .
   )

   mkdir -p /package-kbd/var/log/setup/
   cp -a $CWD/setup.setconsolefont /package-kbd/var/log/setup/
   cp -a $CWD/setconsolefont /package-kbd/usr/bin/

   # Add some extra fonts
   ( cd /package-kbd/
     tar -zxf $CWD/extraf.tgz 
   )

   # This is the keymap for Speakup (http://linux-speakup.org) users:
   cp -a $CWD/speakupmap.map.gz /package-kbd/usr/share/kbd/keymaps/i386/qwerty/speakupmap.map.gz

   # Another keymap for Speakup from Thomas Ward, for JFW users.
   tar -zxf $CWD/speakup-jfw.tar.gz
   ( cd speakup-jfw
     cat speakup-jfw.map | gzip -9c > /package-kbd/usr/share/kbd/keymaps/i386/qwerty/speakup-jfw.map.gz
     cp -a readme /package-kbd/usr/share/kbd/keymaps/i386/qwerty/speakup-jfw.readme
   )

   mkdir -p /package-kbd/etc/rc.d
   cat << EOF > /package-kbd/etc/rc.d/rc.font.sample
#!/bin/sh
#
# This selects your default screen font from among the ones in
# /usr/share/kbd/consolefonts.
#
setfont -v
EOF

   mkdir -p /package-kbd/usr/doc/kbd-$VERSION
   cp -a CHANGES COPYING CREDITS README doc/* \
       /package-kbd/usr/doc/kbd-$VERSION
   mkdir -p /package-kbd/usr/doc/kbd-$VERSION/openvt
   cp -a openvt/README* /package-kbd/usr/doc/kbd-$VERSION/openvt
   rm -f /package-kbd/usr/doc/kbd-$VERSION/kbd.FAQ.sgml

   rm /package-kbd/usr/man/man8/resizecons.8
   ( for dir in 1 5 8; do
       cd /package-kbd/usr/man/man$dir
       rm -f *.gz
       gzip -9 *.$dir
     done
   )

}

attributes() {
   chown -R root.bin $PKG/package-kbd/bin \
                     $PKG/package-kbd/usr/bin
   chmod 755 $PKG/package-kbd/etc/rc.d/rc.font.sample \
             $PKG/package-kbd/usr/bin/setconsolefont \
             $PKG/package-kbd/var/log/setup/setup.setconsolefont
   chmod 644 $PKG/package-kbd/usr/man/man?/*
   chmod 644 $PKG/package-kbd/usr/share/kbd/keymaps/i386/qwerty/speakup-jfw.readme
}

special() {
   cd $PKG
   mv package-kbd/* ./
   rmdir package-kbd

   cd $CTL
   cat $CWD/slack-desc > slack-desc
   sed -e 's%package-kbd/%%' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

