#!/bin/sh
echo "This script tries to automatically set you up so that your applications"
echo "that now use termcap can use terminfo and the ncurses library."
echo ""
if test -n "$TERMINFO"
then
echo "TERMINFO is already defined in your environment. This means"
echo "you already have a local terminfo tree, so you do not need any"
echo "conversion."
if test ! -d $TERMINFO ; then
echo "Caution: TERMINFO does not point to a directory!"
fi
exit;
fi
terminfo=no
for p in $TERMINFO \
/usr/lib/terminfo \
/usr/share/lib/terminfo \
/usr/share/terminfo \
/usr/local/lib/terminfo \
/usr/local/share/terminfo
do
if test -d $p ; then
terminfo=yes
break
fi
done
if test $terminfo = yes
then
echo "Your system already has a system-wide terminfo tree."
echo ""
if test -z "$TERMCAP"
then
echo "You have no TERMCAP variable set, so we are done."
exit;
fi
if test "$TERM" = "xterm"
then
echo "You are running xterm, which usually sets TERMCAP itself."
echo "We can ignore this, because terminfo knows about xterm."
echo "So you will just use the system-wide terminfo tree."
exit;
else
echo "We will have to make a local one for you anyway, to capture the effect"
echo "of your TERMCAP variable."
fi
else
echo "No system-wide terminfo tree. We will make you a local one."
fi
echo "";
OPT="-x"
TMP=test$$; touch $TMP && chmod 755 $TMP
if test $OPT $TMP ; then
chmod 644 $TMP
test $OPT $TMP && OPT="-f"
else
OPT="-f"
fi
rm -f $TMP
TIC=
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for x in $PATH .
do
if test $OPT $x/tic
then
TIC=$x/tic
break
fi
done
IFS="$ac_save_ifs"
if test -n "$TIC"
then
echo "I see tic at $TIC."
case $TIC in ./tic)
if test $OPT ../misc/shlib ; then
TIC="../misc/shlib $TIC"
fi
;;
esac
else
echo "You do not have tic installed anywhere I can see, please fix that."
exit;
fi
echo "";
if test -d $HOME/.terminfo
then
echo "It appears you already have a private terminfo directory"
echo "at $HOME/.terminfo; this seems odd, because TERMINFO"
echo "is not defined. I am not going to second-guess this -- if you"
echo "really want me to try auto-configuring for you, remove or"
echo "rename $HOME/terminfo and run me again."
exit;
else
echo "I am creating your private terminfo directory at $HOME/.terminfo"
mkdir $HOME/.terminfo
TERMINFO="$HOME/.terminfo"; export TERMINFO
fi
echo "";
if test -f ../misc/terminfo.src
then
echo "I see the terminfo master source is handy; I will use that."
master=../misc/terminfo.src
else
master=`find $HOME -name "*terminfo.src" -print`
mcount=`echo $master | wc -l`
case $mcount in
0)
echo "I can not find a terminfo source file anywhere under your home directory."
echo "There should be a file called terminfo.src somewhere in your"
echo "ncurses distribution; please put it in your home directotry"
echo "and run me again (it does not have to live there permanently)."
exit;
;;
1)
echo "I see a file called $master."
echo "I am going to assume this is the terminfo source included with"
echo "the ncurses distribution. If this assumption is wrong, please"
echo "interrupt me now! OK to continue?"
read ans;
;;
2)
echo "I see more than one possible terminfo source. Here they are:"
echo $master | sed "/^/s// /";
while :
do
echo "Please tell me which one to use:"
read master;
if test -f $master
then
break
else
echo "That file does not exist. Try again?";
fi
done
;;
esac
fi
echo "";
echo "OK, now I will make your private terminfo tree. This may take a bit..."
trap "rm -f tsplit$$.*" 0 1 2 5 15
sed -n $master \
-e '1,/SPLIT HERE/w 'tsplit$$.01 \
-e '/SPLIT HERE/,$w 'tsplit$$.02 \
2>/dev/null
for x in tsplit$$.*; do eval $TIC $x; done
rm tsplit$$.*
trap 0 1 2 5 15
echo "You now have a private tree under $HOME/.terminfo;"
echo "the ncurses library will automatically read from it,"
echo "and ncurses tic will automatically compile entries to it."
if test -z "$TERMCAP"
then
echo "You have no TERMCAP set, so we are done."
fi
if test -f $HOME/.termcap
then
echo 'I see you have a $HOME/.termcap file. I will compile that.'
eval $TIC $HOME/.termcap
echo "Done."
echo "Note that editing $HOME/.termcap will no longer change the data curses sees."
elif test -f "$TERMCAP"
then
echo "Your TERMCAP names the file $TERMCAP. I will compile that."
eval $TIC $TERMCAP
echo "Done."
echo "Note that editing $TERMCAP will no longer change the data curses sees."
else
echo "Your TERMCAP value appears to be an entry in termcap format."
echo "I will compile it."
echo $TERMCAP >myterm$$
eval $TIC myterm$$
rm myterm$$
echo "Done."
echo "Note that editing TERMCAP will no longer change the data curses sees."
fi
echo "To do that, decompile the terminal decription you want with infocmp(1),"
echo "edit to taste, and recompile using tic(1)."