summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-05-23 03:49:11 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-05-23 03:49:11 -0400
commitf6005265512004afaf72d7e873fb6702af8a453c (patch)
treeedaf78aba840a0e5368c5efc317b842d766c8876
assorted utilities from the LITMUS project
-rwxr-xr-xbootkernel.grub58
-rwxr-xr-xfiles_added_since3
-rwxr-xr-xfiles_modified_since3
-rwxr-xr-xgsh100
-rwxr-xr-xinstall_kernel.jupiter-cs92
-rwxr-xr-xmake_release74
-rwxr-xr-xzapmod10
-rwxr-xr-xzaptrail9
8 files changed, 349 insertions, 0 deletions
diff --git a/bootkernel.grub b/bootkernel.grub
new file mode 100755
index 0000000..8256f62
--- /dev/null
+++ b/bootkernel.grub
@@ -0,0 +1,58 @@
1#!/bin/bash
2#
3# Copyright (c) 2007, Bjoern B. Brandenburg <bbb [at] cs.unc.edu>
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8# * Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution.
13# * Neither the name of the copyright holder nor the
14# names of its contributors may be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29#
30
31MENU="/boot/grub/menu.lst"
32
33
34BACK="(c) 2007 Bjoern Brandenburg"
35TITLE="GRUB Boot Kernel Selector v0.1"
36
37TMPFILE=`mktemp`
38(egrep '^title' $MENU | sed 's/title *//' | awk '
39 BEGIN {c = 0} \
40 {print c " \"" $0 "\""; c++ } \
41
42' | xargs dialog --title "$TITLE" --backtitle "$BACK" \
43--cancel-label "Keep old default" --ok-label "Select new default" \
44--menu "Choose default kernel: " 23 60 16 ) 2> $TMPFILE
45OK=$?
46
47clear
48
49if [[ $OK == 0 ]]; then
50 CHOICE=`cat $TMPFILE`
51 sed -ibak "s/^default *[0123456789]\+$/default $CHOICE/" $MENU
52 echo "New default set to ${CHOICE}."
53else
54 echo "Keeping old default kernel."
55fi
56
57rm $TMPFILE
58
diff --git a/files_added_since b/files_added_since
new file mode 100755
index 0000000..17e02fd
--- /dev/null
+++ b/files_added_since
@@ -0,0 +1,3 @@
1#!/bin/bash
2
3git diff --no-color $* | grep -A1 -e '/dev/null' | grep -v -e '/dev/null' | grep -v -e -- | sed 's|+++ b/||g'
diff --git a/files_modified_since b/files_modified_since
new file mode 100755
index 0000000..50a742f
--- /dev/null
+++ b/files_modified_since
@@ -0,0 +1,3 @@
1#!/bin/bash
2
3git diff --no-color $* | grep -A1 -e 'a/' | grep -e '+++ b/' | sed 's|+++ b/||g'
diff --git a/gsh b/gsh
new file mode 100755
index 0000000..222edee
--- /dev/null
+++ b/gsh
@@ -0,0 +1,100 @@
1#!/usr/bin/env python
2#
3# Copyright (c) 2008, Bjoern B. Brandenburg <bbb [at] cs.unc.edu>
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8# * Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution.
13# * Neither the name of the copyright holder nor the
14# names of its contributors may be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27# POSSIBILITY OF SUCH DAMAGE.
28
29import sys
30import os
31import readline
32
33HISTFILE = '.gsh_history'
34
35EGREP = 'grep'
36STD_ARGS = ['-n', '--color', '-P']
37
38VERSION = "V0.1"
39HELP = """
40Enter a regular expression to display lines that match the entered expression.
41Enter ^D or ^C at the prompt to terminate gsh. If a search produces too many
42results, then you can enter ^C to abort the search and return to the search
43prompt.
44
45For example, enter 'foo' to display lines containing the string 'foo'.
46"""
47COLS = 80
48
49class HistFile(object):
50 def __init__(self, file):
51 self.histfile = os.path.join(os.environ["HOME"], file)
52 try:
53 readline.read_history_file(self.histfile)
54 except IOError:
55 pass
56
57 def store(self):
58 try:
59 readline.write_history_file(self.histfile)
60 except IOError:
61 pass
62
63def ulc(str):
64 ul(str, (COLS - len(str)) / 2)
65
66def ul(str, offset = 0):
67 print "%s%s" % (' ' * offset, str)
68 print "%s%s" % (' ' * offset, '=' * len(str))
69
70def grep(pattern, files):
71 args = [EGREP]
72 args.append(pattern)
73 args.extend(STD_ARGS)
74 args.extend(files)
75 args.append('/dev/null')
76 return os.spawnvp(os.P_WAIT, EGREP, args)
77
78def main(args):
79 files = list(args)
80 del files[0]
81 if files == []:
82 files = ["-R", "."]
83 history = HistFile(HISTFILE)
84 try:
85 ulc("Simple Grep Shell %s" % VERSION)
86 print HELP
87 while True:
88 pattern = raw_input('>> ')
89 if pattern != '':
90 try:
91 grep(pattern, files)
92 except KeyboardInterrupt:
93 pass
94 except (EOFError, KeyboardInterrupt):
95 print 'Bye.'
96 history.store()
97
98if __name__ == '__main__':
99 main(sys.argv)
100
diff --git a/install_kernel.jupiter-cs b/install_kernel.jupiter-cs
new file mode 100755
index 0000000..720fb9c
--- /dev/null
+++ b/install_kernel.jupiter-cs
@@ -0,0 +1,92 @@
1#!/bin/bash
2
3function die()
4{
5 echo " (EE) $1"
6 exit 1
7}
8
9function info()
10{
11 echo " (II) $1"
12}
13
14function silent()
15{
16 OUTPUT=`$*`
17 if [ "$?" != "0" ]; then
18 echo $OUTPUT
19 die "$* failed!"
20 fi
21}
22
23# Function to grab var from src
24function getvar() {
25 old=$(head -5 Makefile | grep "^$1")
26 echo $(echo ${old/"$1 ="/} | sed -e "s/[ ]*\(.*\)[ ]*/\1/g")
27 return 0
28}
29
30if [ ! -f "./.config" ]; then
31 CURDIR=`pwd`
32 die "No kernel .config exists in $CURDIR!"
33fi
34
35if [ ! -f "./Makefile" ]; then
36 die "No Makefile present!"
37fi
38
39VERSION=`getvar VERSION`
40PATCHLEVEL=`getvar PATCHLEVEL`
41SUBLEVEL=`getvar SUBLEVEL`
42EXTRAVERSION=`getvar EXTRAVERSION`
43
44. ./.config
45
46NAME="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION$CONFIG_LOCALVERSION"
47
48info "Detected kernel version $NAME"
49
50if [ $UID != "0" ]; then
51 die "Must be root to install kernel!"
52fi
53
54# (1) copy modules
55if [ "$1" != "-m" ]; then
56 info "Installing modules..."
57 silent make -j8 modules_install
58else
59 info "Skipping installing modules."
60fi
61
62# (2) copy kernel
63info "Installing kernel..."
64silent cp -v arch/i386/boot/bzImage /boot/vmlinuz-$NAME
65silent cp -v System.map /boot/System.map-$NAME
66
67# (3) build ramdisk
68info "Building module dependencies"
69silent depmod -v $NAME
70
71info "Building initial ramdisk..."
72silent mkinitcpio -g /boot/kernel-$NAME.img -k $NAME
73
74# (4) make bootloader entry
75ALREADY_PRESENT=`grep "kernel /boot/vmlinuz-$NAME" /boot/grub/menu.lst `
76
77if [ ! -z "$ALREADY_PRESENT" ]; then
78 info "Bootloader entry appears to be already present."
79else
80 info "Creating bootloader entry..."
81 cat >> /boot/grub/menu.lst <<__EOE__
82
83# Custom kernel
84title Kernel $NAME
85root (hd0,5)
86kernel /boot/vmlinuz-$NAME root=/dev/sda6 ro vga=791
87initrd /boot/kernel-$NAME.img
88__EOE__
89
90fi
91
92info "Kernel $NAME has been installed."
diff --git a/make_release b/make_release
new file mode 100755
index 0000000..b5da268
--- /dev/null
+++ b/make_release
@@ -0,0 +1,74 @@
1#!/bin/bash
2
3RELEASE_DIR=/home/bbb/releases
4
5LIBLITMUS_DIR=/home/bbb/liblitmus
6LIBSO_DIR=/home/bbb/libso
7LITMUS_DIR=/home/bbb/litmus
8
9BASE_TAG="v2.6.20"
10
11TAG=$1
12
13function die {
14 echo $1
15 echo
16 echo "Usage: make_release <TAG>"
17 echo "Example: make_release 2007.3"
18 exit 1
19}
20
21if [ -z "$TAG" ]; then
22 die "TAG missing."
23fi
24
25function archive {
26 PREFIX=$1
27 TGZ=$2
28
29 TMP=`mktemp`
30 git archive --format=tar --prefix=$PREFIX/ $TAG > $TMP || \
31 die "Could not create archive from tree."
32 gzip -c $TMP > $TGZ || die "Could not compress."
33 rm $TMP
34}
35
36function release_liblitmus {
37 echo "Releasing liblitmus."
38 cd $LIBLITMUS_DIR || die "Could not cd to $LIBLITMUS_DIR."
39 archive liblitmus $TARGET/liblitmus-$TAG.tgz || die "Could not build archive."
40 return 0
41}
42
43function release_libso {
44 echo "Releasing libso."
45 cd $LIBSO_DIR || die "Could not cd to $LIBSO_DIR."
46 archive libso $TARGET/libso-$TAG.tgz || "Could not build archive."
47 return 0
48}
49
50
51function release_litmus {
52 echo "Releasing LITMUS^RT."
53 cd $LITMUS_DIR || die "Could not cd to $LITMUS_DIR."
54 git-diff -p --stat $BASE_TAG $TAG > $TARGET/litmus-rt-$TAG.patch || \
55 die "Could not create patch."
56 return 0
57}
58
59
60
61TARGET="$RELEASE_DIR/$TAG"
62
63mkdir -p $TARGET || die "Could not make directory $TARGET."
64
65
66release_litmus || die "Releasing LITMUS^RT failed."
67release_liblitmus || die "Releasing liblitmus failed."
68release_libso || die "Releasing libso failed."
69
70cd $TARGET
71echo "Generating check sums."
72sha256sum * > SHA256SUMS
73
74echo "Release generated in $TARGET."
diff --git a/zapmod b/zapmod
new file mode 100755
index 0000000..6a55bec
--- /dev/null
+++ b/zapmod
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3#CMD=/home/bbb/bin/zaptrail
4CMD=zaptrail
5
6set -e
7for f in `git diff --name-only`; do
8 echo "Zapping trailing white space in $f."
9 $CMD $f
10done
diff --git a/zaptrail b/zaptrail
new file mode 100755
index 0000000..dfe91bc
--- /dev/null
+++ b/zaptrail
@@ -0,0 +1,9 @@
1#!/bin/bash
2
3if [ "" == "$*" ]; then
4 echo "zaptrail: remove trailing white space"
5 echo "Usage: zaptrail <file1> <file2> ...."
6 exit 1
7fi
8
9sed -i -r -e 's/\s+$//' $*