From f7c31a5a862060af3d0b76a25b42f4eb00a8bd25 Mon Sep 17 00:00:00 2001 From: Srikant Patnaik Date: Sun, 22 Feb 2015 10:12:36 +0530 Subject: moved and renamed --- README.rst | 25 ---- fossee-update.desktop | 11 -- init.sh | 51 ------- opt/noNoise-master/README.rst | 160 --------------------- opt/noNoise-master/noNoise.py | 113 --------------- opt/noNoise-master/noNoise.sh | 32 ----- opt/noNoise-master/nonoise.desktop | 10 -- patcher.png | Bin 4126 -> 0 bytes patcher.sh | 248 --------------------------------- update-tool/README.rst | 25 ++++ update-tool/fossee-update.desktop | 11 ++ update-tool/init.sh | 51 +++++++ update-tool/patcher.png | Bin 0 -> 4126 bytes update-tool/patcher.sh | 248 +++++++++++++++++++++++++++++++++ usr/share/applications/nonoise.desktop | 10 -- 15 files changed, 335 insertions(+), 660 deletions(-) delete mode 100644 README.rst delete mode 100644 fossee-update.desktop delete mode 100755 init.sh delete mode 100644 opt/noNoise-master/README.rst delete mode 100644 opt/noNoise-master/noNoise.py delete mode 100755 opt/noNoise-master/noNoise.sh delete mode 100644 opt/noNoise-master/nonoise.desktop delete mode 100644 patcher.png delete mode 100755 patcher.sh create mode 100644 update-tool/README.rst create mode 100644 update-tool/fossee-update.desktop create mode 100755 update-tool/init.sh create mode 100644 update-tool/patcher.png create mode 100755 update-tool/patcher.sh delete mode 100644 usr/share/applications/nonoise.desktop diff --git a/README.rst b/README.rst deleted file mode 100644 index 6ae75a9..0000000 --- a/README.rst +++ /dev/null @@ -1,25 +0,0 @@ -README -====== - -A simple git based application to manage distribution specific patches for -FOSSEE-netbook. - -What it can do --------------- - -* A simple graphical & CLI tool to select and apply available patches - -* It can change Kernel, firmware and modules too - -Proposed features(TODO) ------------------------ - -* A xml/csv file with precise instructions to compile/install any packages - - -Limitations ------------ - -* Only one patch at a time - -* Removing a patch is not implemented, one has to revert to a known version manually diff --git a/fossee-update.desktop b/fossee-update.desktop deleted file mode 100644 index c5f1ed1..0000000 --- a/fossee-update.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Keywords=FOSSEE updates -Name=FOSSEE-updates -Comment=FOSSEE updates -Exec=bash /opt/FOSSEE-netbook-patcher/init.sh -#Exec=lxterminal --working-directory=/opt/FOSSEE-netbook-patcher -e /opt/FOSSEE-netbook-patcher/patcher.sh >/dev/null 2>&1 -Icon=/opt/FOSSEE-netbook-patcher/patcher.png -Terminal=false -Type=Application -MimeType=text/plain -Categories=GTK;Other; diff --git a/init.sh b/init.sh deleted file mode 100755 index b5b148f..0000000 --- a/init.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/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 diff --git a/opt/noNoise-master/README.rst b/opt/noNoise-master/README.rst deleted file mode 100644 index 0efdbd4..0000000 --- a/opt/noNoise-master/README.rst +++ /dev/null @@ -1,160 +0,0 @@ -Introduction -============ - -With home made videos or screencasts, we often find a constant noise in our recording due to electric wiring, fan, choke coil of fluorescent -lamp etc. This could be irritating.But fortunately, these noises can be easily detected and can be removed with GUI based tools, such as -Audacity. -To use any GUI based tool, we need to extract audio manually and then feed it to the software, once done we have to again join the noisefree -audio with the video. This is OK with 1 or 2 files. But to for automating each step and to handle multiple files we need a simple script. - -One can simply use `sox` and `ffmpeg` commands shown below in given order to get the same result(see `Working`). - - -UPDATE for 14.04 ----------------- - -Install **libav-tools** and **sox**. - -Run as :: - - $ bash noNoise.sh noisyVideo.mp4 noise-reduction-factor - -This will create an backup file of original video in **/tmp** -and noisefreeVideo in **pwd**. - -Example :: - - $ bash noNoise.sh Kazam_screencast_00000.mp4 0.2 - -It will create **noisefree_Kazam_screencast_00000.mp4.mp4** in **pwd** -and a backup of original video in **/tmp/orig_Kazam_screencast_00000.mp4** - -This is just an early fix, will add more features soon. - -Please raise issues for any bugs or email me for feature requests. - -Also, I recently came across **Kazam** package (available in repositories), -its a good screen recorder with most needed keyboard shortcuts, such as - -* start recording: Super + Control + r -* pause recording: Super + Control + p -* finish recording: Super + Control + f -* show Kazam: Super + Control + s -* quit: Super + Control + q - -Required packages (Upto Ubuntu 13.10) -------------------------------------- - - * sox - - * ffmpeg - - * ffmpeg2theora - - * libmp3lame0 - - * Linux machine with default python - - - -Usage ------ - -### Remove noise from a single file - - - $ python noNoise.py VideoWithNoise.ogv CleanVideo.ogv - (source file) (destination file) - -(OR) - - $ python noNoise.py VideoWithNoise.ogv CleanVideo.ogv 0.21 - (source file) (destination file) (noise factor) - - The third argument is optional(Noise factor). The scale spans from - `0.0` to `1.0`. Zero means no noise supression and 1.0 means full. The full - scale is avoided. Best optimum result is found between `0.2` to `0.3`. By default - script will take `0.26`. One can experiment with noise factor to get best noise - free video. - NOTE: Careful, destination file will be overwritten if exist in given path. - - - -### Remove noise from all files inside a directory - - - $ python noNoise.py allNoisyFiles allCleanFiles - (source dir) (destination dir) - -(OR) - - $ python noNoise.py allNoisyFiles allCleanFiles 0.21 - (source Dir) (destination dir) (Noise factor) - -NOTE: Please don't use any '/' after directory name. It will spit error. -The fix is possible, but I don't want to spend time on it. This script is dirty -but useful(atleast for me). When I find time, I will surely modify it. Meanwhile -you all are welcome to add modifications. - - - -Working: -------- -###1. Extracting video in less compressed format - - ffmpeg -i 1.ogv -sameq -an 2.wmv - - Extracting video in wmv format for easy editing(less compressed - than mp4,ogv,avi). We can leave the video intact and combine the - noiseless audio later to it, but it will hamper the video quality - of the newly joined video. - The size of this 'wmv' will be approximately 5 times than that of - original 'ogv' video. - - -###2. Extracting audio in less compressed format - - ffmpeg -i 1.ogv -sameq 2.wav - - Extracting audio in wav format for fast & easy editing.The size of the - `wav` audio file will be approximately 8 times larger than the original. - - -###3. Getting noise profile - - sox 2.wav -t null /dev/null trim 0 0.5 noiseprof myprofile - - Creating a noise profile of original audio at 0 to 0.5 second. - One can change this duration if required. In most cases the - standard noise is evenly distributed throughout the recording(eg: - fan, PC etc), so the default 0 to 0.5 value will do the trick. - -###4. Converting audio according to noise profile - - sox 2.wav 2-noisefree.wav noisered myprofile 0.26 - - Creating a noisefree audio based on our noise profile. The value - `0.26` is important. This is scale for noise removal. 0 means no removal - and 1 means full removal. The full removal will supress most of the - orginal audio too. So as per my R&D, I found `0.26` to be most optimized - one for noise removal. - - -###5. Combining back audio and video - - ffmpeg -i 2-noisefree.wav -i 2.wmv -sameq vid.wmv - - Merging new noiseless audio and old video together. - - -###6. Final conversion - - ffmpeg2theora vid.wmv -o vid.ogv - - Now converting wmv into our favorite ogv format. This will create a - `vid.ogv` of almost same size that of original video. - - -License -------- -GNU GPLV3 diff --git a/opt/noNoise-master/noNoise.py b/opt/noNoise-master/noNoise.py deleted file mode 100644 index cfff188..0000000 --- a/opt/noNoise-master/noNoise.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/python env - -"""This script can be used to remove audio noise from 'ogv' videos. - - Usage:(for future Srikant & all users) - - 1)Remove noise from a single file: - ---------------------------------- - $ python noNoise.py VideoWithNoise.ogv CleanVideo.ogv - (source file) (destination file) - - (OR) - - $ python noNoise.py VideoWithNoise.ogv CleanVideo.ogv 0.21 - (source file) (destination file) (noise factor) - - The third argument is optional(Noise factor). The scale spans from - 0.0 to 1.0. Zero means no noise supression and 1.0 means full. The full - scale is avoided. Best optimum result is found between 0.2 to 0.3. By default - script will take 0.26. One can experiment with noise factor to get best noise - free video. - NOTE: Careful, destination file will be overwritten if exist in given path. - - - - 2)Remove noise from all files inside a directory: - ------------------------------------------------- - $ python noNoise.py allNoisyFiles allCleanFiles - (source dir) (destination dir) - - (OR) - - $ python noNoise.py allNoisyFiles allCleanFiles 0.21 - (source Dir) (destination dir) (Noise factor) - - - NOTE: Please don't use any '/' after directory name. It will spit error. - The fix is possible, but I don't want to spend time on it. This script is dirty - but useful(atleast for me). When I find time, I will surely modify it. Meanwhile - you all are welcome to add modifications. Please find this copy and future updates - at http://github.com/srikantpatnaik. - Thanks for your time. - - Details of each commands are in README.rst. - -""" - -from os import system, path, listdir, chdir, mkdir -from sys import argv -from time import sleep - -def checkType(): - #Check for type of first argument(file or dir). - if path.isdir(argv[1]): - processDir() - else: - processFile() - return - - -def processDir(): - #make dir to save all new files - mkdir(argv[2]) - #cd to source dir - chdir(argv[1]) - for eachfile in listdir('.'): - execute(setCommands(eachfile)) - return - - -def processFile(): - #Calling setCommands with source file. - #Will return list of commands to be executed - execute(setCommands(argv[1])) - return - - -def execute(cli): - #total 7 commands with some delay for disk - #write and sync - for each in cli: - system(each) - sleep(0.2) - return - - -def setCommands(filename): - #The dirty function. - cli = [None]*7 - cli[0] = 'ffmpeg -i ' + ' ' + filename + ' -sameq -an ' + '.rawVideo.wmv' - cli[1] = 'ffmpeg -i ' + ' ' + filename + ' -sameq ' + '.rawAudio.wav' - cli[2] = 'sox .rawAudio.wav -t null /dev/null trim 0 0.5 noiseprof myprofile' - #Checks for noise factor. - if len(argv)>3: - cli[3] = 'sox .rawAudio.wav .noisefree.wav noisered myprofile ' + argv[3] - else: - #The default value for noise factor is 0.26. Change accordingly. - cli[3] = 'sox .rawAudio.wav .noisefree.wav noisered myprofile 0.26' - #Creating a less compressed file to retain video quality. - cli[4] = 'ffmpeg -i .noisefree.wav -i .rawVideo.wmv -sameq .combined.wmv' - #Checks for file or directory. If dir, the output is saved in different directory. - if not path.isfile(argv[1]): - cli[5] = 'ffmpeg2theora .combined.wmv -o ' + '../' + argv[2] + '/' + filename - else: - #Will create the final ogv video from wmv. - cli[5] = 'ffmpeg2theora .combined.wmv -o ' + argv[2] - cli[6] = 'rm .rawVideo.wmv .rawAudio.wav .noisefree.wav .combined.wmv myprofile' - return cli - - - -if __name__ == '__main__': - checkType() diff --git a/opt/noNoise-master/noNoise.sh b/opt/noNoise-master/noNoise.sh deleted file mode 100755 index f247568..0000000 --- a/opt/noNoise-master/noNoise.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Please install 'libav-tools' for Ubuntu 14.04 onwards -# As ffmpeg is obsolete, it has been replaced by 'avconv' -# Instead of python script, a simple bash one is sufficient - -# A beta release for noNoise-v2 - -# Usage example -# $ bash noNoise.sh noisyVideo.mp4 noise-reduction-factor - -# noise-reduction-factor: 0 means no reduction, 1 means -# maximum damping of noise (recommended is 0.2 to 0.4) - - - -# Making a backup of the original video -echo "Back up original video at /tmp/orig_$1" -cp -v $1 /tmp/orig_$1 - -# Extracting audio from noisyVideo -avconv -i $1 -f wav -ab 192000 -vn /tmp/noisy.wav - -# Creating a noise profile, basically looking for white noise -# in 0 to 0.5 sec of the clip (change if you like) -sox /tmp/noisy.wav -n trim 0 0.5 noiseprof myprofile - -# Removing noise using noise profile -sox /tmp/noisy.wav /tmp/noisefree.wav noisered myprofile $2 - -# Replacing noisyAudio with noisefree audio in original video -avconv -i $1 -i /tmp/noisefree.wav -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 noisefree_$1.mp4 diff --git a/opt/noNoise-master/nonoise.desktop b/opt/noNoise-master/nonoise.desktop deleted file mode 100644 index 676111e..0000000 --- a/opt/noNoise-master/nonoise.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Keywords=FOSSEE updates -Name=FOSSEE-updates -Comment=FOSSEE updates -Exec=bash /opt/noNoise-master/noNoise.sh -#Icon=/opt/FOSSEE-netbook-patcher/patcher.png -Terminal=false -Type=Application -MimeType=text/plain -Categories=GTK;Other; diff --git a/patcher.png b/patcher.png deleted file mode 100644 index 19e30ff..0000000 Binary files a/patcher.png and /dev/null differ diff --git a/patcher.sh b/patcher.sh deleted file mode 100755 index 88c52fe..0000000 --- a/patcher.sh +++ /dev/null @@ -1,248 +0,0 @@ -#!/bin/bash - -# 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 3 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, see . -# This program is intended to write/copy images to any media or drive. - -# This script depends on 'easybashgui'. -# The password function has extra dependency on 'zenity' & 'dialog' -# programs, which can be modified to work with other libraries too - - -# For title of each Window -export supertitle="FOSSEE Netbook Updates" -source easybashgui - -# For global debugging(open flood gates) -#set -x - -# Get the PATH of the running script -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -# 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 -all_commits_one_liner_with_date=$DIR/all_commits_one_liner_with_date.txt -all_commits_dates_with_file_paths=$DIR/all_commits_dates_with_file_paths.txt -past_applied_commits=$DIR/past_applied_commits.txt -local_updates=$DIR/local_updates -unique_tags=$DIR/unique_tags - [ ! -d $unique_tags ] && mkdir -p $unique_tags -# Default is no internet -INET_AVAILABLE=0 - -# 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 clean_up() { - echo "=========================== New iteration =========================">>$logfile - date >> $logfile - [ -f $testfile ] && rm -v $testfile>>$logfile - [ -f $files_in_all_commits ] && rm -v $files_in_all_commits>>$logfile - [ -f $all_commits_one_liner_with_date ] && rm -v $all_commits_one_liner_with_date>>$logfile - [ -f $all_commits_dates_with_file_paths ] && rm -v $all_commits_dates_with_file_paths>>$logfile - [ -f $past_applied_commits ] && rm -v $past_applied_commits>>$logfile - [ -d $local_updates ] && rm -rvf $local_updates/>>$logfile - -} - -# ====================================================================================== - -function check_internet() { - #wait_for internet - for each in {fossee.in,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 list_updates() { - # If internet available just merge the changes (won't update patches automatically) - #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) - 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 '(|)') - do - files_in_each_commit=$(cd $DIR && git show --first-parent --pretty="format:" --name-only $each) - echo $files_in_each_commit | tr ' ' ',' >> $files_in_all_commits - done - # Create a file with [Not Updated] flag on the first column for all the tags, we will - # selectively change it to [Updated] based on previously applied patches(git tags) - paste -d ';' $all_commits_one_liner_with_date \ - $files_in_all_commits | \ - awk 'BEGIN{FS=";";OFS=";"} {$1="[Not Updated]"} 1' > \ - $all_commits_dates_with_file_paths -} - -# ====================================================================================== - -function check_past_updates() { - # If no new/old update available, just quit (Ignoring HEAD based tags to avoid confusion) - no_updates=$(cat $all_commits_dates_with_file_paths | sed '/HEAD/d' | wc -c) - [ $no_updates -eq 0 ] && alert_message -w 400 -h 250 "No updates available !!!" && exit 0 - # Look for previously applied updates(git tags) - for hash in $(cat unique_tags/*); - do - line=$(grep -on $hash $all_commits_dates_with_file_paths | cut -d ':' -f 1);\ - sed -i $line's/\[Not\ Updated\]/\[Updated\]/g' $all_commits_dates_with_file_paths; - done -} - - -# ====================================================================================== - -function select_updates() { - # Show updates using 'menu' of 'easybashgui' - selected_update=$(menu -w 900 -h 550 "$(cat $all_commits_dates_with_file_paths | sed '/HEAD/d' | \ - cut -d ';' -f 1,2,3,4,5| tr ';' ' ' )" 2>&1) - [ $? -eq 1 ] && exit 0 - #get hash for selected_update - selected_hash=$(echo $selected_update | grep -o \([0-9a-z]*\) | tr -d '(|)') - selected_tag=$(echo $selected_update | grep -o \(tag:\ [A-Za-z0-9._-]*\) | sed 's/(tag:\ //' |sed 's/)//') -} - - -# ====================================================================================== - -function generate_commit_files() { - # At a time only one version from similar group of tags will be applied, for eg: AudioMic-1 and - # AudioMic-2 (tags) can't be applied simultaneously as they might point to same file - find $unique_tags -iname $(echo $selected_tag | cut -d '-' -f 1)\* | grep '' && [ $? -eq 0 ] && \ - rm $(find $unique_tags -iname $(echo $selected_tag | cut -d '-' -f 1)\*) - # This will help identifying the unique tags among group of tags(commits/patches) - echo $selected_hash > $unique_tags/$selected_tag - # This for loop creates a copy of file(s) from given tag/commit - files_in_selected_hash=$(grep $selected_hash $all_commits_dates_with_file_paths | cut -d ';' -f6) - # For more than one file in a commit - for each_file in $(echo $files_in_selected_hash|tr ',' '\n'); - do - mkdir -pv $local_updates/$(dirname $each_file)>>$logfile - cd $DIR && git show $selected_hash:$each_file>$local_updates/$each_file - #echo "$selected_hash,$selected_tag">>$logfile - done -} - -# ====================================================================================== - -function sudo_access() { -# Clear remember password -sudo -K -# The only place 'easybashgui' fails. So adding separate functions for both tty(consoles) -# and pts(terminals). If tty not found, it returns 1, and 'zenity' is used - -if [ ! -z $(pidof X) ] ; then - -while true - do - password=$(zenity --title "FOSSEE Netbook Updates" --password) - # zenity dialog button 'Cancel' returns 1, and 'Yes' returns 0. - [ $? -eq 1 ] && exit 0 - echo $password | sudo -S echo "test">/dev/null - # If wrong password then brek - [ $? -eq 0 ] && break - done -else - -while true - do - password=$(dialog --title "FOSSEE Netbook Updates" \ - --clear \ - --passwordbox "Enter your password" 10 30 \ - --stdout) - [ $? -eq 1 ] && exit 0 - echo $password | sudo -S echo "test">/dev/null - # If wrong password then brek - [ $? -eq 0 ] && break - done -fi -} - -# ====================================================================================== - -function apply_updates() { - question -w 400 -h 150 "Do you want to apply the selected update?\\nThis may install/update the following file(s): '/$files_in_selected_hash'" 2>&1 - [ $? -eq 1 ] && exit 0 - for each_file in $(echo $files_in_selected_hash | tr ',' '\n'); - do - echo "##### applying updates #####">>$logfile - [ -d /$(dirname each_file) ] && sudo mkdir -pv $(dirname /$each_file)>>$logfile; - sudo mv -v $local_updates/$each_file /$each_file>>$logfile - done - question -w 400 -h 150 "Successfully Updated!\\n\\nSelect 'Yes' to close this application. Select 'Cancel' to relaunch update selection menu" - [ $? -eq 0 ] && exit 0 - main -} - - -# ====================================================================================== - -function spl_kernel_manage() { - - # environment variables - 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 - sync - echo 0 > /sys/module/yaffs/parameters/yaffs_bg_enable - flash_erase $boot_part 0 0 - nandwrite -p $boot_part /tmp/boot.img - sync - echo 1 > /sys/module/yaffs/parameters/yaffs_bg_enable -} - -# ====================================================================================== - -function main() { -#Function calls - clean_up - # Next function is handled by init.sh script in same directory - #check_internet - list_updates - check_past_updates - select_updates - generate_commit_files - sudo_access - apply_updates - # Comment next function if you are not using FOSSEE netbook - #spl_kernel_manage -} - - -# ====================================================================================== - -# __init__ -main diff --git a/update-tool/README.rst b/update-tool/README.rst new file mode 100644 index 0000000..6ae75a9 --- /dev/null +++ b/update-tool/README.rst @@ -0,0 +1,25 @@ +README +====== + +A simple git based application to manage distribution specific patches for +FOSSEE-netbook. + +What it can do +-------------- + +* A simple graphical & CLI tool to select and apply available patches + +* It can change Kernel, firmware and modules too + +Proposed features(TODO) +----------------------- + +* A xml/csv file with precise instructions to compile/install any packages + + +Limitations +----------- + +* Only one patch at a time + +* Removing a patch is not implemented, one has to revert to a known version manually diff --git a/update-tool/fossee-update.desktop b/update-tool/fossee-update.desktop new file mode 100644 index 0000000..3025959 --- /dev/null +++ b/update-tool/fossee-update.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Keywords=FOSSEE updates +Name=FOSSEE-updates +Comment=FOSSEE updates +Exec=bash /opt/FOSSEE-netbook-tools/update-tool/init.sh +#Exec=lxterminal --working-directory=/opt/FOSSEE-netbook-patcher -e /opt/FOSSEE-netbook-patcher/patcher.sh >/dev/null 2>&1 +Icon=/opt/FOSSEE-netbook-tools/update-tool/patcher.png +Terminal=false +Type=Application +MimeType=text/plain +Categories=GTK;Other; diff --git a/update-tool/init.sh b/update-tool/init.sh new file mode 100755 index 0000000..b5b148f --- /dev/null +++ b/update-tool/init.sh @@ -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 diff --git a/update-tool/patcher.png b/update-tool/patcher.png new file mode 100644 index 0000000..19e30ff Binary files /dev/null and b/update-tool/patcher.png differ diff --git a/update-tool/patcher.sh b/update-tool/patcher.sh new file mode 100755 index 0000000..88c52fe --- /dev/null +++ b/update-tool/patcher.sh @@ -0,0 +1,248 @@ +#!/bin/bash + +# 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 3 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, see . +# This program is intended to write/copy images to any media or drive. + +# This script depends on 'easybashgui'. +# The password function has extra dependency on 'zenity' & 'dialog' +# programs, which can be modified to work with other libraries too + + +# For title of each Window +export supertitle="FOSSEE Netbook Updates" +source easybashgui + +# For global debugging(open flood gates) +#set -x + +# Get the PATH of the running script +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +# 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 +all_commits_one_liner_with_date=$DIR/all_commits_one_liner_with_date.txt +all_commits_dates_with_file_paths=$DIR/all_commits_dates_with_file_paths.txt +past_applied_commits=$DIR/past_applied_commits.txt +local_updates=$DIR/local_updates +unique_tags=$DIR/unique_tags + [ ! -d $unique_tags ] && mkdir -p $unique_tags +# Default is no internet +INET_AVAILABLE=0 + +# 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 clean_up() { + echo "=========================== New iteration =========================">>$logfile + date >> $logfile + [ -f $testfile ] && rm -v $testfile>>$logfile + [ -f $files_in_all_commits ] && rm -v $files_in_all_commits>>$logfile + [ -f $all_commits_one_liner_with_date ] && rm -v $all_commits_one_liner_with_date>>$logfile + [ -f $all_commits_dates_with_file_paths ] && rm -v $all_commits_dates_with_file_paths>>$logfile + [ -f $past_applied_commits ] && rm -v $past_applied_commits>>$logfile + [ -d $local_updates ] && rm -rvf $local_updates/>>$logfile + +} + +# ====================================================================================== + +function check_internet() { + #wait_for internet + for each in {fossee.in,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 list_updates() { + # If internet available just merge the changes (won't update patches automatically) + #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) + 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 '(|)') + do + files_in_each_commit=$(cd $DIR && git show --first-parent --pretty="format:" --name-only $each) + echo $files_in_each_commit | tr ' ' ',' >> $files_in_all_commits + done + # Create a file with [Not Updated] flag on the first column for all the tags, we will + # selectively change it to [Updated] based on previously applied patches(git tags) + paste -d ';' $all_commits_one_liner_with_date \ + $files_in_all_commits | \ + awk 'BEGIN{FS=";";OFS=";"} {$1="[Not Updated]"} 1' > \ + $all_commits_dates_with_file_paths +} + +# ====================================================================================== + +function check_past_updates() { + # If no new/old update available, just quit (Ignoring HEAD based tags to avoid confusion) + no_updates=$(cat $all_commits_dates_with_file_paths | sed '/HEAD/d' | wc -c) + [ $no_updates -eq 0 ] && alert_message -w 400 -h 250 "No updates available !!!" && exit 0 + # Look for previously applied updates(git tags) + for hash in $(cat unique_tags/*); + do + line=$(grep -on $hash $all_commits_dates_with_file_paths | cut -d ':' -f 1);\ + sed -i $line's/\[Not\ Updated\]/\[Updated\]/g' $all_commits_dates_with_file_paths; + done +} + + +# ====================================================================================== + +function select_updates() { + # Show updates using 'menu' of 'easybashgui' + selected_update=$(menu -w 900 -h 550 "$(cat $all_commits_dates_with_file_paths | sed '/HEAD/d' | \ + cut -d ';' -f 1,2,3,4,5| tr ';' ' ' )" 2>&1) + [ $? -eq 1 ] && exit 0 + #get hash for selected_update + selected_hash=$(echo $selected_update | grep -o \([0-9a-z]*\) | tr -d '(|)') + selected_tag=$(echo $selected_update | grep -o \(tag:\ [A-Za-z0-9._-]*\) | sed 's/(tag:\ //' |sed 's/)//') +} + + +# ====================================================================================== + +function generate_commit_files() { + # At a time only one version from similar group of tags will be applied, for eg: AudioMic-1 and + # AudioMic-2 (tags) can't be applied simultaneously as they might point to same file + find $unique_tags -iname $(echo $selected_tag | cut -d '-' -f 1)\* | grep '' && [ $? -eq 0 ] && \ + rm $(find $unique_tags -iname $(echo $selected_tag | cut -d '-' -f 1)\*) + # This will help identifying the unique tags among group of tags(commits/patches) + echo $selected_hash > $unique_tags/$selected_tag + # This for loop creates a copy of file(s) from given tag/commit + files_in_selected_hash=$(grep $selected_hash $all_commits_dates_with_file_paths | cut -d ';' -f6) + # For more than one file in a commit + for each_file in $(echo $files_in_selected_hash|tr ',' '\n'); + do + mkdir -pv $local_updates/$(dirname $each_file)>>$logfile + cd $DIR && git show $selected_hash:$each_file>$local_updates/$each_file + #echo "$selected_hash,$selected_tag">>$logfile + done +} + +# ====================================================================================== + +function sudo_access() { +# Clear remember password +sudo -K +# The only place 'easybashgui' fails. So adding separate functions for both tty(consoles) +# and pts(terminals). If tty not found, it returns 1, and 'zenity' is used + +if [ ! -z $(pidof X) ] ; then + +while true + do + password=$(zenity --title "FOSSEE Netbook Updates" --password) + # zenity dialog button 'Cancel' returns 1, and 'Yes' returns 0. + [ $? -eq 1 ] && exit 0 + echo $password | sudo -S echo "test">/dev/null + # If wrong password then brek + [ $? -eq 0 ] && break + done +else + +while true + do + password=$(dialog --title "FOSSEE Netbook Updates" \ + --clear \ + --passwordbox "Enter your password" 10 30 \ + --stdout) + [ $? -eq 1 ] && exit 0 + echo $password | sudo -S echo "test">/dev/null + # If wrong password then brek + [ $? -eq 0 ] && break + done +fi +} + +# ====================================================================================== + +function apply_updates() { + question -w 400 -h 150 "Do you want to apply the selected update?\\nThis may install/update the following file(s): '/$files_in_selected_hash'" 2>&1 + [ $? -eq 1 ] && exit 0 + for each_file in $(echo $files_in_selected_hash | tr ',' '\n'); + do + echo "##### applying updates #####">>$logfile + [ -d /$(dirname each_file) ] && sudo mkdir -pv $(dirname /$each_file)>>$logfile; + sudo mv -v $local_updates/$each_file /$each_file>>$logfile + done + question -w 400 -h 150 "Successfully Updated!\\n\\nSelect 'Yes' to close this application. Select 'Cancel' to relaunch update selection menu" + [ $? -eq 0 ] && exit 0 + main +} + + +# ====================================================================================== + +function spl_kernel_manage() { + + # environment variables + 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 + sync + echo 0 > /sys/module/yaffs/parameters/yaffs_bg_enable + flash_erase $boot_part 0 0 + nandwrite -p $boot_part /tmp/boot.img + sync + echo 1 > /sys/module/yaffs/parameters/yaffs_bg_enable +} + +# ====================================================================================== + +function main() { +#Function calls + clean_up + # Next function is handled by init.sh script in same directory + #check_internet + list_updates + check_past_updates + select_updates + generate_commit_files + sudo_access + apply_updates + # Comment next function if you are not using FOSSEE netbook + #spl_kernel_manage +} + + +# ====================================================================================== + +# __init__ +main diff --git a/usr/share/applications/nonoise.desktop b/usr/share/applications/nonoise.desktop deleted file mode 100644 index 676111e..0000000 --- a/usr/share/applications/nonoise.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Keywords=FOSSEE updates -Name=FOSSEE-updates -Comment=FOSSEE updates -Exec=bash /opt/noNoise-master/noNoise.sh -#Icon=/opt/FOSSEE-netbook-patcher/patcher.png -Terminal=false -Type=Application -MimeType=text/plain -Categories=GTK;Other; -- cgit