summaryrefslogtreecommitdiffstats
path: root/sanity/system_light/scripts/compile_kernel
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendrabhat@gluster.com>2012-01-25 13:59:36 +0530
committerRaghavendra Bhat <raghavendrabhat@gluster.com>2012-02-06 11:09:26 +0530
commit9d36eca70a458c736e44fd8eb9184415ec45f1e6 (patch)
treef996594e813e6e4bce6fe77c31c8fe4758b2647d /sanity/system_light/scripts/compile_kernel
parent01a77a1ae18d9add01f893e06e58191b065602e8 (diff)
system_light: changes to have modularity in running tests
Till now this script allowed running all the tools (or exit for the first failure). Running individual tools was not possible. Now individual tools can be given as an argument to run. Change-Id: Ia133943667ad4dc30956f4a021f2edfc30458cee Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Diffstat (limited to 'sanity/system_light/scripts/compile_kernel')
-rwxr-xr-xsanity/system_light/scripts/compile_kernel/compile_kernel.sh15
-rwxr-xr-xsanity/system_light/scripts/compile_kernel/kernel.sh44
-rwxr-xr-xsanity/system_light/scripts/compile_kernel/kernel_compile.sh262
3 files changed, 321 insertions, 0 deletions
diff --git a/sanity/system_light/scripts/compile_kernel/compile_kernel.sh b/sanity/system_light/scripts/compile_kernel/compile_kernel.sh
new file mode 100755
index 0000000..ed153f2
--- /dev/null
+++ b/sanity/system_light/scripts/compile_kernel/compile_kernel.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+function main ()
+{
+ $TOOLDIR/kernel.sh;
+
+ if [ $? -eq 0 ]; then
+ rm -r linux-$VERSION* && echo "removed kernel";
+ return 0;
+ else
+ return 1;
+ fi
+}
+
+main "$@" \ No newline at end of file
diff --git a/sanity/system_light/scripts/compile_kernel/kernel.sh b/sanity/system_light/scripts/compile_kernel/kernel.sh
new file mode 100755
index 0000000..c6c9542
--- /dev/null
+++ b/sanity/system_light/scripts/compile_kernel/kernel.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+#This script 1st searches in the pwd for the kernel tar file. If its not there then based on the value of the vriable KERNEL_PATH it either searches from the path given or searches in http://www.kernel.org
+
+function main()
+{
+ SCRIPTS_DIR=$(dirname $0);
+ if [ -e "linux-$VERSION.tar.bz2" ]
+ then
+ echo "start:`date +%T`"
+ time $SCRIPTS_DIR/kernel_compile.sh linux-$VERSION.tar.bz2 2>>$LOG_FILE 1>>$LOG_FILE
+ if [ $? -ne 0 ]; then
+ err=$?
+ echo "end:`date +%T`"
+ return 11;
+ else
+ echo "end:`date +%T`"
+ return 0;
+ fi
+ elif [ -z "$KERNEL_PATH" ]
+ then
+ time $SCRIPTS_DIR/kernel_compile.sh 2>>$LOG_FILE 1>>$LOG_FILE
+ if [ $? -ne 0 ]; then
+ err=$?
+ echo "end:`date +%T`"
+ return 11;
+ else
+ echo "end:`date +%T`"
+ return 0;
+ fi
+ else
+ time $SCRIPTS_DIR/kernel_compile.sh $KERNEL_PATH 2>>$LOG_FILE 1>>$LOG_FILE
+ if [ $? -ne 0 ]; then
+ err=$?
+ echo "end:`date +%T`"
+ return 11;
+ else
+ echo "end:`date +%T`"
+ return 0;
+ fi
+ fi;
+}
+
+main "$@"; \ No newline at end of file
diff --git a/sanity/system_light/scripts/compile_kernel/kernel_compile.sh b/sanity/system_light/scripts/compile_kernel/kernel_compile.sh
new file mode 100755
index 0000000..646d639
--- /dev/null
+++ b/sanity/system_light/scripts/compile_kernel/kernel_compile.sh
@@ -0,0 +1,262 @@
+#! /bin/bash
+## vi: ai si et ts=4 sw=4 sts=4 bs=2 sta sr
+
+ENV_me=$(basename $0);
+ENV_medir="$(dirname $0)";
+[ "$ENV_medir" = "." ] && ENV_medir="$(pwd)";
+ENV_retval=0;
+
+ENV_short_options='cs:m:V';
+ENV_long_options='continue,site:,mainline:,verbose,quiet,help,version';
+
+ENV_timestamp_in_log=0; # 0 = Disabled, 1 = Enabled
+ENV_log="/dev/stderr";
+ENV_verbosity=2;
+ENV_debug=1;
+ENV_tmpdir=""; ## Temporary directory. Defined later
+
+ENV_version="0.0";
+ENV_copyright_years="2008";
+
+def_mainline="2.6";
+def_site="http://www.kernel.org";
+
+function print_help () {
+ cat <<-_HERE_
+Usage: $ENV_me [OPTION]... [FILE]...
+<DESCRIPTION HERE>.
+
+Mandatory arguments to long options are mandatory for short options too.
+ --help display this help and exit
+ --version output version information and exit
+_HERE_
+}
+
+function timestamp () {
+ echo "$(date +%F\ %T)";
+}
+
+function log () {
+ if [ "$ENV_timestamp_in_log" = "1" ]; then
+ echo "$ENV_me: $(timestamp): $@" | tee -a $log;
+ else
+ echo "$ENV_me: $(timestamp): $@";
+ fi
+}
+
+function debug () {
+ if [ "$ENV_debug" = 1 -o "$ENV_verbosity" = 3]; then
+ echo "$@";
+ fi
+}
+
+function error () {
+ if [ "$ENV_verbosity" -ge 1 ]; then
+ echo "$ENV_me: $@" 1>&2;
+ quit 1;
+ fi
+}
+
+function warn () {
+ if [ "$ENV_verbosity" -ge 1 ]; then
+ echo "$ENV_me: $@" 1>&2;
+ fi
+}
+
+function outn () {
+ if [ "$ENV_verbosity" -ge 2 ]; then
+ echo -n "$@";
+ fi
+}
+
+function out () {
+ if [ "$ENV_verbosity" -ge 2 ]; then
+ echo "$@";
+ fi
+}
+
+function outln () {
+ if [ "$ENV_verbosity" -ge 2 ]; then
+ echo -n "$@" | tee -a $ENV_log;
+ fi
+}
+
+function outl () {
+ if [ "$ENV_verbosity" -ge 2 ]; then
+ echo "$@" | tee -a $ENV_log;
+ fi
+}
+
+function quit () {
+ [ -d "$ENV_tmpdir" ] && rm -rf "$ENV_tmpdir";
+ exit $1;
+}
+
+function print_version () {
+ if [ "$ENV_package" != "" ]; then
+ version_str="$ENV_me ($ENV_package) $ENV_version";
+ else
+ version_str="$ENV_me $ENV_version";
+ fi
+
+ cat <<-_version_
+ $version_str
+ Copyright (C) ${ENV_copyright_years:-$(date +%Y)} Z Research, Inc.
+_version_
+}
+
+function print_usage () {
+ warn "Try \`$ENV_me --help' for more information.";
+ if [ "$1" != "0" -a "$1" != "" ]; then
+ exit "$1";
+ fi
+}
+
+function parseargs () {
+ unset ${!OPT_@};
+ ARGV=($(getopt --shell bash --name $ENV_me \
+ --option "$ENV_short_options" \
+ --longoptions "$ENV_long_options" \
+ -- "$@")) || print_usage 1;
+
+ local index=0;
+ while [ "${ARGV[$index]}" != "--" ]; do
+ local opt="$(echo ${ARGV[$index]//-/_} | sed 's/^__\?//')";
+ eval local arg=${ARGV[$index+1]}; ## eval to get rid of 's
+
+ if [[ "${ARGV[$index+1]}" =~ ^$'\''.* ]]; then # To
+## debug "Setting OPT_$opt = $arg";
+ eval OPT_${opt}=$arg;
+ index=$((index+1));
+ else
+## debug "Incrementing OPT_$opt";
+ eval OPT_$opt=$((OPT_$opt+1));
+ fi
+ index=$((index+1));
+ done
+ eval ARGV=("${ARGV[@]:$index+1}");
+}
+
+function make_tmp_dir () {
+ local dirname="$ENV_me.$RANDOM.$RANDOM.$RANDOM.$$";
+ ENV_tmpdir="$((umask 077 && \
+ mktemp -d -q ${tmpdir:-/tmp}/$dirname) 2>/dev/null)";
+ [ -z "$ENV_tmpdir" ] || [ ! -d "$ENV_tmpdir" ] && {
+ warn "Unable to create temporary directory. Exiting ..";
+ return 1;
+ }
+ return 0;
+}
+
+function get_tarball () {
+ url="$1";
+ filename=$(basename $url);
+ basedir=$(pwd);
+
+ [ -f "$filename" ] && {
+ [ "$OPT_continue" != "1" ] && error "$filename: file exists.";
+ }
+ wget -c $url;
+## out "Updating Timestamps ..";
+## $UPDATE_TIMESTAMP "$filename";
+
+ return 0;
+}
+
+
+function get_latest_tarball () {
+ basedir=$(pwd);
+ cd $ENV_tmpdir;
+
+ echo -n "Retreiving listing [ $ENV_site ] ... ";
+ wget -q "$ENV_site";
+ echo "Done";
+
+ latest=$(sed -n '/The latest stable version of the Linux kernel is/,/<\/tr>/p' index.html | \
+ sed -n 's/.*"\(.*\)">F<.*/\1/p');
+ [ "$latest" = "" ] && error "$ENV_site: No tarball found";
+
+ cd $basedir;
+ url="$ENV_site$latest";
+ get_tarball "$url";
+
+ return 0;
+}
+
+function init () {
+ parseargs "$@";
+ set -e;
+
+ [ "$OPT_help" = "1" ] && print_help && quit 0;
+ [ "$OPT_version" = "1" ] && print_version && quit 0;
+ trap 'quit 255' 1 2 3 6 13 15;
+ make_tmp_dir || quit 1;
+
+ OPT_verbosity=$((${OPT_verbose:-0} + ${OPT_v:-0}));
+
+ ENV_mainline=${OPT_mainline:-${OPT_m:-$def_mainline}};
+ ENV_site=${OPT_site:-${OPT_s:-$def_site}};
+
+ return 0;
+}
+
+function main () {
+ filename=;
+
+ if [ ${#ARGV[@]} = 0 ]; then
+ out "No input specified. Fetching latest kernel tarball ..";
+ get_latest_tarball;
+ elif [[ "${ARGV[0]}" =~ ^http|ftp ]]; then
+ out "URL detected. Fetching from URL ..";
+ get_tarball "$@";
+ elif [ -f "${ARGV[0]}" ]; then
+ filename=$(basename ${ARGV[0]});
+ if [[ ("${ARGV[0]}" =~ /) && ("${ARGV[0]::2}" != "./") ]]; then
+ out "File detected. Copying from location ..";
+ cp "${ARGV[0]}" .;
+ fi
+ else
+ error "${ARGV[0]}: Unknown input method";
+ fi
+
+ out "Extracting Tarball ..";
+ tar -jxf $filename;
+ cd ${filename%.tar.bz2};
+ find . -exec touch '{}' \;
+ out "Making defconfig";
+ make defconfig;
+ if [ $? -ne 0 ]; then
+ err=$?
+ echo "Make defconfig failed"
+ return $err
+ fi
+ echo "its not coming here"
+ out "Making depmod ..";
+ #make depmod;
+ make dep;
+ if [ $? -ne 0 ]; then
+ err=$?
+ echo "Make dep failed"
+ return $err
+ fi
+ out "Making bzImage ..";
+ make bzImage;
+ if [ $? -ne 0 ]; then
+ err=$?
+ echo "Make bzImage failed"
+ return $err
+ fi
+ out "Making modules ..";
+ make modules;
+ if [ $? -ne 0 ]; then
+ err=$?
+ echo "Make modules failed"
+ return $err
+ fi
+ quit 0;
+}
+
+init "$@" && main "$@";
+#quit $ENV_retval;
+
+