diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-06-15 08:15:52 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-06-15 08:15:52 +0200 |
commit | 9916a54ae263be4ce87554aa94b23fd5188a55aa (patch) | |
tree | 651a14861fd35e4474d89fe351764e94e2377d47 /easy_e17.sh | |
parent | ea57f5ef6cb7336c6fabcd1db53189aa2a4a49ab (diff) | |
download | bin-9916a54ae263be4ce87554aa94b23fd5188a55aa.zip bin-9916a54ae263be4ce87554aa94b23fd5188a55aa.tar.gz |
easy_e17.sh: rewrite, update move compilation functions
Diffstat (limited to 'easy_e17.sh')
-rwxr-xr-x | easy_e17.sh | 328 |
1 files changed, 153 insertions, 175 deletions
diff --git a/easy_e17.sh b/easy_e17.sh index ad95370..b26d070 100755 --- a/easy_e17.sh +++ b/easy_e17.sh @@ -762,31 +762,117 @@ function svn_fetch () fi } - -# SRC ############################################################################# - -function find_local_path () +function parse_svn_updates () { - name=$1 - path="" - for dir in `find "$src_path" -maxdepth 3 -type d -name "$name" | awk -F "$src_path" '{print $2}'`; do + tmp="" + for dir in `egrep "^[A|D|G|U] " "$tmp_path/source_update.log" | awk '{print $2}' | sed 's,[^/]*$,,g' | sort -u`; do + add_pkg="" found=0 for idir in $ignore_dirs; do topdir=`echo "$dir" | cut -d'/' -f1` if [ "$topdir" == "$idir" ]; then found=1; fi done if [ $found == 1 ]; then continue; fi + for pkg in $real_packages; do + if [ `echo "$dir" | egrep -q "^$pkg/|/$pkg/"; echo $?` == 0 ]; then + if [ ! `echo "$tmp" | egrep -q "^$pkg | $pkg\$ | $pkg "; echo $?` == 0 ]; then + tmp="$tmp $pkg" + echo "- $pkg" + fi + break + fi + done + done + real_packages=$tmp +} - if [ "${#dir}" -lt "${#path}" ] || [ -z "$path" ]; then - path=$dir + +# SRC ############################################################################# + +function del_lines () +{ + cnt=0 + max=$1 + while [ ! "$cnt" == "$max" ]; do + echo -n -e "\b \b" + cnt=$(($cnt+1)) + done +} + +function rotate () +{ + pid=$1 + name=$2 + animation_state=1 + log_line="" + echo -n " " + while [ "`ps -p $pid -o comm=`" ]; do + last_line=`tail -1 "$logs_path/$name.log"` + if [ ! "$log_line" = "$last_line" ]; then + echo -e -n "\b\b\b[\033[1m" + case $animation_state in + 1) + echo -n "|" + animation_state=2 + ;; + 2) + echo -n "/" + animation_state=3 + ;; + 3) + echo -n "-" + animation_state=4 + ;; + 4) + echo -n "\\" + animation_state=1 + ;; + esac + echo -n -e "\033[0m" + echo -n "]" + log_line=$last_line fi + sleep 1 done + if [ -e "$status_path/$name.noerrors" ]; then + del_lines 12 + else + del_lines 3 + echo -e "\033[1mERROR!\033[0m" + set_notification "critical" "Package '$name': build failed" + if [ ! "$skip_errors" ]; then + set_title "$name: ERROR" + echo -e "\033[1m--------------------------------------------------------------------------------\033[0m" + echo + echo -e "\033[1m-----------------------------------\033[7m Last loglines \033[0m\033[1m------------------------------\033[0m" + echo -n -e "\033[1m" + tail -25 "$logs_path/$name.log" + echo -n -e "\033[0m" + echo -e "\033[1m--------------------------------------------------------------------------------\033[0m" + echo + echo "-> Get more informations by checking the log file '$logs_path/$name.log'!" + echo + set_title + exit 2 + fi + fi +} - if [ "$path" ]; then echo "$src_path/$path"; fi +function error () +{ + echo -e "\n\n\033[1mERROR: $1\033[0m\n\n" + set_title "ERROR: $1" + set_notification "critical" "Error: $1" + exit 2 } -function build_each () -{ for pkg in $packages; do compile $pkg; done +function logfile_banner () +{ + cmd=$1 + logfile=$2 + echo "-------------------------------------------------------------------------------" >> "$logfile" + echo "EASY_E17 $version CMD: $cmd" >> "$logfile" + echo "-------------------------------------------------------------------------------" >> "$logfile" } function run_command () @@ -797,11 +883,9 @@ function run_command () log_title=$4 mode_needed=$5 cmd=$6 - set_title "$name: $title ($pkg_pos/$pkg_total)" echo -n "$log_title" logfile_banner "$cmd" "$logs_path/$name.log" - if [ $mode_needed == "rootonly" ]; then mode_needed=$mode else @@ -819,62 +903,33 @@ function run_command () nice -n $nice_level $cmd >> "$logs_path/$name.log" 2>&1 && touch $status_path/$name.noerrors & ;; esac - pid="$!" rotate "$pid" "$name" } -function write_appname () +function find_local_path () { name=$1 - hidden=$2 - cnt=${#name} - max=27 - - if [ "$hidden" ]; then - c=-3 - while [ ! $c = $cnt ]; do - echo -n " " - c=$(($c+1)) + path="" + for dir in `find "$src_path" -maxdepth 3 -type d -name "$name" | awk -F "$src_path" '{print $2}'`; do + found=0 + for idir in $ignore_dirs; do + topdir=`echo "$dir" | cut -d'/' -f1` + if [ "$topdir" == "$idir" ]; then found=1; fi done - else - echo -n "- $name " - fi + if [ $found == 1 ]; then continue; fi - while [ ! $cnt = $max ]; do - echo -n "." - cnt=$(($cnt+1)) + if [ "${#dir}" -lt "${#path}" ] || [ -z "$path" ]; then + path=$dir + fi done - echo -n " " + + if [ "$path" ]; then echo "$src_path/$path"; fi } function compile () { name=$1 - - write_appname "$name" - - for one in $skip; do - if [ "$name" == "$one" ]; then - echo "SKIPPED" - touch $status_path/$name.skipped - return - fi - done - if [ "$only" ] || [ "$action" == "update" ]; then - found="" - for one in $only; do - if [ "$name" == "$one" ]; then found=1; fi - done - if [ -z "$found" ]; then - echo "SKIPPED" - touch $status_path/$name.skipped - return - fi - fi - - pkg_pos=$(($pkg_pos+1)) - if [ -e "$status_path/$name.installed" ]; then echo "previously installed" return @@ -886,10 +941,8 @@ function compile () return fi cd "$path" - rm -f $status_path/$name.noerrors rm -f "$logs_path/$name.log" - if [ $clean -ge 1 ]; then if [ -e "Makefile" ]; then if [ $clean -eq 1 ]; then @@ -915,14 +968,12 @@ function compile () if [ $clean -ge 3 ]; then run_command "$name" "$path" "uninstall" "uninst : " "rootonly" "$make -j $threads uninstall clean distclean" if [ ! -e "$status_path/$name.noerrors" ] ; then return ; fi - # It's no longer installed if we just uninstalled it. # Even if the uninstall failed, it's best to mark it as uninstalled so that a partial uninstall gets fixed later. rm -f $status_path/$name.installed fi fi fi - # get autogen arguments args="" for app_arg in `echo $autogen_args | tr -s '\,' ' '`; do @@ -931,7 +982,6 @@ function compile () args="$args `echo $app_arg | cut -d':' -f2- | tr -s '+' ' '`" fi done - if [ -e "autogen.sh" ]; then run_command "$name" "$path" "autogen" "autogen: " "$mode" "./autogen.sh --prefix=$install_path $accache $args" if [ ! -e "$status_path/$name.noerrors" ] ; then return ; fi @@ -979,7 +1029,6 @@ function compile () if [ ! -e "$status_path/$name.noerrors" ] ; then return ; fi fi fi - # All done, mark it as installed OK. touch $status_path/$name.installed rm -f $status_path/$name.noerrors @@ -987,101 +1036,48 @@ function compile () set_notification "normal" "Package '$name': build successful" } -function rotate () +function write_appname () { - pid=$1 - name=$2 - animation_state=1 - log_line="" - echo -n " " - while [ "`ps -p $pid -o comm=`" ]; do - last_line=`tail -1 "$logs_path/$name.log"` - if [ ! "$log_line" = "$last_line" ]; then - echo -e -n "\b\b\b[\033[1m" - case $animation_state in - 1) - echo -n "|" - animation_state=2 - ;; - 2) - echo -n "/" - animation_state=3 - ;; - 3) - echo -n "-" - animation_state=4 - ;; - 4) - echo -n "\\" - animation_state=1 - ;; - esac - echo -n -e "\033[0m" - echo -n "]" - log_line=$last_line - fi - sleep 1 - done - if [ -e "$status_path/$name.noerrors" ]; then - del_lines 12 + name=$1 + hidden=$2 + cnt=${#name} + max=27 + if [ "$hidden" ]; then + c=-3 + while [ ! $c = $cnt ]; do + echo -n " " + c=$(($c+1)) + done else - del_lines 3 - echo -e "\033[1mERROR!\033[0m" - set_notification "critical" "Package '$name': build failed" - if [ ! "$skip_errors" ]; then - set_title "$name: ERROR" - echo -e "\033[1m--------------------------------------------------------------------------------\033[0m" - echo - echo -e "\033[1m-----------------------------------\033[7m Last loglines \033[0m\033[1m------------------------------\033[0m" - echo -n -e "\033[1m" - tail -25 "$logs_path/$name.log" - echo -n -e "\033[0m" - echo -e "\033[1m--------------------------------------------------------------------------------\033[0m" - echo - echo "-> Get more informations by checking the log file '$logs_path/$name.log'!" - echo - set_title - exit 2 - fi + echo -n "- $name " fi -} - -function del_lines () -{ - cnt=0 - max=$1 - while [ ! "$cnt" == "$max" ]; do - echo -n -e "\b \b" + while [ ! $cnt = $max ]; do + echo -n "." cnt=$(($cnt+1)) done + echo -n " " } -function error () -{ - echo -e "\n\n\033[1mERROR: $1\033[0m\n\n" - set_title "ERROR: $1" - set_notification "critical" "Error: $1" - exit 2 -} - -function logfile_banner () +function build_each () { - cmd=$1 - logfile=$2 - echo "-------------------------------------------------------------------------------" >> "$logfile" - echo "EASY_E17 $version CMD: $cmd" >> "$logfile" - echo "-------------------------------------------------------------------------------" >> "$logfile" -} - -function cnt_pkgs () { - pkg_total=0 pkg_pos=0 - - if [ -n "$only" ]; then - pkg_total=`echo "$only" | wc -w` - else - pkg_total=`echo "$packages" | wc -w` - fi + for pkg in $packages; do + pkg_pos=$(($pkg_pos+1)) + write_appname "$pkg" + must=0 + for one in $real_packages; do + if [ "$pkg" == "$one" ]; then + must=1 + break + fi + done + if [ $must -eq 1 ]; then + compile $pkg + else + echo "SKIPPED" + touch $status_path/$name.skipped + fi + done } @@ -1140,7 +1136,7 @@ echo -e "\033[1m-----------------------------\033[7m Source checkout/update \033 if [ -z "$skip_srcupdate" ]; then rm "$tmp_path/source_update.log" 2>/dev/null cd "$src_path" - if [ "`$cmd_src_test &>/dev/null; echo $?`" == 0 ]; then + if [ "`$cmd_svn_test &>/dev/null; echo $?`" == 0 ]; then if [ "$src_mode" == "packages" ]; then echo -e "\033[1m- Full checkout found, changed source mode to 'full'!\033[0m" src_mode="full" @@ -1157,34 +1153,14 @@ echo if [ "$action" == "update" ] && [ -e "$tmp_path/source_update.log" ]; then echo -e "\033[1m--------------------------------\033[7m Parsing updates \033[0m\033[1m-------------------------------\033[0m" - for dir in `egrep "^[A|D|G|U] " "$tmp_path/source_update.log" | \ - awk '{print $2}' | sed 's,[^/]*$,,g' | sort -u`; do - add_pkg="" - found=0 - for idir in $ignore_dirs; do - topdir=`echo "$dir" | cut -d'/' -f1` - if [ "$topdir" == "$idir" ]; then found=1; fi - done - if [ $found == 1 ]; then continue; fi - - for pkg in $packages; do - if [ `echo "$dir" | egrep -q "^$pkg/|/$pkg/"; echo $?` == 0 ]; then - if [ ! `echo "$only" | egrep -q "^$pkg | $pkg\$ | $pkg "; echo $?` == 0 ]; then - only="$pkg $only" - echo "- $pkg" - fi - break - fi - done - done - - if [ -z "$only" ]; then + if [ -z "$real_packages" ]; then echo -e "\n - - - NO UPDATES AVAILABLE - - -\n" fi echo -e "\033[1m--------------------------------------------------------------------------------\033[0m" echo fi +pkg_total=`echo "$real_packages" | wc -w` cnt_pkgs # Count packages @@ -1196,11 +1172,13 @@ sleep 5 if [ "$action" == "install" ]; then set_notification "normal" "Now building packages..." elif [ "$action" == "only" ]; then - set_notification "normal" "Now building following packages: $only" + set_notification "normal" "Now building following packages: $real_packages" elif [ "$action" == "update" ]; then - if [ "$only" ]; then - set_notification "normal" "Now building following packages: $only" - else set_notification "normal" "Everything is up to date, nothing to build"; fi + if [ "$real_packages" ]; then + set_notification "normal" "Now building following packages: $real_packages" + else + set_notification "normal" "Everything is up to date, nothing to build" + fi fi phase 2 echo -e "\033[1m------------------------------\033[7m Installing packages \033[0m\033[1m-----------------------------\033[0m" |