#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.1 #Date: 05-11-07 #System: Ubuntu/Debian GNU/Linux #Information: man tar, man make #Category Thunar scripts (thunar->edit->custom actions) #Name: Compile and Install #Description: Compile package and install #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/compile-install %F #Patterns: *.tar.gz;*.tar.bz2 #Other Files: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Compile and Install" DESCRIPTION=$"Compile package and install" cecho() { case "$1" in "black") echo -ne "\E[30m" ;; "red") echo -ne "\E[31m" ;; "green") echo -ne "\E[32m" ;; "yellow") echo -ne "\E[33m" ;; "blue") echo -ne "\E[34m" ;; "magenta") echo -ne "\E[35m" ;; "cyan") echo -ne "\E[36m" ;; *) echo -ne "\E[30m" exit ;; esac echo "$2" "$3" tput sgr0 } cecho "green" $"program:" echo "$0" cecho "green" $"description:" echo "$DESCRIPTION" echo $"Process these file(s):" for I in "$@" do cecho "cyan" "$I" done echo -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi for I in "$@" do cecho "green" $"starting with: " echo "$I" filetype=`file -b "$I" | cut -f 1 -d ","` filetypeandtool=`file -b "$I"` cecho "green" "filetype:" echo "$filetype" if [ ! -O "$I" ] then user="sudo" fi location="$HOME/" location+=`date +%Y-%m-%d` location+="-" location+=`date +%k:%M:%S`/ cecho "green" $"extract location:" cecho "cyan" "$location" if [ ! -d "$location" ] then cecho "green" $"creating the extract location" $user mkdir -v -m 0777 -p "$location" fi old_directory="$PWD" #echo $old_directory cd "$location" if [ "$filetype" = "bzip2 compressed data" ] then cecho "cyan" $"extract bzip2 file" $user tar -xjf "$I" directory=$($user tar -tjf "$I" | head -1) fi if [ "$filetype" = "gzip compressed data" ] then cecho "cyan" "extract gzip file" $user tar -xzf "$I" directory=$($user tar -tzf "$I" | head -1) fi cd "$directory" echo "$PWD" autogen_file=$($user find "$PWD" -type f -name "autogen.sh") if [ -n "$autogen_file" ] then cecho "red" $"found autogen file" echo "$autogen_file" $user dirname "$autogen_file" | cd $user ./autogen.sh fi configure_file=$($user find "$PWD" -type f -name "configure") if [ -n "$configure_file" ] then cecho "red" $"found configure file" echo "$configure_file" $user dirname "$configure_file" | cd $user ./configure fi make_file=$($user find "$PWD" -type f -name "Makefile") if [ -n "$make_file" ] then cecho "red" $"found make file" echo "$make_file" #stay in the configure directory $user dirname "$install_file" | cd $user make fi while [ $? -eq 1 ] do cecho -n "red" $"error with make commando, retry [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi make done install_file=$($user find "$PWD" -type f -name "install-sh") if [ -n "$install_file" ] || [ -n "$make_file" ] then echo -n $"are you sure you want to install the program [y/N]? " read input if [ "$input" = "y" -o "$input" = "Y" ] then cecho "red" $"found install file" echo "$install_file" $user dirname "$install_file" | cd sudo make install fi fi cecho "green" $"completed with: " echo "$I" cecho "cyan" "---------------" done echo -n $"installation completed, are you sure you want to exit [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi exit 0