diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-23 03:49:11 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-23 03:49:11 -0400 |
commit | f6005265512004afaf72d7e873fb6702af8a453c (patch) | |
tree | edaf78aba840a0e5368c5efc317b842d766c8876 |
assorted utilities from the LITMUS project
-rwxr-xr-x | bootkernel.grub | 58 | ||||
-rwxr-xr-x | files_added_since | 3 | ||||
-rwxr-xr-x | files_modified_since | 3 | ||||
-rwxr-xr-x | gsh | 100 | ||||
-rwxr-xr-x | install_kernel.jupiter-cs | 92 | ||||
-rwxr-xr-x | make_release | 74 | ||||
-rwxr-xr-x | zapmod | 10 | ||||
-rwxr-xr-x | zaptrail | 9 |
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 | |||
31 | MENU="/boot/grub/menu.lst" | ||
32 | |||
33 | |||
34 | BACK="(c) 2007 Bjoern Brandenburg" | ||
35 | TITLE="GRUB Boot Kernel Selector v0.1" | ||
36 | |||
37 | TMPFILE=`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 | ||
45 | OK=$? | ||
46 | |||
47 | clear | ||
48 | |||
49 | if [[ $OK == 0 ]]; then | ||
50 | CHOICE=`cat $TMPFILE` | ||
51 | sed -ibak "s/^default *[0123456789]\+$/default $CHOICE/" $MENU | ||
52 | echo "New default set to ${CHOICE}." | ||
53 | else | ||
54 | echo "Keeping old default kernel." | ||
55 | fi | ||
56 | |||
57 | rm $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 | |||
3 | git 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 | |||
3 | git diff --no-color $* | grep -A1 -e 'a/' | grep -e '+++ b/' | sed 's|+++ b/||g' | ||
@@ -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 | |||
29 | import sys | ||
30 | import os | ||
31 | import readline | ||
32 | |||
33 | HISTFILE = '.gsh_history' | ||
34 | |||
35 | EGREP = 'grep' | ||
36 | STD_ARGS = ['-n', '--color', '-P'] | ||
37 | |||
38 | VERSION = "V0.1" | ||
39 | HELP = """ | ||
40 | Enter a regular expression to display lines that match the entered expression. | ||
41 | Enter ^D or ^C at the prompt to terminate gsh. If a search produces too many | ||
42 | results, then you can enter ^C to abort the search and return to the search | ||
43 | prompt. | ||
44 | |||
45 | For example, enter 'foo' to display lines containing the string 'foo'. | ||
46 | """ | ||
47 | COLS = 80 | ||
48 | |||
49 | class 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 | |||
63 | def ulc(str): | ||
64 | ul(str, (COLS - len(str)) / 2) | ||
65 | |||
66 | def ul(str, offset = 0): | ||
67 | print "%s%s" % (' ' * offset, str) | ||
68 | print "%s%s" % (' ' * offset, '=' * len(str)) | ||
69 | |||
70 | def 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 | |||
78 | def 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 | |||
98 | if __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 | |||
3 | function die() | ||
4 | { | ||
5 | echo " (EE) $1" | ||
6 | exit 1 | ||
7 | } | ||
8 | |||
9 | function info() | ||
10 | { | ||
11 | echo " (II) $1" | ||
12 | } | ||
13 | |||
14 | function 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 | ||
24 | function getvar() { | ||
25 | old=$(head -5 Makefile | grep "^$1") | ||
26 | echo $(echo ${old/"$1 ="/} | sed -e "s/[ ]*\(.*\)[ ]*/\1/g") | ||
27 | return 0 | ||
28 | } | ||
29 | |||
30 | if [ ! -f "./.config" ]; then | ||
31 | CURDIR=`pwd` | ||
32 | die "No kernel .config exists in $CURDIR!" | ||
33 | fi | ||
34 | |||
35 | if [ ! -f "./Makefile" ]; then | ||
36 | die "No Makefile present!" | ||
37 | fi | ||
38 | |||
39 | VERSION=`getvar VERSION` | ||
40 | PATCHLEVEL=`getvar PATCHLEVEL` | ||
41 | SUBLEVEL=`getvar SUBLEVEL` | ||
42 | EXTRAVERSION=`getvar EXTRAVERSION` | ||
43 | |||
44 | . ./.config | ||
45 | |||
46 | NAME="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION$CONFIG_LOCALVERSION" | ||
47 | |||
48 | info "Detected kernel version $NAME" | ||
49 | |||
50 | if [ $UID != "0" ]; then | ||
51 | die "Must be root to install kernel!" | ||
52 | fi | ||
53 | |||
54 | # (1) copy modules | ||
55 | if [ "$1" != "-m" ]; then | ||
56 | info "Installing modules..." | ||
57 | silent make -j8 modules_install | ||
58 | else | ||
59 | info "Skipping installing modules." | ||
60 | fi | ||
61 | |||
62 | # (2) copy kernel | ||
63 | info "Installing kernel..." | ||
64 | silent cp -v arch/i386/boot/bzImage /boot/vmlinuz-$NAME | ||
65 | silent cp -v System.map /boot/System.map-$NAME | ||
66 | |||
67 | # (3) build ramdisk | ||
68 | info "Building module dependencies" | ||
69 | silent depmod -v $NAME | ||
70 | |||
71 | info "Building initial ramdisk..." | ||
72 | silent mkinitcpio -g /boot/kernel-$NAME.img -k $NAME | ||
73 | |||
74 | # (4) make bootloader entry | ||
75 | ALREADY_PRESENT=`grep "kernel /boot/vmlinuz-$NAME" /boot/grub/menu.lst ` | ||
76 | |||
77 | if [ ! -z "$ALREADY_PRESENT" ]; then | ||
78 | info "Bootloader entry appears to be already present." | ||
79 | else | ||
80 | info "Creating bootloader entry..." | ||
81 | cat >> /boot/grub/menu.lst <<__EOE__ | ||
82 | |||
83 | # Custom kernel | ||
84 | title Kernel $NAME | ||
85 | root (hd0,5) | ||
86 | kernel /boot/vmlinuz-$NAME root=/dev/sda6 ro vga=791 | ||
87 | initrd /boot/kernel-$NAME.img | ||
88 | __EOE__ | ||
89 | |||
90 | fi | ||
91 | |||
92 | info "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 | |||
3 | RELEASE_DIR=/home/bbb/releases | ||
4 | |||
5 | LIBLITMUS_DIR=/home/bbb/liblitmus | ||
6 | LIBSO_DIR=/home/bbb/libso | ||
7 | LITMUS_DIR=/home/bbb/litmus | ||
8 | |||
9 | BASE_TAG="v2.6.20" | ||
10 | |||
11 | TAG=$1 | ||
12 | |||
13 | function die { | ||
14 | echo $1 | ||
15 | echo | ||
16 | echo "Usage: make_release <TAG>" | ||
17 | echo "Example: make_release 2007.3" | ||
18 | exit 1 | ||
19 | } | ||
20 | |||
21 | if [ -z "$TAG" ]; then | ||
22 | die "TAG missing." | ||
23 | fi | ||
24 | |||
25 | function 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 | |||
36 | function 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 | |||
43 | function 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 | |||
51 | function 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 | |||
61 | TARGET="$RELEASE_DIR/$TAG" | ||
62 | |||
63 | mkdir -p $TARGET || die "Could not make directory $TARGET." | ||
64 | |||
65 | |||
66 | release_litmus || die "Releasing LITMUS^RT failed." | ||
67 | release_liblitmus || die "Releasing liblitmus failed." | ||
68 | release_libso || die "Releasing libso failed." | ||
69 | |||
70 | cd $TARGET | ||
71 | echo "Generating check sums." | ||
72 | sha256sum * > SHA256SUMS | ||
73 | |||
74 | echo "Release generated in $TARGET." | ||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | #CMD=/home/bbb/bin/zaptrail | ||
4 | CMD=zaptrail | ||
5 | |||
6 | set -e | ||
7 | for f in `git diff --name-only`; do | ||
8 | echo "Zapping trailing white space in $f." | ||
9 | $CMD $f | ||
10 | done | ||
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 | |||
3 | if [ "" == "$*" ]; then | ||
4 | echo "zaptrail: remove trailing white space" | ||
5 | echo "Usage: zaptrail <file1> <file2> ...." | ||
6 | exit 1 | ||
7 | fi | ||
8 | |||
9 | sed -i -r -e 's/\s+$//' $* | ||