diff options
author | Srikant Patnaik | 2015-02-20 11:27:15 +0530 |
---|---|---|
committer | Srikant Patnaik | 2015-02-20 11:27:15 +0530 |
commit | 9dd0fd7ac657e7fd3b152213beac1f7d276a4b6b (patch) | |
tree | 168717114f6fe09934e627a00cbb097552d78639 | |
parent | 26162d64a9348890767787852561f19d904d1950 (diff) | |
download | FOSSEE-netbook-patcher-9dd0fd7ac657e7fd3b152213beac1f7d276a4b6b.tar.gz FOSSEE-netbook-patcher-9dd0fd7ac657e7fd3b152213beac1f7d276a4b6b.tar.bz2 FOSSEE-netbook-patcher-9dd0fd7ac657e7fd3b152213beac1f7d276a4b6b.zip |
added a separate init file to start fetching updates, this will help to update the main patcher.sh file before executing it
-rwxr-xr-x | init.sh | 51 | ||||
-rwxr-xr-x | patcher.sh | 17 |
2 files changed, 59 insertions, 9 deletions
@@ -0,0 +1,51 @@ +#!/bin/bash + +# For title of each Window +export supertitle="FOSSEE Netbook Updates" +source easybashgui + +# Intermediate files/directories. Will be removed after each interation +testfile=robots.txt +# Default is no internet +INET_AVAILABLE=0 +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +# Its good to have them together +generic_return_code='Working offline. Select Ok to continue.' +return_code_1="Unknown error occured. $generic_return_code" +return_code_3="File I/0 error. $generic_return_code" +return_code_4="Network failure. Unable to connect internet. $generic_return_code" +return_code_5="SSL verification failure. Check system date. $generic_return_code" +return_code_7="Protocol error. $generic_return_code" +return_code_8="Server error. $generic_return_code" + +# ===================================================================================== +# Functions in order they get called # +# ===================================================================================== + +function check_internet() { + #wait_for internet + wait_seconds 3 + for each in {google.com,github.com}; + do + wget -P $DIR $each/$testfile &> /dev/null + return_code=$? + [ $return_code -eq 0 ] && INET_AVAILABLE=1 && break + [ $return_code -eq 1 ] && alert_message -w 300 -h 100 $return_code_1 && break + [ $return_code -eq 3 ] && alert_message -w 300 -h 100 $return_code_3 && break + [ $return_code -eq 4 ] && alert_message -w 300 -h 100 $return_code_4 && break + [ $return_code -eq 5 ] && alert_message -w 300 -h 100 $return_code_5 && break + [ $return_code -eq 7 ] && alert_message -w 300 -h 100 $return_code_7 && break + done + [ $return_code -eq 8 ] && alert_message -w 300 -h 100 $return_code_8 +} + +# ====================================================================================== + +# Fetch updates if internet is available and formulate a CSV +function pull_updates() { + # If internet available just merge the changes (this won't update patches automatically) + [ $INET_AVAILABLE -eq 1 ] && cd $DIR && git tag -l | xargs git tag -d && git pull>/dev/null 2>&1 +} +check_internet +pull_updates +bash $DIR/patcher.sh @@ -24,10 +24,10 @@ source easybashgui # For global debugging(open flood gates) #set -x -# For local debugging -logfile=patcher.log +# Get the PATH of the running script DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -echo $DIR +# For local debugging +logfile=$DIR/patcher.log # Intermediate files/directories. Will be removed after each interation testfile=robots.txt files_in_all_commits=$DIR/files_in_all_commits.txt @@ -54,7 +54,6 @@ return_code_8="Server error. $generic_return_code" # ===================================================================================== function clean_up() { - wait_seconds 3 echo "=========================== New iteration =========================">>$logfile date >> $logfile [ -f $testfile ] && rm -v $testfile>>$logfile @@ -89,9 +88,9 @@ function check_internet() { # Fetch updates if internet is available and formulate a CSV function list_updates() { # If internet available just merge the changes (won't update patches automatically) - [ $INET_AVAILABLE -eq 1 ] && git tag -l | xargs git tag -d && git pull &>/dev/null + #cd $DIR && [ $INET_AVAILABLE -eq 1 ] && git tag -l | xargs git tag -d && git pull &>/dev/null # Create CSV of commits with only tags( git tags are used to group similar patches) - git log --pretty=\;\(%ar\)\;%d\;%s\;\(%h\) --no-walk --tags >\ + #cd $DIR && git log --pretty=\;\(%ar\)\;%d\;%s\;\(%h\) --no-walk --tags >\ $all_commits_one_liner_with_date # Find out files in each commit(with tag) for each in $(cat $all_commits_one_liner_with_date | cut -d ';' -f 5 | tr -d '(|)') @@ -212,8 +211,8 @@ function apply_updates() { function spl_kernel_manage() { # environment variables - kernel_image=uzImage.bin - ramdisk_image=initrd.img + kernel_image=$DIR/uzImage.bin + ramdisk_image=$DIR/initrd.img boot_part=/dev/mtd4 mkbootimg --kernel $kernel_image --ramdisk $ramdisk_image -o /tmp/boot.img @@ -230,7 +229,7 @@ function spl_kernel_manage() { function main() { #Function calls clean_up - check_internet + #check_internet list_updates check_past_updates select_updates |