home *** CD-ROM | disk | FTP | other *** search
/ PCMania 8 / PCM8.iso / XFREE86 / Linux-ix86-glibc20 / Xinstall.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2000-05-08  |  22.5 KB  |  1,086 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # $XFree86: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh,v 1.9 2000/03/18 19:58:56 dawes Exp $
  5. #
  6. # Copyright ⌐ 2000 by Precision Insight, Inc.
  7. # Portions Copyright ⌐ 1996-2000 by The XFree86 Project, Inc.
  8. #
  9. # This script should be used to install XFree86 4.0.
  10. #
  11. # Parts of this script are based on the old preinst.sh and postinst.sh
  12. # scripts.
  13. #
  14. # Set tabs to 4 spaces to view/edit this file.
  15. #
  16. # Authors:    David Dawes <dawes@xfree86.org>
  17. #
  18.  
  19. VERSION=4.0
  20.  
  21. RUNDIR=/usr/X11R6
  22. ETCDIR=/etc/X11
  23. VARDIR=/var
  24.  
  25. if [ X"$1" = "X-test" -o X"$XINST_TEST" != X ]; then
  26.     RUNDIR=/home1/test/X11R6
  27.     ETCDIR=/home1/test/etcX11
  28.     VARDIR=/home1/test/var
  29.     if [ X"$1" = "X-test" ]; then
  30.         shift
  31.     fi
  32.     echo ""
  33.     echo "Running in test mode"
  34. fi
  35.  
  36. OLDFILES=""
  37.  
  38. OLDDIRS=" \
  39.     $RUNDIR/lib/X11/xkb/compiled \
  40.     "
  41.  
  42. OLDMODULES=" \
  43.     xie.so \
  44.     pex5.so \
  45.     glx.so \
  46.     "
  47.  
  48. BASEDIST=" \
  49.     Xbin.tgz \
  50.     Xlib.tgz \
  51.     Xman.tgz \
  52.     Xdoc.tgz \
  53.     Xfnts.tgz \
  54.     Xfenc.tgz \
  55.     "
  56.  
  57. ETCDIST="Xetc.tgz"
  58.  
  59. VARDIST=""
  60.  
  61. SERVDIST=" \
  62.     Xxserv.tgz \
  63.     Xmod.tgz \
  64.     "
  65. OPTDIST=" \
  66.     Xfsrv.tgz \
  67.     Xnest.tgz \
  68.     Xprog.tgz \
  69.     Xprt.tgz \
  70.     Xvfb.tgz \
  71.     Xf100.tgz \
  72.     Xfcyr.tgz \
  73.     Xflat2.tgz \
  74.     Xfnon.tgz \
  75.     Xfscl.tgz \
  76.     Xhtml.tgz \
  77.     Xjdoc.tgz \
  78.     Xps.tgz \
  79.     "
  80.  
  81. ETCLINKS=" \
  82.     app-defaults \
  83.     fs \
  84.     lbxproxy \
  85.     proxymngr \
  86.     rstart \
  87.     twm \
  88.     xdm \
  89.     xinit \
  90.     xsm \
  91.     xserver \
  92.     "
  93.  
  94. XKBDIR="/etc/X11/xkb"
  95.  
  96. FONTDIRS=" \
  97.     local \
  98.     misc
  99.     "
  100.  
  101. WDIR=`pwd`
  102.  
  103. # Check how to suppress newlines with echo (from perl's Configure)
  104. ((echo "xxx\c"; echo " ") > .echotmp) 2> /dev/null
  105. if [ ! -f .echotmp ]; then
  106.     echo "Can't write to the current directory.  Aborting";
  107.     exit 1
  108. fi
  109. if grep c .echotmp >/dev/null 2>&1; then
  110.     n='-n'
  111.     c=''
  112. else
  113.     n=''
  114.     c='\c'
  115. fi
  116. rm -f .echotmp
  117.  
  118. Echo()
  119. {
  120.     echo $n "$@""$c"
  121. }
  122.  
  123. ContinueNo()
  124. {
  125.     Echo "Do you wish to continue? (y/n) [n] "
  126.     read response
  127.     case "$response" in
  128.     [yY]*)
  129.         echo ""
  130.         ;;
  131.     *)
  132.         echo "Aborting the installation."
  133.         exit 2
  134.         ;;
  135.     esac
  136. }
  137.  
  138. ContinueYes()
  139. {
  140.     Echo "Do you wish to continue? (y/n) [y] "
  141.     read response
  142.     case "$response" in
  143.     [nN]*)
  144.         echo "Aborting the installation."
  145.         exit 2
  146.         ;;
  147.     *)
  148.         echo ""
  149.         ;;
  150.     esac
  151. }
  152.  
  153. Description()
  154. {
  155.     case $1 in
  156.     Xfsrv*)
  157.         echo "font server";;
  158.     Xnest*)
  159.         echo "Nested X server";;
  160.     Xprog*)
  161.         echo "programmer support";;
  162.     Xprt*)
  163.         echo "X print server";;
  164.     Xvfb*)
  165.         echo "Virtual framebuffer X server";;
  166.     Xf100*)
  167.         echo "100dpi fonts";;
  168.     Xfcyr*)
  169.         echo "Cyrillic fonts";;
  170.     Xflat2*)
  171.         echo "Latin-2 fonts";;
  172.     Xfnon*)
  173.         echo "Some large fonts";;
  174.     Xfscl*)
  175.         echo "Scaled fonts (Speedo and Type1)";;
  176.     Xhtml*)
  177.         echo "Docs in HTML";;
  178.     Xjdoc*)
  179.         echo "Docs in Japanese";;
  180.     Xps*)
  181.         echo "Docs in PostScript";;
  182.     *)
  183.         echo "unknown";;
  184.     esac
  185. }
  186.  
  187. ReadLink()
  188. {
  189.     rltmp="`ls -l $1`"
  190.     rl=`expr "$rltmp" : '.*-> \([^     ]*\)'`
  191.     echo $rl
  192. }
  193.  
  194. GetOsInfo()
  195. {
  196.     echo "Checking which OS you're running..."
  197.  
  198.     OsName="`uname`"
  199.     OsVersion="`uname -r`"
  200.     case "$OsName" in
  201.     SunOS) # Assumes SunOS 5.x
  202.         OsArch="`uname -p`"
  203.         ;;
  204.     *)
  205.         OsArch="`uname -m`"
  206.         ;;
  207.     esac
  208.     # Some SVR4.0 versions have a buggy uname that reports the node name
  209.     # for the OS name.  Try to catch that here.  Need to check what is
  210.     # reported for non-buggy versions.
  211.     if [ "$OsName" = "`uname -n`" -a -f /stand/unix ]; then
  212.         OsName=UNIX_SV
  213.     fi
  214.     echo "uname reports '$OsName' version '$OsVersion', architecture '$OsArch'."
  215.  
  216.     # Find the object type, where needed
  217.  
  218.     case "$OsName" in
  219.     Linux|FreeBSD|NetBSD)
  220.         if file -L /bin/sh | grep ELF > /dev/null 2>&1; then
  221.             OsObjFormat=ELF
  222.         else
  223.             OsObjFormat=a.out
  224.         fi
  225.         ;;
  226.     esac
  227.  
  228.     if [ X"$OsObjFormat" != X ]; then
  229.         Echo "Object format is '$OsObjFormat'.  "
  230.         needNL=YES
  231.     fi
  232.  
  233.     # test's flag for symlinks
  234.     #
  235.     # For OSs that don't support symlinks, choose a type that is guaranteed to
  236.     # return false for regular files and directories.
  237.  
  238.     case "$OsName" in
  239.     FreeBSD)
  240.         case "$OsVersion" in
  241.         2.*)
  242.             L="-h"
  243.             ;;
  244.         *)
  245.             L="-L"
  246.             ;;
  247.         esac
  248.         ;;
  249.     SunOS)
  250.         L="-h"                # /bin/sh built-in doesn't do -L
  251.         ;;
  252.     OS-with-no-symlinks)    # Need to set this correctly
  253.         L="-b"
  254.         NoSymlinks=YES
  255.         ;;
  256.     *)
  257.         L="-L"
  258.         ;;
  259.     esac
  260.  
  261.     # Find the libc version, where needed
  262.     case "$OsName" in
  263.     Linux)
  264.         tmp="`ldd /bin/sh | grep libc.so 2> /dev/null`"
  265.         LibcPath=`expr "$tmp" : '[^/]*\(/[^ ]*\)'`
  266.         tmp="`strings $LibcPath | grep -i 'c library'`"
  267.         OsLibcMajor=`expr "$tmp" : '.* \([0-9][0-9]*\)'`
  268.         OsLibcMinor=`expr "$tmp" : '.* [0-9][0-9]*\.\([0-9][0-9]*\)'`
  269.         case "$OsLibcMajor" in
  270.         2)
  271.             # 2 is the glibc version
  272.             OsLibcMajor=6
  273.             ;;
  274.         esac
  275.         ;;
  276.     esac
  277.  
  278.     if [ X"$OsLibcMajor" != X ]; then
  279.         Echo "libc version is '$OsLibcMajor"
  280.         if [ X"$OsLibcMinor" != X ]; then
  281.             Echo ".$OsLibcMinor'."
  282.         else
  283.             Echo "'."
  284.         fi
  285.         needNL=YES
  286.     fi
  287.     if [ X"$needNL" = XYES ]; then
  288.         echo ""
  289.     fi
  290.     echo ""
  291. }
  292.  
  293. DoOsChecks()
  294. {
  295.     # Do some OS-specific checks
  296.  
  297.     case "$OsName" in
  298.     Linux)
  299.         case "$OsObjFormat" in
  300.         ELF)
  301.             # Check ldconfig
  302.             LDSO=`/sbin/ldconfig -v -n | awk '{ print $3 }'`
  303.             LDSOMIN=`echo $LDSO | awk -F[.-] '{ print $3 }'`
  304.             LDSOMID=`echo $LDSO | awk -F[.-] '{ print $2 }'`
  305.             LDSOMAJ=`echo $LDSO | awk -F[.-] '{ print $1 }'`
  306.             if [ "$LDSOMAJ" -gt 1 ]; then
  307.                 : OK
  308.             else
  309.                 if [ "$LDSOMID" -gt 7 ]; then
  310.                     : OK
  311.                 else
  312.                     if [ "$LDSOMIN" -ge 14 ]; then
  313.                         : OK
  314.                     else
  315.                         echo ""
  316.                         echo "Before continuing, you will need to get a"
  317.                         echo "current version of ld.so.  Version 1.7.14 or"
  318.                         echo "newer will do."
  319.                         NEEDSOMETHING=YES
  320.                     fi
  321.                 fi
  322.             fi
  323.             ;;
  324.         esac
  325.         # The /dev/tty0 check is left out.  Presumably nobody has a system where
  326.         # this is missing any more.
  327.         ;;
  328.     esac
  329. }
  330.  
  331. FindDistName()
  332. {
  333.     case "$OsName" in
  334.     DGUX)    # Check this string
  335.         case "$OsArch" in
  336.         i*86)
  337.             DistName="DGUX-ix86"
  338.             ;;
  339.         *)
  340.             Message="DGUX binaries are only available for ix86 platforms"
  341.             ;;
  342.         esac
  343.         ;;
  344.     FreeBSD)
  345.         case "$OsArch" in
  346.         i386)
  347.             case "$OsVersion" in
  348.             2.2*)
  349.                 DistName="FreeBSD-2.2.x"
  350.                 ;;
  351.             3.*)
  352.                 case "$OsObjFormat" in
  353.                 ELF)
  354.                     DistName="FreeBSD-3.x"
  355.                     ;;
  356.                 *)
  357.                     Message="FreeBSD 3.x binaries are only available in ELF format"
  358.                     ;;
  359.                 esac
  360.                 ;;
  361.             4.*)
  362.                 DistName="FreeBSD-4.x"
  363.                 ;;
  364.             *)
  365.                 Message="FreeBSD/i386 binaries are not available for this version"
  366.                 ;;
  367.             esac
  368.             ;;
  369.         alpha)
  370.             case "$OsVersion" in
  371.             3.*)
  372.                 DistName="FreeBSD-alpha-3.x"
  373.                 ;;
  374.             4.*)
  375.                 DistName="FreeBSD-alpha-4.x"
  376.                 ;;
  377.             *)
  378.                 Message="FreeBSD/alpha binaries are not available for this version"
  379.                 ;;
  380.             esac
  381.             ;;
  382.         *)
  383.             Message="FreeBSD binaries are not available for this architecture"
  384.             ;;
  385.         esac
  386.         ;;
  387.     Linux)
  388.         case "$OsArch" in
  389.         i*86)
  390.             case "$OsLibcMajor" in
  391.             5)
  392.                 DistName="Linux-ix86-libc5"
  393.                 ;;
  394.             6)
  395.                 case "$OsLibcMinor" in
  396.                 0)
  397.                     DistName="Linux-ix86-glibc20"
  398.                     ;;
  399.                 1)
  400.                     DistName="Linux-ix86-glibc21"
  401.                     ;;
  402.                 *)
  403.                     Message="No dist available for glibc 2.$OsLibcMinor.  Try Linux-ix86-glibc21"
  404.                     ;;
  405.                 esac
  406.                 ;;
  407.             *)
  408.                 case "$OsObjFormat" in
  409.                 a.out)
  410.                     Message="Linux a.out is no longer supported"
  411.                     ;;
  412.                 *)
  413.                     Message="No Linux/ix86 binaries for this libc version"
  414.                     ;;
  415.                 esac
  416.                 ;;
  417.             esac
  418.             ;;
  419.         alpha)
  420.             case "$OsLibcMajor.$OsLibcMinor" in
  421.             6.1)
  422.                 DistName="Linux-alpha-glibc21"
  423.                 ;;
  424.             6.*)
  425.                 Message="No Linux/alpha binaries for glibc 2.$OsLibcMinor.  Try Linux-alpha-glibc21"
  426.                 ;;
  427.             *)
  428.                 Message="No Linux/alpha binaries for this libc version"
  429.                 ;;
  430.             esac
  431.             ;;
  432.         *)
  433.             Message="No Linux binaries available for this architecture"
  434.             ;;
  435.         esac
  436.         ;;
  437.     LynxOS)    # Check this
  438.         DistName="LynxOS"
  439.         ;;
  440.     NetBSD)
  441.         case "$OsArch" in
  442.         i386)
  443.             case "$OsVersion" in
  444.             1.[3-9]*)    # Check this
  445.                 case "$OsObjFormat" in
  446.                 a.out)
  447.                     DistName="NetBSD-1.4.1"
  448.                     ;;
  449.                 *)
  450.                     DistName="NetBSD-current-ELF"
  451.                     ;;
  452.                 esac
  453.                 ;;
  454.             *)
  455.                 Message="No NetBSD/i386 binaries available for this version"
  456.                 ;;
  457.             esac
  458.             ;;
  459.         *)
  460.             Message="No NetBSD binaries available for this architecture"
  461.             ;;
  462.         esac
  463.         ;;
  464.     OpenBSD)
  465.         case "$OsArch" in
  466.         i386)
  467.             case "$OsVersion" in
  468.             2.[6-9]*)    # Check this
  469.                 DistName="OpenBSD-2.6"
  470.                 ;;
  471.             *)
  472.                 Message="No OpenBSD/i386 binaries available for this version"
  473.                 ;;
  474.             esac
  475.             ;;
  476.         *)
  477.             Message="No OpenBSD binaries available for this architecture"
  478.             ;;
  479.         esac
  480.         ;;
  481.     SunOS)
  482.         case "$OsArch" in
  483.         i386)
  484.             case "$OsVersion" in
  485.             5.[67]*)
  486.                 DistName="Solaris"
  487.                 ;;
  488.             5.8*)
  489.                 DistName="Solaris-8"
  490.                 ;;
  491.             *)
  492.                 Message="No Solaris/x86 binaries available for this version"
  493.                 ;;
  494.             esac
  495.             ;;
  496.         *)
  497.             Message="No SunOS/Solaris binaries available for this architecture"
  498.             ;;
  499.         esac
  500.         ;;
  501.     UNIX_SV)
  502.         case "$OsArch" in
  503.         i386)
  504.             case "$OsVersion" in
  505.             4.0*)
  506.                 DistName="SVR4.0"
  507.                 ;;
  508.             *)
  509.                 # More detailed version check??
  510.                 DistName="UnixWare"
  511.                 ;;
  512.             esac
  513.             ;;
  514.         *)
  515.             Message="No SYSV binaries available for this architecture"
  516.             ;;
  517.         esac
  518.         ;;
  519.     *)
  520.         Message="No binaries available for this OS"
  521.         ;;
  522.     esac
  523.  
  524.     if [ X"$DistName" != X ]; then
  525.         echo "Binary distribution name is '$DistName'"
  526.         echo ""
  527.     else
  528.         if [ X"$Message" = X ]; then
  529.             echo "Can't find which binary distribution you should use."
  530.             echo "Please send the output of this script to XFree86@XFree86.org"
  531.             echo ""
  532.         else
  533.             echo "$Message"
  534.             echo ""
  535.         fi
  536.     fi
  537. }
  538.  
  539. if [ X"$1" = "X-check" ]; then
  540.     GetOsInfo
  541.     FindDistName
  542.     exit 0
  543. fi
  544.  
  545. echo ""
  546. echo "        Welcome to the XFree86 $VERSION installer"
  547. echo ""
  548. echo "You are strongly advised to backup your existing XFree86 installation"
  549. echo "before proceeding.  This includes the /usr/X11R6 and /etc/X11"
  550. echo "directories.  The installation process will overwrite existing files"
  551. echo "in those directories, and this may include some configuration files"
  552. echo "that may have been customised."
  553. echo ""
  554. ContinueNo
  555.  
  556. # Should check if uid is zero
  557.  
  558. # Check if $DISPLAY is set, and warn
  559.  
  560. if [ X"$DISPLAY" != X ]; then
  561.     echo "\$DISPLAY is set, which may indicate that you are running this"
  562.     echo "installation from an X session.  It is recommended that X not be"
  563.     echo "running while doing the installation."
  564.     echo ""
  565.     ContinueNo
  566. fi
  567.  
  568. # First, do some preliminary checks
  569.  
  570. GetOsInfo
  571.  
  572. # Make OS-specific adjustments
  573.  
  574. case "$OsName" in
  575. FreeBSD|NetBSD|OpenBSD)
  576.     VARDIST="Xvar.tgz"
  577.     XKBDIR="/var/db/xkb"
  578.     ;;
  579. Interactive)    # Need the correct name for this
  580.     EXTRADIST="Xbin1.tgz"
  581.     EXTRAOPTDIST="Xxdm.tgz"
  582.     ;;
  583. Linux)
  584.     VARDIST="Xvar.tgz"
  585.     XKBDIR="/var/state/xkb"
  586.     ;;
  587. esac
  588.  
  589. REQUIREDFILES=" \
  590.     extract \
  591.     $BASEDIST \
  592.     $ETCDIST \
  593.     $VARDIST \
  594.     $SERVDIST \
  595.     $EXTRADIST \
  596.     "
  597.  
  598. echo "Checking for required files ..."
  599. Needed=""
  600.  
  601. # Check for extract and extract.exe, and check that they are usable.
  602. #
  603. # This test may not be fool-proof.  A FreeBSD/ELF binary downloaded in
  604. # ASCII mode passed it :-(.
  605. #
  606. if [ -f extract ]; then
  607.     ExtractExists=YES
  608.     chmod +x extract
  609.     if ./extract --version | head -1 | \
  610.       fgrep "extract (XFree86 version" > /dev/null 2>&1; then
  611.         ExtractOK=YES
  612.     else
  613.         echo "extract doesn't work properly, renaming it to 'extract.bad'"
  614.         rm -f extract.bad
  615.         mv extract extract.bad
  616.     fi
  617. fi
  618. if [ X"$ExtractOK" != XYES ]; then
  619.     if [ -f extract.exe ]; then
  620.         ExtractExeExists=YES
  621.         rm -f extract
  622.         ln extract.exe extract
  623.         chmod +x extract
  624.         if ./extract --version | head -1 | \
  625.           fgrep "extract (XFree86 version" > /dev/null 2>&1; then
  626.             ExtractOK=YES
  627.         else
  628.             echo "extract.exe doesn't work properly, renaming it to"
  629.             echo "'extract.exe.bad'"
  630.             rm -f extract.exe.bad
  631.             mv extract.exe extract.exe.bad
  632.             rm -f extract
  633.         fi
  634.     fi
  635. fi
  636. if [ X"$ExtractOK" != XYES ]; then
  637.     echo ""
  638.     if [ X"$ExtractExists" = XYES -a X"$ExtractExeExists" = XYES ]; then
  639.         echo "The versions of 'extract' and 'extract.exe' you have do not run'"
  640.         echo "correctly.  Make sure that you have downloaded the correct"
  641.         echo "binaries for your system.  To find out which is correct,"
  642.         echo "run 'sh $0 -check'."
  643.     fi
  644.     if [ X"$ExtractExists" = XYES -a X"$ExtractExeExists" != XYES ]; then
  645.         echo "The version of 'extract' you have does not run correctly."
  646.         echo "This is most commonly due to problems downloading this file"
  647.         echo "with some web browsers.  You may get better results if you"
  648.         echo "download the version called 'extract.exe' and try again."
  649.     fi
  650.     if [ X"$ExtractExists" != XYES -a X"$ExtractExeExists" = XYES ]; then
  651.         echo "The version of 'extract.exe' you have does not run correctly."
  652.         echo "Make sure that you have downloaded the correct binaries for your"
  653.         echo "system.  To find out which is correct, run 'sh $0 -check'."
  654.     fi
  655.     if [ X"$ExtractExists" != XYES -a X"$ExtractExeExists" != XYES ]; then
  656.         echo "You need to download the 'extract' (or 'extract.exe') utility"
  657.         echo "and put it in this directory."
  658.     fi
  659.     echo ""
  660.     echo "When you have corrected the problem, please re-run 'sh $0'"
  661.     echo "to proceed with the installation."
  662.     echo ""
  663.     exit 1
  664. fi
  665.  
  666. for i in $REQUIREDFILES; do
  667.     if [ ! -f $i ]; then
  668.         Needed="$Needed $i"
  669.     fi
  670. done
  671. if [ X"$Needed" != X ]; then
  672.     echo ""
  673.     echo "The files:"
  674.     echo ""
  675.     echo "$Needed"
  676.     echo ""
  677.     echo "must be present in the current directory to proceed with the"
  678.     echo "installation.  You should be able to find it at the same place"
  679.     echo "you picked up the rest of the XFree86 binary distribution."
  680.     echo "Please re-run 'sh $0' to proceed with the installation when"
  681.     echo "you have them."
  682.     echo ""
  683.     exit 1
  684. fi
  685.  
  686. DoOsChecks
  687.  
  688. if [ X"$NEEDSOMETHING" != X ]; then
  689.     echo ""
  690.     echo "Please re-run 'sh $0' to proceed with the installation after you"
  691.     echo "have made the required updates."
  692.     echo ""
  693.     exit 1
  694. fi
  695.  
  696. echo ""
  697.  
  698. # Link extract to gnu-tar so it can also be used as a regular tar
  699. rm -f gnu-tar
  700. ln extract gnu-tar
  701.  
  702. EXTRACT=$WDIR/extract
  703. TAR=$WDIR/gnu-tar
  704.  
  705. # Create $RUNDIR and $ETCDIR if they don't already exist
  706.  
  707. if [ ! -d $RUNDIR ]; then
  708.     NewRunDir=YES
  709.     echo "Creating $RUNDIR"
  710.     mkdir $RUNDIR
  711. fi
  712. if [ ! -d $RUNDIR/lib ]; then
  713.     echo "Creating $RUNDIR/lib"
  714.     mkdir $RUNDIR/lib
  715. fi
  716. if [ ! -d $RUNDIR/lib/X11 ]; then
  717.     echo "Creating $RUNDIR/lib/X11"
  718.     mkdir $RUNDIR/lib/X11
  719. fi
  720. if [ ! -d $ETCDIR ]; then
  721.     NewEtcDir=YES
  722.     echo "Creating $ETCDIR"
  723.     mkdir $ETCDIR
  724. fi
  725.  
  726. if [ -d $RUNDIR -a -d $RUNDIR/bin -a -d $RUNDIR/lib ]; then
  727.     echo ""
  728.     echo "You appear to have an existing installation of X.  Continuing will"
  729.     echo "overwrite it.  You will, however, have the option of being prompted"
  730.     echo "before most configuration files are overwritten."
  731.     ContinueYes
  732. fi
  733.  
  734. if [ X"$OLDFILES" != X ]; then
  735.     echo ""
  736.     echo "Removing some old files that are no longer required..."
  737.     for i in $OLDFILES; do
  738.         if [ -f $i ]; then
  739.             echo "    removing old file $i"
  740.             rm -f $i
  741.         fi
  742.     done
  743.     echo ""
  744. fi
  745.  
  746. if [ X"$OLDDIRS" != X ]; then
  747.     echo ""
  748.     echo "Removing some old directories that are no longer required..."
  749.     for i in $OLDDIRS; do
  750.         if [ -d $i ]; then
  751.             echo "    removing old directory $i"
  752.             rm -fr $i
  753.         fi
  754.     done
  755.     echo ""
  756. fi
  757.  
  758. if [ ! -d $RUNDIR/lib/X11/xkb ]; then
  759.     echo "Creating $RUNDIR/lib/X11/xkb"
  760.     mkdir $RUNDIR/lib/X11/xkb
  761. fi
  762. # Check for config file directories that may need to be moved.
  763.  
  764. EtcToMove=
  765. if [ X"$NoSymLinks" != XYES ]; then
  766.     for i in $ETCLINKS; do
  767.         if [ -d $RUNDIR/lib/X11/$i -a ! $L $RUNDIR/lib/X11/$i ]; then
  768.             EtcToMove="$EtcToMove $i"
  769.         fi
  770.     done
  771. fi
  772.  
  773. if [ X"$EtcToMove" != X ]; then
  774.     echo "XFree86 now installs most customisable configuration files under"
  775.     echo "$ETCDIR instead of under $RUNDIR/lib/X11, and has symbolic links"
  776.     echo "under $RUNDIR/lib/X11 that point to $ETCDIR.  You currently have"
  777.     echo "files under the following subdirectories of $RUNDIR/lib/X11:"
  778.     echo ""
  779.     echo "$EtcToMove"
  780.     echo ""
  781.     echo "Do you want to move them to $ETCDIR and create the necessary"
  782.     Echo "links? (y/n) [y] "
  783.     read response
  784.     case "$response" in
  785.     [nN]*)
  786.         echo ""
  787.         echo "Note: this means that your run-time config files will remain"
  788.         echo "in the old $RUNDIR/lib/X11 location."
  789.         NoSymLinks=YES;
  790.         ;;
  791.     esac
  792.     echo ""
  793.     if [ X"NoSymlinks" != XYES ]; then
  794.         for i in $EtcToMove; do
  795.             echo "Moving $RUNDIR/lib/X11/$i to $ETCDIR/$i ..."
  796.             if [ ! -d $ETCDIR/$i ]; then
  797.                 mkdir $ETCDIR/$i
  798.             fi
  799.             $TAR -C $RUNDIR/lib/X11/$i -c -f - . | \
  800.                 $TAR -C $ETCDIR/$i -v -x -p -U -f - && \
  801.                 rm -fr $RUNDIR/lib/X11/$i && \
  802.                 ln -s $ETCDIR/$i $RUNDIR/lib/X11/$i
  803.         done
  804.     fi
  805. fi
  806.  
  807. # Maybe allow a backup of the config files to be made?
  808.  
  809. # Extract Xetc.tgz into a temporary location, and prompt for moving the
  810. # files.
  811.  
  812. echo "Extracting $ETCDIST into a temporary location ..."
  813. rm -fr .etctmp
  814. mkdir .etctmp
  815. (cd .etctmp; $EXTRACT $WDIR/$ETCDIST)
  816. for i in $ETCLINKS; do
  817.     DoCopy=YES
  818.     if [ -d $RUNDIR/lib/X11/$i ]; then
  819.         Echo "Do you want to overwrite the $i config files? (y/n) [n] "
  820.         read response
  821.         case "$response" in
  822.         [yY]*)
  823.             : OK
  824.             ;;
  825.         *)
  826.             DoCopy=NO
  827.             ;;
  828.         esac
  829.     fi
  830.     if [ $DoCopy = YES ]; then
  831.         echo "Installing the $i config files ..."
  832.         if [ X"$NoSymLinks" != XYES ]; then
  833.             if [ ! -d $ETCDIR/$i ]; then
  834.                 mkdir $ETCDIR/$i
  835.             fi
  836.             if [ ! -d $RUNDIR/lib/X11/$i ]; then
  837.                 ln -s $ETCDIR/$i $RUNDIR/lib/X11/$i
  838.             fi
  839.         else
  840.             if [ ! -d $RUNDIR/lib/X11/$i ]; then
  841.                 mkdir $RUNDIR/lib/X11/$i
  842.             fi
  843.         fi
  844.         $TAR -C .etctmp/$i -c -f - . | \
  845.             $TAR -C $RUNDIR/lib/X11/$i -v -x -p -U -f -
  846.     fi
  847. done
  848. if [ X"$XKBDIR" != X ]; then
  849.     rm -fr $RUNDIR/lib/X11/xkb/compiled
  850.     if [ X"$NoSymLinks" = XYES ]; then
  851.         XKBDIR=$RUNDIR/lib/X11/xkb/compiled
  852.     fi
  853.     if [ -d .etctmp/xkb ]; then
  854.         mkdir $XKBDIR
  855.         $TAR -C .etctmp/xkb -c -f - . | \
  856.             $TAR -C $XKBDIR -v -x -p -U -f -
  857.     fi
  858. fi
  859. rm -fr .etctmp
  860.  
  861. echo ""
  862. echo "Installing the mandatory parts of the binary distribution"
  863. echo ""
  864. for i in $BASEDIST $SERVDIST; do
  865.     (cd $RUNDIR; $EXTRACT $WDIR/$i)
  866. done
  867. if [ X"$VARDIST" != X ]; then
  868.     (cd $VARDIR; $EXTRACT $WDIR/$VARDIST)
  869. fi
  870.  
  871. if [ X"$XKBDIR" != X -a X"$XKBDIR" != X"$RUNDIR/lib/X11/xkb/compiled" ]; then
  872.     rm -fr $RUNDIR/lib/X11/xkb/compiled
  873.     ln -s $XKBDIR $RUNDIR/lib/X11/xkb/compiled
  874. fi
  875.  
  876. echo "Checking for optional components to install ..."
  877. for i in $OPTDIST $EXTRAOPTDIST; do
  878.     if [ -f $i ]; then
  879.         Echo "Do you want to install $i (`Description $i`)? (y/n) [y] "
  880.         read response
  881.         case "$response" in
  882.         [nN]*)
  883.             : skip this one
  884.             ;;
  885.         *)
  886.             (cd $RUNDIR; $EXTRACT $WDIR/$i)
  887.             ;;
  888.         esac
  889.     fi
  890. done
  891.  
  892. # Need to run ldconfig on some OSs
  893. case "$OsName" in
  894. FreeBSD|NetBSD|OpenBSD)
  895.     echo ""
  896.     echo "Running ldconfig"
  897.     /sbin/ldconfig -m $RUNDIR/lib
  898.     ;;
  899. Linux)
  900.     echo ""
  901.     echo "Running ldconfig"
  902.     /sbin/ldconfig $RUNDIR/lib
  903.     ;;
  904. esac
  905.  
  906. # Run mkfontdir in the local and misc directories to make sure that
  907. # the fonts.dir files are up to date after the installation.
  908. echo ""
  909. for i in $FONTDIRS $EXTRAFONTDIRS; do
  910.     if [ -d $RUNDIR/lib/X11/fonts/$i ]; then
  911.         Echo "Updating the fonts.dir file in $RUNDIR/lib/X11/fonts/$i..."
  912.         $RUNDIR/bin/mkfontdir $RUNDIR/lib/X11/fonts/$i
  913.         echo ""
  914.     fi
  915. done
  916.         
  917. # Check if the system has a termcap file
  918. TERMCAP1DIR=/usr/share
  919. TERMCAP2=/etc/termcap
  920. if [ -d $TERMCAP1DIR ]; then
  921.     TERMCAP1=`find $TERMCAP1DIR -type f -name termcap -print 2> /dev/null`
  922.     if [ x"$TERMCAP1" != x ]; then
  923.         TERMCAPFILE="$TERMCAP1"
  924.     fi
  925. fi
  926. if [ x"$TERMCAPFILE" = x ]; then
  927.     if [ -f $TERMCAP2 ]; then
  928.         TERMCAPFILE="$TERMCAP2"
  929.     fi
  930. fi
  931.  
  932. # Override this for some OSs
  933.  
  934. case "$OsName" in
  935. OpenBSD)
  936.     TERMCAPFILE=""
  937.     ;;
  938. esac
  939.  
  940. if [ X"$TERMCAPFILE" != X ]; then
  941.     echo ""
  942.     echo "You appear to have a termcap file: $TERMCAPFILE"
  943.     echo "This should be edited manually to replace the xterm entries"
  944.     echo "with those in $RUNDIR/lib/X11/etc/xterm.termcap"
  945.     echo ""
  946.     echo "Note: the new xterm entries are required to take full advantage"
  947.     echo "of new features, but they may cause problems when used with"
  948.     echo "older versions of xterm.  A terminal type 'xterm-r6' is included"
  949.     echo "for compatibility with the standard X11R6 version of xterm."
  950. fi
  951.  
  952. # Check for terminfo, and update the xterm entry
  953. TINFODIR=/usr/lib/terminfo
  954. # Does this list need to be updated?
  955. OLDTINFO=" \
  956.     x/xterm \
  957.     x/xterms \
  958.     x/xterm-24 \
  959.     x/xterm-vi \
  960.     x/xterm-65 \
  961.     x/xterm-bold \
  962.     x/xtermm \
  963.     x/xterm-boldso \
  964.     x/xterm-ic \
  965.     x/xterm-r6 \
  966.     x/xterm-old \
  967.     x/xterm-r5 \
  968.     v/vs100"
  969.     
  970. if [ -d $TINFODIR ]; then
  971.     echo ""
  972.     echo "You appear to have a terminfo directory: $TINFODIR"
  973.     echo "New xterm terminfo entries can be installed now."
  974.     echo ""
  975.     echo "Note: the new xterm entries are required to take full advantage"
  976.     echo "of new features, but they may cause problems when used with"
  977.     echo "older versions of xterm.  A terminal type 'xterm-r6' is included"
  978.     echo "for compatibility with the standard X11R6 version of xterm."
  979.     echo ""
  980.     echo "Do you wish to have the new xterm terminfo entries installed"
  981.     Echo "now (y/n)? [n] "
  982.     read response
  983.     case "$response" in
  984.     [yY]*)
  985.         echo ""
  986.         for t in $OLDTINFO; do
  987.             if [ -f $TINFODIR/$t ]; then
  988.                 echo "Moving old terminfo file $TINFODIR/$t to $TINFODIR/$t.bak"
  989.                 rm -f $TINFODIR/$t.bak
  990.                 mv -f $TINFODIR/$t $TINFODIR/$t.bak
  991.             fi
  992.         done
  993.         echo ""
  994.         echo "Installing new terminfo entries for xterm."
  995.         echo ""
  996.         echo "On some systems you may get warnings from tic about 'meml'"
  997.         echo "and 'memu'.  These warnings can safely be ignored."
  998.         echo ""
  999.         tic $RUNDIR/lib/X11/etc/xterm.terminfo
  1000.         ;;
  1001.     *)
  1002.         echo ""
  1003.         echo "Not installing new terminfo entries for xterm."
  1004.         echo "They can be installed later by running:"
  1005.         echo ""
  1006.         echo "  tic $RUNDIR/lib/X11/etc/xterm.terminfo"
  1007.         ;;
  1008.     esac
  1009. fi
  1010.  
  1011. if [ -f $RUNDIR/bin/rstartd ]; then
  1012.     echo ""
  1013.     echo "If you are going to use rstart and $RUNDIR/bin isn't in the"
  1014.     echo "default path for commands run remotely via rsh, you will need"
  1015.     echo "a link to rstartd installed in /usr/bin."
  1016.     echo ""
  1017.     Echo "Do you wish to have this link installed (y/n)? [n] "
  1018.     read response
  1019.     case "$response" in
  1020.     [yY]*)
  1021.         echo "Creating link from $RUNDIR/bin/rstartd to /usr/bin/rstartd"
  1022.         rm -f /usr/bin/rstartd
  1023.         ln -s $RUNDIR/bin/rstartd /usr/bin/rstartd
  1024.         ;;
  1025.     esac
  1026. fi
  1027.  
  1028. # Finally, check for old 3.3.x modules that will conflict with 4.x
  1029. if [ -d $RUNDIR/lib/modules ]; then
  1030.     for i in $OLDMODULES; do
  1031.         if [ -f $RUNDIR/lib/modules/$i ]; then
  1032.             ModList="$ModList $i"
  1033.         fi
  1034.     done
  1035.     if [ X"$ModList" != X ]; then
  1036.         echo ""
  1037.         echo "The following 3.3.x X server modules were found in"
  1038.         echo "$RUNDIR/lib/modules, and they may cause problems when running"
  1039.         echo "$VERSION:"
  1040.         echo ""
  1041.         echo "  $ModList"
  1042.         echo ""
  1043.         echo "Do you want them moved to $RUNDIR/lib/modules/old?"
  1044.         echo "Note: that if you want to use them with 3.3.x again, you'll"
  1045.         Echo "need to move them back manually. (y/n) [n] "
  1046.         read response
  1047.         case "$response" in
  1048.         [yY]*)
  1049.             if [ ! -d $RUNDIR/lib/modules/old ]; then
  1050.                 echo ""
  1051.                 echo "Creating $RUNDIR/lib/modules/old"
  1052.                 mkdir $RUNDIR/lib/modules/old
  1053.             else
  1054.                 echo ""
  1055.             fi
  1056.             if [ -d $RUNDIR/lib/modules/old ]; then
  1057.                 for i in $ModList; do
  1058.                     echo "Moving $i to $RUNDIR/lib/modules/old"
  1059.                     mv $RUNDIR/lib/modules/$i $RUNDIR/lib/modules/old/$i
  1060.                 done
  1061.             else
  1062.                 echo "Failed to create directory $RUNDIR/lib/modules/old"
  1063.             fi
  1064.             ;;
  1065.         *)
  1066.             echo ""
  1067.             echo "Make sure that you rename, move or delete the old modules"
  1068.             echo "before running $VERSION."
  1069.         esac
  1070.     fi
  1071.     # Some distributions have old codeconv modules
  1072.     if [ -d $RUNDIR/lib/modules/codeconv ]; then
  1073.         if [ -f $RUNDIR/lib/modules/codeconv/ISO8859_1.so ]; then
  1074.             echo ""
  1075.             echo "Warning: it looks like there are some old *.so modules"
  1076.             echo "in $RUNDIR/lib/modules/codeconv.  You may need to rename,"
  1077.             echo "move or delete them if you use the xtt font module."
  1078.         fi
  1079.     fi
  1080. fi
  1081.  
  1082. echo ""
  1083. echo "Installation complete."
  1084.  
  1085. exit 0
  1086.