home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 May / pcp151c.iso / gnome / install-gnome < prev    next >
Encoding:
Text File  |  1998-10-13  |  6.0 KB  |  233 lines

  1. #!/bin/bash
  2. #
  3. #
  4. # Shell script to install GNOME
  5. #
  6. # Updated: Oct 6, 1998
  7. #
  8.  
  9. # Note to users: if you find a bug in this shell script and are able to
  10. # fix it, or if you simply want to change something, copy the script to
  11. # some writable directory and edit it.  Run it, and it will ask you what
  12. # directory the CDROM is at, and then it will continue with the installation
  13. # appropriately.
  14.  
  15. # default...
  16. ARCH=i386
  17. case `arch` in
  18.   *86) ARCH=i386 ;;
  19.   alpha) ARCH=alpha ;;
  20.   sparc) ARCH=sparc ;;
  21. esac
  22.  
  23. FINDME="RPMS/$ARCH/gnome-core-0.30rh-?.$ARCH.rpm"
  24.  
  25. # Get in the right directory if necessary first!
  26. if [ ! -f $FINDME ] ; then
  27.   relpath=$(echo $0 | sed 's:/[^/]*$::')
  28.   [ -n "$relpath" ] && cd $relpath
  29. fi
  30.  
  31. until [ -f $FINDME ] ; do
  32.   # Now, as long as we are in the wrong directory, keep asking...
  33.   echo 'This program must run from the CDROM.
  34.  
  35. Please type the name of the directory where the CDROM is mounted, or
  36. press control-C to quit:
  37. '
  38.   read dir
  39.   cd $dir
  40. done
  41.  
  42. # Keep things consistent...
  43. BT='Install GNOME Beta Snapshot 1998/10/06'
  44. DG=whiptail
  45.  
  46. D ()
  47. {
  48.   if [ -n "$O" ] ; then
  49.     $DG --fb --backtitle "$BT" "$@" 2>$O || die 1
  50.   else
  51.     $DG --fb --backtitle "$BT" "$@" || die 1
  52.   fi
  53.   bluescreen
  54. }
  55. YN ()
  56. {
  57.   $DG --fb --backtitle "$BT" --yesno "$@"
  58.   ret=$?
  59.   bluescreen
  60.   return $ret
  61. }
  62.  
  63. die ()
  64. {
  65.   [ -s /tmp/ai.$$.log ] && {
  66.     D --msgbox 'GNOME install failed with the following error from rpm:
  67.  
  68. '"$(cat /tmp/ai.$$.log)" 21 72
  69.   }
  70.   if [ -x /usr/bin/tput ] ; then
  71.     tput rmcup ; tput sgr0 ; clear
  72.   else
  73.     reset ; clear
  74.   fi
  75.   rm -f $O
  76.   exit $1
  77. }
  78.  
  79. rpm2dialog ()
  80. {
  81.   awk '
  82.     function telldialog(string, percent)
  83.     {
  84.       printf("XXX\n %s\n%s\nXXX\n", percent, string)
  85.       fflush()
  86.       next
  87.     }
  88.     /^%f/ {
  89.       sub("^%f ", "")
  90.       sub(":.*$", "")
  91.       packagename=$0
  92.       telldialog(sprintf("Installing the %s package...", packagename), 0)
  93.     }
  94.     {
  95.       sub("^%%", "")
  96.       sub("\\..*$", "")
  97.     }
  98.     /100/ {
  99.       telldialog(sprintf("Configuring the %s package...", packagename), 100)
  100.     }
  101.     {
  102.       print
  103.       fflush()
  104.       next
  105.     }'
  106. }
  107.  
  108. findrpm ()
  109. {
  110.   (ls -1d RPMS/$ARCH/*; ls -1d RPMS/noarch/*) | \
  111.     grep '/'"$1"'-[^-][^-]*-[^-][^-]*\.rpm'
  112. }
  113.  
  114. TP=
  115. [ -x /usr/bin/tput ] && {
  116.   TP=''"$(tput cup 0 0)$(tput clear)$(tput bold)$BT"
  117. }
  118. bluescreen ()
  119. {
  120.   echo -n $TP
  121. }
  122.  
  123. O=/tmp/do.$$
  124. touch $O || {
  125.   echo "Could not touch file $O -- check permissions" >&2
  126.   die 1
  127. }
  128.  
  129. bluescreen
  130.  
  131.  
  132.  
  133. # welcome
  134. D --msgbox 'Welcome to the GNOME desktop installation.
  135.  
  136. This unsupported technology preview version, made on 6 Oct 1998, will allow you to play with -- and even work with -- many programs that will be a part of the GNOME desktop.  The various programs have not yet been integrated into a cohesive desktop, and some pieces are simply missing.  However, many programs are quite useable on their own, and we encourage you to try them out.  Plenty of us use them every day.
  137.  
  138. More information on the GNOME project is available at http://www.gnome.org' \
  139.   20 72
  140.  
  141.  
  142.  
  143.  
  144.  
  145. # package list selection
  146.  
  147. # First, packages that we WILL be installing...
  148. # This package set should fulfill all interdependencies.
  149. pl="gnome-libs gnome-core gnome-imglib gnome-rh5.2-release-notes ORBit imlib libghttp libgtop libxml gtk+ glib gtk+10 glib10"
  150.  
  151. # "Optional" packages -- there should be no interdependencies between
  152. # these packages
  153. D --separate-output --checklist \
  154.   'Each of these packages is an optional part of the GNOME environment; that is, you can run other gnome components with any of these packages not installed.  However, they are all quite useful and you very likely will want to install them all, so the default is to install all of them.  In many categories, we list the current contents; more components may be added to each category later.' \
  155.   20 75 8 \
  156.   gnome-games 'A set of desktop games' on \
  157.   gnome-media 'CD player and mixer applications' on \
  158.   gnome-admin 'GNOME system administration utilities' on \
  159.   gnome-utils 'Editors, time tracking, calculators' on \
  160.   yagirc 'A GNOME IRC client' on \
  161.   gnumeric 'The GNOME Spreadsheet' on \
  162.   ggv 'The GNOME Postscript previewer' on \
  163.   gtop 'GNOME process monitor' on \
  164.   grpm 'GNOME frontend to RPM' on
  165.  
  166.  
  167. pl="$pl $(cat $O)"
  168.  
  169. # if gmc is selected, see if we need to upgrade to included mc
  170. #if echo $pl | grep gmc >/dev/null 2>&1 ; then
  171. #  if rpm --test -U `findrpm mc` ; then
  172. #    pl="$pl mc"
  173. #  fi
  174. #fi
  175.  
  176. # Development packages?
  177. if YN 'Do you wish to install the GNOME development packages?' 10 60 ; then
  178.   pl="$pl gnome-core-devel gnome-games-devel ORBit-devel gnome-libs-devel imlib-devel libghttp-devel libgtop-devel libxml-devel gtk+-devel glib-devel"
  179. fi
  180.  
  181.  
  182. # Make list of all packages to install...
  183. plt=
  184. for package in $pl ; do
  185.   plt="$plt `findrpm $package`"
  186. done
  187. pl=$plt
  188.  
  189. # Promised cancel button.
  190. # Try to test for free disk space
  191. FS=$(df /usr | tail -1 | awk '{print $4}')
  192. NS=$(($(for i in $pl; do rpm -qp --qf '%{size}\n' $i; done | \
  193.        awk '{sum += $1} END {print sum}') / 1024))
  194. if [ $FS -lt $NS ] ; then
  195.   if YN 'It appears that GNOME will not fit on your /usr partition
  196.  
  197. Only '$(($FS/1024))'MB are free on /usr, but the packages you have chosen to install require '$(($NS/1024+1))'MB.
  198.  
  199. If you wish to start over and configure the installation differently, press return.
  200.  
  201. Otherwise, uninstall other software until '$(($NS/1024+1))'MB are free on /usr and then choose "yes" to attempt to install.' 20 75 --defaultno ; then
  202.       die 1
  203.   fi
  204. else
  205.   if YN 'The packages you have chosen will use '$(($NS/1024+1))'MB of the '$(($FS/1024))'MB available space in the filesystem containing the /usr directory.
  206.  
  207. Choose yes to install, or no to abort.' 13 75 ; then : ; else
  208.       die 0
  209.   fi
  210. fi
  211.  
  212.  
  213.  
  214. rpm --percent -U $pl 2>/tmp/ai.$$.log | \
  215.     rpm2dialog | \
  216.     D --gauge 'Please wait while RPM inspects your system...' 6 60 0
  217.  
  218. # if no error in the install
  219. if [ ! -s /tmp/ai.$$.log ] ; then
  220.   # convert desktop entries
  221.   ./wmconfig2desktop.pl -q
  222.   D --msgbox 'The GNOME beta snapshot has been successfully installed on your system.
  223.  
  224. Read the README file and docs/index.html for more information.' 14 72
  225. else
  226.   die 1
  227. fi
  228.  
  229. rm -f /tmp/ai.$$.log
  230.  
  231. die 0
  232.  
  233.