|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +begin_message() { |
| 4 | + clear |
| 5 | + cat <<EOF |
| 6 | +
|
| 7 | + This script is provided to simplify the installation of GtkAda. |
| 8 | +
|
| 9 | + You will be asked for confirmation before the actual installation is |
| 10 | + done. You can break out of this script at any time before this. |
| 11 | +
|
| 12 | + Hit RETURN to continue. |
| 13 | +EOF |
| 14 | + |
| 15 | + read x |
| 16 | +} |
| 17 | + |
| 18 | +current_dir=`/bin/pwd` |
| 19 | + |
| 20 | +# Checks for the presence of a Gtk+ binary package in gtk-bin/ |
| 21 | +check_gtk_bin() { |
| 22 | + gtk_bin_dir=`pwd`/gtk-bin |
| 23 | + if test ! -d "$gtk_bin_dir"; then |
| 24 | + echo "Gtk+ binary package not found. Aborting the installation process." |
| 25 | + exit |
| 26 | + fi |
| 27 | +} |
| 28 | + |
| 29 | +## Read the base directory (absolute path name) |
| 30 | +## Sets the variable $basedir |
| 31 | +ask_basedir() { |
| 32 | + clear |
| 33 | + default_dir=`type gnatmake 2>/dev/null| cut -d' ' -f3` |
| 34 | + default_dir=`dirname "$default_dir" 2>/dev/null` |
| 35 | + |
| 36 | + if [ "$default_dir" != "" -a "$default_dir" != "." -a "$default_dir" != "/usr/bin" ]; then |
| 37 | + default_dir=`cd "$default_dir/.."; pwd` |
| 38 | + cat <<EOF |
| 39 | +
|
| 40 | + GNAT has been found in $default_dir. |
| 41 | + Do you want to install GtkAda there too? Hit RETURN if yes or enter |
| 42 | + the name of the directory in which GtkAda should be installed: |
| 43 | +
|
| 44 | +EOF |
| 45 | + else |
| 46 | + default_dir=/opt/gtkada |
| 47 | + cat <<EOF |
| 48 | + Enter the name of the directory in which you would like to install GtkAda |
| 49 | +
|
| 50 | +EOF |
| 51 | + fi |
| 52 | + |
| 53 | + while [ "$basedir" = "" ]; do |
| 54 | + printf "[$default_dir] " |
| 55 | + read basedir |
| 56 | + if [ "$basedir" = "" ]; then |
| 57 | + basedir="$default_dir" |
| 58 | + fi |
| 59 | + if echo "$basedir" | egrep "^[/~]" >/dev/null; then |
| 60 | + true |
| 61 | + else |
| 62 | + basedir=`pwd`/"$basedir" |
| 63 | + fi |
| 64 | + done |
| 65 | + |
| 66 | + # Suppress the final / in basedir |
| 67 | + basedir=`echo "$basedir" | sed -e 's/\/$//'` |
| 68 | + |
| 69 | + # Check that we have permission to write in $basedir |
| 70 | + if test -d "$basedir"; then |
| 71 | + if test -w "$basedir"; then |
| 72 | + if [ -x "$basedir/bin/gtkada" ]; then |
| 73 | + echo " $basedir/bin/gtkada found." |
| 74 | + printf " Do you want to overwrite existing installation [Y/n] ? " |
| 75 | + read x |
| 76 | + if [ "$x" = "n" -o "$x" = "N" ]; then |
| 77 | + echo "Aborting the installation process" |
| 78 | + exit |
| 79 | + fi |
| 80 | + fi |
| 81 | + else |
| 82 | + echo "You do not have permission to write in $basedir" |
| 83 | + echo "Please check whether you should be root to install in that directory." |
| 84 | + echo "Aborting the installation process" |
| 85 | + exit |
| 86 | + fi |
| 87 | + else |
| 88 | + echo "" |
| 89 | + echo " Directory $basedir does not exist." |
| 90 | + printf " Do you want to create it [Y/n] ? " |
| 91 | + read x |
| 92 | + if [ "$x" = "n" -o "$x" = "N" ]; then |
| 93 | + echo "Aborting the installation process" |
| 94 | + exit |
| 95 | + fi |
| 96 | + mkdir -p "$basedir" |
| 97 | + fi |
| 98 | + |
| 99 | + echo "" |
| 100 | + printf " Are you now ready to proceed with the installation [Y/n] ? " |
| 101 | + read x |
| 102 | + if [ "$x" = "n" -o "$x" = "N" ]; then |
| 103 | + echo "Aborting the installation process" |
| 104 | + exit |
| 105 | + fi |
| 106 | +} |
| 107 | + |
| 108 | +################################## |
| 109 | +## Do the actual installation |
| 110 | +################################## |
| 111 | + |
| 112 | +install_binaries() { |
| 113 | + |
| 114 | + echo "Copying the Gtk+ binaries" |
| 115 | + |
| 116 | + cp -r $gtk_bin_dir/* $basedir |
| 117 | + |
| 118 | + echo "Setting up the environment" |
| 119 | + eval `$basedir/bin/gtkada-env.sh --print-only` |
| 120 | + |
| 121 | + echo "Compiling GtkAda" |
| 122 | + ./configure --prefix=$basedir --with-GL=no && make all install 2>&1 | \ |
| 123 | + tee install.log |
| 124 | + |
| 125 | + if [ "$?" != "0" ]; then |
| 126 | + echo "" |
| 127 | + echo "An error occurred. Please see install.log.""" |
| 128 | + exit |
| 129 | + fi |
| 130 | +} |
| 131 | + |
| 132 | +## |
| 133 | +## Write the end message |
| 134 | +## |
| 135 | +end_message() { |
| 136 | + clear |
| 137 | + cat <<EOF |
| 138 | +
|
| 139 | + GtkAda has now been installed on your machine. |
| 140 | +
|
| 141 | + You can enter the GtkAda environment by doing: |
| 142 | +
|
| 143 | + $basedir/bin/gtkada-env.sh |
| 144 | +
|
| 145 | +EOF |
| 146 | +} |
| 147 | + |
| 148 | +## Main program |
| 149 | + |
| 150 | +check_gtk_bin |
| 151 | +begin_message |
| 152 | +ask_basedir |
| 153 | +install_binaries |
| 154 | +end_message |
| 155 | + |
0 commit comments