Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions easy-kernel-workflow.sh
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

Copy link
Copy Markdown
Author

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.


# 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
}
138 changes: 0 additions & 138 deletions mk

This file was deleted.

100 changes: 100 additions & 0 deletions setup.sh
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
12 changes: 12 additions & 0 deletions src/commons
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
Loading