eval $uz_command
}
-# =============================
-# = Find executables function =
-# =============================
+# ================================
+# = Choose installation function =
+# ================================
-function find_executables {
- exe=""
- execs=`which -a $@`
- if [ "${#execs[@]}" -gt "0" ]; then
- (>&2 echo "--> I have found a(some) executable(s), please choose one:")
- c=0
- choices=()
- for i in ${execs[@]}; do
- (>&2 echo " [$c] $i")
- choices+=("$i")
- c=$[$c+1]
- done
- (>&2 echo " [$c] Manually choose another installation")
- c=$[$c+1]
- (>&2 echo " [$c] Compile from source code")
- (>&2 echo -n " Please choose a number and press [ENTER]: ")
- read choice
- if [ "$choice" -lt "${#choices[@]}" ]; then
- exe=${choices[$choice]}
- elif [ "$choice" -eq "${#choices[@]}" ]; then
- read -e -p "Please provide a valid location: " tmp
- exe=`readlink -f ${tmp/#\~/$HOME}`
- fi
+function choose_installation {
+ ## Load choices
+ choices=()
+ for i in $@; do
+ choices+=("$i")
+ done
+
+ ## Print menu
+ if [ "${#choices[@]}" -eq 0 ]; then
+ (>&2 echo "--> I have not found any installation, please choose:")
else
- (>&2 echo "--> I have not found any valid install, please choose:")
- (>&2 echo " [0] Manually choose an installation")
- (>&2 echo " [1] Compile from source code")
- (>&2 echo -n " Please choose a number and press [ENTER]: ")
- read choice
- if [ "$choice" -eq "0" ]; then
- read -e -p "Please provide a valid location: " tmp
- exe=`readlink -f ${tmp/#\~/$HOME}`
- fi
+ (>&2 echo "--> I have found a(some) installation(s), please choose one:")
+ fi
+ c=0
+ for i in ${choices[@]}; do
+ (>&2 echo " [$c] $i")
+ c=$[$c+1]
+ done
+ (>&2 echo " [$c] Manually choose another installation")
+ c=$[$c+1]
+ (>&2 echo " [$c] Compile from source code")
+
+ ## Get user input
+ (>&2 echo -n " Please choose a number and press [ENTER]: ")
+ read choice
+ exe=""
+ if [ "$choice" -lt "${#choices[@]}" ]; then
+ exe=${choices[$choice]}
+ elif [ "$choice" -eq "${#choices[@]}" ]; then
+ read -e -p "Please provide a valid location: " tmp
+ exe=`readlink -f ${tmp/#\~/$HOME}`
fi
echo "$exe"
}
+# ================================
+# = Prepare compilation function =
+# ================================
+
+function prepare_compilation {
+ source_dir=""
+ (>&2 echo "----> Ok, I will compile from source code <----")
+ read -e -p "--> Please provide a valid location of source code (either a compressed file or directory): " tmp
+ loc=`readlink -f ${tmp/#\~/$HOME}`
+ if [[ -f $loc ]]; then
+ (>&2 echo -n "--> Expanding source code... ")
+ source_dir=`dirname $loc`/`echo \`basename $loc\` | sed 's/\./_/g'`_sources
+ rm -rf $source_dir
+ mkdir -p $source_dir
+ uncompress $loc $source_dir
+ (>&2 echo "done!")
+ else
+ source_dir=$loc
+ fi
+ echo "$source_dir"
+}
+
## eof - $RCSfile$