install.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. UTILDIR=/usr/local/bin
  74. HERE=`pwd`
  75. if checkpath /usr/local/bin; then
  76. EXECDIR=/usr/local/bin
  77. else
  78. EXECDIR=/usr/bin
  79. fi
  80. # welcome message.
  81. clear
  82. echo "This shell script will attempt to install the Free Pascal Compiler"
  83. echo "version $VERSION" in the directories of your choice.
  84. echo
  85. # Install libraries. Mandatory.
  86. ask "Install libraries in" LIBDIR
  87. echo Installing libraries in $LIBDIR ...
  88. makedirhierarch $LIBDIR
  89. unztar libs.tar.gz $LIBDIR
  90. echo Done.
  91. echo
  92. # Install the program. Mandatory.
  93. ask "Install program in" EXECDIR
  94. echo Installing program in $EXECDIR ...
  95. makedirhierarch $EXECDIR
  96. ln -sf $LIBDIR/ppc386 $EXECDIR/ppc386
  97. echo Done.
  98. echo
  99. # Install the utilities. Optional.
  100. if yesno "Install utility binaries"; then
  101. ask "Install utility binaries in" UTILDIR
  102. echo Installing utility binaries in $UTILDIR ...
  103. makedirhierarch $UTILDIR
  104. unztar bins.tar.gz $UTILDIR
  105. echo Done.
  106. fi
  107. echo
  108. # Install the sources. Optional.
  109. if yesno "Install sources"; then
  110. ask "Install sources in" SRCDIR
  111. echo Installing sources in $SRCDIR ...
  112. makedirhierarch $SRCDIR
  113. unztar sources.tar.gz $SRCDIR
  114. echo Done.
  115. fi
  116. echo
  117. # Install the documentation. Optional.
  118. if yesno "Install documentation"; then
  119. ask "Install documentation in" DOCDIR
  120. echo Installing documentation in $DOCDIR ...
  121. makedirhierarch $DOCDIR
  122. unztar docs.tar.gz $DOCDIR
  123. echo Done.
  124. fi
  125. echo
  126. # Install the demos. Optional.
  127. if yesno "Install demos"; then
  128. ask "Install demos in" DEMODIR
  129. echo Installing demos in $DEMODIR ...
  130. makedirhierarch $DEMODIR
  131. unztar demo.tar.gz $DEMODIR
  132. echo Done.
  133. fi
  134. echo
  135. # Install /etc/ppc386.cfg, this is done using the samplecfg script
  136. $LIBDIR/samplecfg $LIBDIR
  137. # The End
  138. echo
  139. echo End of installation.
  140. echo
  141. echo Refer to the documentation for more information.
  142. echo