install.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/sh
  2. #
  3. # Free Pascal installation script for Linux.
  4. # Michael Van Canneyt, 1996-1999
  5. #
  6. # Don't edit this file.
  7. # Everything can be set when the script is run.
  8. #
  9. # Release Version
  10. VERSION=0.99.12
  11. # some useful functions
  12. # ask displays 1st parameter, and ask new value for variable, whose name is
  13. # in the second parameter.
  14. ask ()
  15. {
  16. askvar=$2
  17. eval old=\$$askvar
  18. eval echo -n \""$1 [$old] : "\"
  19. read $askvar
  20. eval test -z \"\$$askvar\" && eval $askvar=\'$old\'
  21. }
  22. # yesno gives 1 on no, 0 on yes $1 gives text to display.
  23. yesno ()
  24. {
  25. while true; do
  26. echo -n "$1 (Y/N) ? "
  27. read ans
  28. case $ans in
  29. y|Y) return 0;;
  30. n|N) return 1;;
  31. esac
  32. done
  33. }
  34. # Untar files ($3,optional) from file ($1) to the given directory ($2)
  35. unztar ()
  36. {
  37. tar -xzf $HERE/$1 --directory $2 $3
  38. }
  39. # Make all the necessary directories to get $1
  40. makedirhierarch ()
  41. {
  42. OLDDIR=`pwd`
  43. case $1 in
  44. /*) cd /;;
  45. esac
  46. OLDIFS=$IFS;IFS=/;eval set $1; IFS=$OLDIFS
  47. for i
  48. do
  49. test -d $i || mkdir $i || break
  50. cd $i ||break
  51. done
  52. cd $OLDDIR
  53. }
  54. # check to see if something is in the path
  55. checkpath ()
  56. {
  57. ARG=$1
  58. OLDIFS=$IFS; IFS=":";eval set $PATH;IFS=$OLDIFS
  59. for i
  60. do
  61. if [ $i = $ARG ]; then
  62. return 0
  63. fi
  64. done
  65. return 1
  66. }
  67. # Here we start the thing.
  68. # Set some defaults.
  69. LIBDIR=/usr/lib/fpc/$VERSION
  70. SRCDIR=/usr/src/fpc-$VERSION
  71. DOCDIR=/usr/doc/fpc-$VERSION
  72. DEMODIR=$DOCDIR/demo
  73. HERE=`pwd`
  74. if checkpath /usr/local/bin; then
  75. EXECDIR=/usr/local/bin
  76. else
  77. EXECDIR=/usr/bin
  78. fi
  79. # welcome message.
  80. clear
  81. echo "This shell script will attempt to install the Free Pascal Compiler"
  82. echo "version $VERSION" in the directories of your choice.
  83. echo
  84. # Install libraries. Mandatory.
  85. ask "Install libraries in" LIBDIR
  86. echo Installing libraries in $LIBDIR ...
  87. makedirhierarch $LIBDIR
  88. unztar libs.tar.gz $LIBDIR
  89. echo Done.
  90. echo
  91. # Install the program. Mandatory.
  92. ask "Install program in" EXECDIR
  93. echo Installing program in $EXECDIR ...
  94. makedirhierarch $EXECDIR
  95. ln -sf $LIBDIR/ppc386 $EXECDIR/ppc386
  96. echo Done.
  97. echo
  98. # Install the sources. Optional.
  99. if yesno "Install sources"; then
  100. ask "Install sources in" SRCDIR
  101. echo Installing sources in $SRCDIR ...
  102. makedirhierarch $SRCDIR
  103. unztar sources.tar.gz $SRCDIR
  104. echo Done.
  105. fi
  106. echo
  107. # Install the documentation. Optional.
  108. if yesno "Install documentation"; then
  109. ask "Install documentation in" DOCDIR
  110. echo Installing documentation in $DOCDIR ...
  111. makedirhierarch $DOCDIR
  112. unztar docs.tar.gz $DOCDIR
  113. echo Done.
  114. fi
  115. echo
  116. # Install the demos. Optional.
  117. if yesno "Install demos"; then
  118. ask "Install demos in" DEMODIR
  119. echo Installing demos in $DEMODIR ...
  120. makedirhierarch $DEMODIR
  121. unztar demo.tar.gz $DEMODIR
  122. echo Done.
  123. fi
  124. echo
  125. # Install /etc/ppc386.cfg, this is done using the samplecfg script
  126. $LIBDIR/samplecfg $LIBDIR
  127. # The End
  128. echo
  129. echo End of installation.
  130. echo
  131. echo Refer to the documentation for more information.
  132. echo