-
Notifications
You must be signed in to change notification settings - Fork 2
Make scripts works as a single program and rework code #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rodrigosiqueira
wants to merge
7
commits into
padovan:master
Choose a base branch
from
rodrigosiqueira:add_install
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5eb31b3
Make vm and mk working as single program
rodrigosiqueira d7d65ad
Create unify help
rodrigosiqueira 015d45a
Add function to show current environment variable
rodrigosiqueira a0ed60a
Add routine to read local configuration
rodrigosiqueira 812a583
Add wake up vm command
rodrigosiqueira be9e9e8
Add pretty messages output
rodrigosiqueira 95b0e3f
Add simple README
rodrigosiqueira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Set required variables | ||
| EASY_KERNEL_WORKFLOW=${EASY_KERNEL_WORKFLOW:-"easy-kernel-workflow"} | ||
| src_script_path=${src_script_path:-"$HOME/.config/$EASY_KERNEL_WORKFLOW/src"} | ||
|
|
||
| set -e | ||
|
|
||
| # Load code (take care with the order) | ||
| . $src_script_path/commons --source-only | ||
| . $src_script_path/vm --source-only | ||
| . $src_script_path/mk --source-only | ||
|
|
||
| # Export external variables required by easy-kernel-workflow | ||
| export EASY_KERNEL_WORKFLOW | ||
|
|
||
| function easy-kernel-workflow() | ||
| { | ||
| if [ "$#" -eq 1 ] ; then | ||
| action=$1 | ||
| elif [ "$#" -eq 2 ] ; then | ||
| TARGET=$1 | ||
| action=$2 | ||
| fi | ||
|
|
||
| case "$action" in | ||
| mount) | ||
| vm_mount | ||
| ;; | ||
| umount) | ||
| vm_umount | ||
| ;; | ||
| boot) | ||
| vm_boot | ||
| ;; | ||
| export) | ||
| mk_export_kbuild $@ | ||
| ;; | ||
| build|b) | ||
| mk_build | ||
| ;; | ||
| install|i) | ||
| mk_install | ||
| ;; | ||
| bi) | ||
| mk_build | ||
| mk_install | ||
| ;; | ||
| mail) | ||
| mk_send_mail | ||
| ;; | ||
| help) | ||
| # TODO: Unify help | ||
| echo "--- mk ---" | ||
| mk_help | ||
| echo "--- vm ---" | ||
| vm_help | ||
| ;; | ||
| *) | ||
| mk_help | ||
| vm_help | ||
| ;; | ||
| esac | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| declare -r BLUECOLOR="\033[1;34;49m%s\033[m\n" | ||
| declare -r REDCOLOR="\033[1;31;49m%s\033[m\n" | ||
| declare -r SEPARATOR="=========================================================" | ||
| declare -r APPLICATIONNAME="easy-kernel-workflow" | ||
| declare -r APPLICATIONNAME_1="vm" | ||
| declare -r APPLICATIONNAME_2="mk" | ||
| declare -r SRCDIR="src" | ||
| declare -r INSTALLTO="$HOME/.config/$APPLICATIONNAME" | ||
|
|
||
| # Print normal message (e.g info messages). This function verifies if stdout | ||
| # is open and print it with color, otherwise print it without color. | ||
| # @param $@ it receives text message to be printed. | ||
| function say() | ||
| { | ||
| message="$@" | ||
| if [ -t 1 ]; then | ||
| printf $BLUECOLOR "$message" | ||
| else | ||
| echo "$message" | ||
| fi | ||
| } | ||
|
|
||
| # Print error message. This function verifies if stdout is open and print it | ||
| # with color, otherwise print it without color. | ||
| # @param $@ it receives text message to be printed. | ||
| function complain() | ||
| { | ||
| message="$@" | ||
| if [ -t 1 ]; then | ||
| printf $REDCOLOR "$message" | ||
| else | ||
| echo "$message" | ||
| fi | ||
| } | ||
|
|
||
| function usage() | ||
| { | ||
| say "--install | -i Install $APPLICATIONNAME" | ||
| say "--uninstall | -u Uninstall $APPLICATIONNAME" | ||
| } | ||
|
|
||
| function clean_legacy() | ||
| { | ||
| say "Removing ..." | ||
| local trash=$(mktemp -d) | ||
|
|
||
| # Remove files | ||
| if [ -d $INSTALLTO ]; then | ||
| mv $INSTALLTO $trash | ||
| fi | ||
|
|
||
| local toDelete="$APPLICATIONNAME" | ||
| eval "sed -i '/$toDelete/d' $HOME/.bashrc" | ||
| } | ||
|
|
||
| # Synchronize .vim and .vimrc with repository. | ||
| function synchronize_files() | ||
| { | ||
| say "Installing ..." | ||
|
|
||
| mkdir -p $INSTALLTO | ||
|
|
||
| # Copy the script | ||
| cp $APPLICATIONNAME.sh $INSTALLTO | ||
| rsync -vr $SRCDIR $INSTALLTO | ||
|
|
||
| # Add to bashrc | ||
| echo "# $APPLICATIONNAME" >> $HOME/.bashrc | ||
| echo "source $INSTALLTO/$APPLICATIONNAME.sh" >> $HOME/.bashrc | ||
|
|
||
| say $SEPARATOR | ||
| say "$APPLICATIONNAME installed into $INSTALLTO" | ||
| say $SEPARATOR | ||
| } | ||
|
|
||
| function install_home() | ||
| { | ||
| # First clean old installation | ||
| clean_legacy | ||
| # Synchronize of vimfiles | ||
| synchronize_files | ||
| } | ||
|
|
||
| # Options | ||
| case $1 in | ||
| --install | -i) | ||
| install_home | ||
| ;; | ||
| --uninstall | -u) | ||
| clean_legacy | ||
| ;; | ||
| *) | ||
| complain "Invalid number of arguments" | ||
| exit 1 | ||
| ;; | ||
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| BASE=$HOME/p/linux-trees | ||
| BUILD_DIR=$BASE/build-linux | ||
|
|
||
| QEMU_ARCH="x86_64" | ||
| QEMU="qemu-system-${QEMU_ARCH}" | ||
| QEMU_OPTS="-enable-kvm -smp 2 -m 1024" | ||
| VDISK="$HOME/p/virty.qcow2" | ||
| QEMU_MNT="/mnt/qemu" | ||
|
|
||
| TARGET="qemu" | ||
|
|
||
| BASHPATH=/bin/bash |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, we don't want this option here. It has to be removed because it makes hard to find errors and also it is an 'aggressive' option when used with the intention to provide user features. I just noted it recently, please, during the review comment this line. I will fix it for the next version.