+++ /dev/null
-#!/usr/bin/python
-
-# This script is for checking that patches don't introduce non-portable symbols
-# into the Lustre/LNET/libcfs code.
-#
-# Input:
-# 1. (Required) Filename (including path) of the diff file to be checked
-# 2. (Optional) path to the nn-final-symbol-list.txt file (By default, this
-# script looks for nn-final-symbol-list.txt in the current working
-# directory.)
-#
-# Output:
-# The output of this script is either PASS or FAIL (with WARNINGS).
-# FAIL means that there may have been symbols found that are not supposed
-# to be used. This requires the person running the script to look into the
-# WARNINGS that are in the output to determine if there is a problem.
-
-# Author: lisa.week@sun.com
-
-import string
-import re
-import sys
-import optparse
-import os.path
-import fileinput
-
-# Setup command line options for nn-check.py
-from optparse import OptionParser
-usage = "%prog DIFF-FILE [options]"
-parser = OptionParser(usage)
-parser.add_option("-s", "--symb", action="store", dest="symb_pathname",
- help="(Optional) PATH to nn-final-symbol-list.txt file",
- metavar="PATH")
-
-(options, args) = parser.parse_args()
-
-# Check if we have the minimum number of arguments supplied.
-if len(args) < 1:
- parser.error("Incorrect number of arguments, see nn-check -h for help.")
-
-# Check if we were passed a path to the nn-final-symbol-list.txt file
-if options.symb_pathname:
- symb_file = os.path.join(options.symb_pathname,
- 'nn-final-symbol-list.txt')
-else:
- symb_file = 'nn-final-symbol-list.txt'
-
-# Global Variables
-bad_symbol_cnt = 0
-symbol_dict = dict()
-
-# Function Definitions
-def search_symbol(line, linenum):
- global bad_symbol_cnt
-
- for key, val in symbol_dict.items():
- regex_match = val.search(line)
-
- if regex_match:
- print_symbol = regex_match.group(0)
- print 'warning: Found %s at line %d:' \
- % (print_symbol, linenum)
- print '%s' % line.rstrip()
- bad_symbol_cnt += 1
-
-# Open the nn-final-symbol-list.txt file and pull in the symbols to check into
-# a dictionary object.
-try:
- f = fileinput.input(symb_file)
-except IOError:
- print 'nn-check.py: error: %s not found.' % symb_file
- print 'Is nn-final-symbol-list.txt is in your current working directory'
- print 'or have you have passed nn-check.py a valid path to the file?'
- sys.exit(1)
-
-
-for line in f:
- stripped_symbol = line.rstrip()
- symbol_dict[stripped_symbol] = re.compile(stripped_symbol)
-
-# Close nn-final-symbol-list.txt
-f.close()
-
-# Open the diff file passed to the script and parse it for the symbols from
-# nn-final-symbol-list.txt
-try:
- f = fileinput.input(sys.argv[1])
-except IOError:
- print 'nn-check.py: error: %s not found.' % sys.argv[1]
- print 'Check the path provided for the diff file.'
- sys.exit(1)
-
-# The main portion of the script
-print '==================================================='
-print '%s: starting nn-check' % sys.argv[1]
-print '==================================================='
-
-index = re.compile(r'^\+\+\+ b/(.*)')
-plus = re.compile(r'^\+')
-for line in f:
- # Check for the "diff --cc " delimiter in order to grab the file name.
- index_match = index.match(line)
-
- if index_match:
- # Store the file name
- filename=index_match.group(1)
- print '%s: ' % filename
- else:
- # Check if the line starts with a "+" character.
- plus_match = plus.match(line)
- if plus_match:
- # The line starts with a "+" character. Look for
- # non-portable symbols
- search_symbol(line, f.lineno())
- else:
- continue
-
-# Close the diff file
-f.close()
-
-# Finish up and print the results of the script (i.e. total number of
-# bad symbols found)
-if bad_symbol_cnt != 0:
- print '=============================='
- print 'Finished nn-check status: FAIL'
- print '=============================='
- print 'Found %d potential problem(s). See "WARNINGS" from script output and refer to https://wikis.lustre.org/intra/index.php/Lustre_Name_Normalization for the complete set of rules to make sure you have not used a non-portable symbol.' % bad_symbol_cnt
-else:
- print '=============================='
- print 'Finished nn-check status: PASS'
- print '=============================='
+++ /dev/null
-#!/bin/sh
-# Extract names of new files from a patch, print them out
-
-PATCHFILE=$1
-case "$PATCHFILE" in
-*.gz) CMD="gzip -d < $PATCHFILE";;
-*) CMD="cat $PATCHFILE";;
-esac
-
-TMP=$(mktemp /tmp/abp.XXXXXX)
-
-eval $CMD | egrep '^--- .*1969|^--- .*1970' > $TMP
-sed -e 's@[^/]*/\([^ ]*\).*@\1@' < $TMP | sed -e 's@^linux/@@' | sort
-rm -f $TMP
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-do_apply()
-{
- FILES=$(cat $P/pc/$PATCH_NAME.pc)
- for file in $FILES
- do
- copy_file_to_bup $file $PATCH_NAME
- done
-
- silent=-s
- if [ $opt_force != 0 ]
- then
- silent=
- fi
-
- if patch -p1 $silent -i "$1" || [ $opt_force != 0 ]
- then
- true
- else
- echo SOMETHING WENT WRONG
- exit 1
- fi
-}
-
-add_to_db()
-{
- basename "$1" >> "$DB"
-}
-
-usage()
-{
- echo "Usage: apatch patchname"
- exit 1
-}
-
-opt_force=0
-PATCH_NAMES=""
-
-for i in $*
-do
- case "$i" in
- -f)
- opt_force=1;;
- *)
- PATCH_NAMES="$PATCH_NAMES $i"
- esac
-done
-
-if [ x"$PATCH_NAMES" == x ]
-then
- usage
-fi
-
-apatch()
-{
- PATCH_NAME=$(stripit $1)
-
- need_file_there $P/pc/$PATCH_NAME.pc
-
- if is_applied "$PATCH_NAME"
- then
- echo "$PATCH_NAME" is already applied
- exit 1
- fi
-
- if [ $opt_force != 0 ]
- then
- echo FORCING PATCH
- fi
-
- if [ $opt_force != 0 ] || can_apply $P/patches/"$PATCH_NAME".patch
- then
- check_pc_match $P/patches/"$PATCH_NAME".patch $P/pc/"$PATCH_NAME".pc
- do_apply $P/patches/"$PATCH_NAME".patch
- add_to_db "$PATCH_NAME"
- echo applied $PATCH_NAME
- echo
- else
- echo "$PATCH_NAME" does not apply
- exit 1
- fi
-}
-
-for i in $PATCH_NAMES
-do
- if ! apatch $i
- then
- exit 1
- fi
-done
-
+++ /dev/null
-#!/bin/sh
-
-. patchfns 2>/dev/null ||
-. /usr/lib/patch-scripts/patchfns 2>/dev/null ||
-. $PATCHSCRIPTS_LIBDIR/patchfns 2>/dev/null ||
-{
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-if [ $# -eq 0 ]
-then
- cat_series
-else
- __cat_series $1
-fi
+++ /dev/null
-#!/bin/sh
-
-#
-# Make superpatch from currently applied patches using combinediff.
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: combine-applied output-file"
- exit 1
-}
-
-if [ $# -ne 1 ]
-then
- usage
-fi
-
-need_file_there applied-patches
-CURRENT=$(mktemp /tmp/cmbd-XXXXXXXX)
-APPLY_FILE=$(mktemp /tmp/cmbd-XXXXXXXX)
-for FILE in `cat applied-patches`
-do
- if [ -f $P/pc/$FILE.pc ]
- then
- cat $P/pc/$FILE.pc >> $CURRENT
- elif [ -f $P/pc/$FILE ]
- then
- cat $P/pc/$FILE >> $CURRENT
- fi
-done
-cat $CURRENT | sort -u > $APPLY_FILE
-echo > $1
-for FILE in `cat $APPLY_FILE`
-do
- diff -uNp $FILE~orig $FILE >> $1
-done
-rm -rf $APPLY_FILE
-rm -rf $CURRENT
-
+++ /dev/null
-#!/bin/sh
-
-#
-# Make superpatch from current series using combinediff.
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: combine-series output-file"
- exit 1
-}
-
-if [ $# -ne 1 ]
-then
- usage
-fi
-
-need_file_there series
-CURRENT=$(mktemp /tmp/cmbd-XXXXXXXX)
-for FILE in $(cat series)
-do
- NEXT=$(mktemp /tmp/cmbd-XXXXXXXX)
- if [ -f $P/patches/$FILE ]
- then
- combinediff $CURRENT $P/patches/$FILE > $NEXT
- elif [ -f $P/patches/$FILE.patch ]
- then
- combinediff $CURRENT $P/patches/$FILE.patch > $NEXT
- elif [ -f $FILE ]
- then
- combinediff $CURRENT $FILE > $NEXT
- fi
- rm $CURRENT
- CURRENT=$NEXT
-done
-
-mv $NEXT "$1"
+++ /dev/null
-#!/bin/sh
-
-doit()
-{
- echo $*
- $*
-}
-
-usage()
-{
- echo "Usage: cvs-take-patch patch_file_name"
- exit 1
-}
-
-#
-# Find the highest level directory in $1 which does not
-# contain the directory $2. Return it in $MISSING
-#
-highest_missing()
-{
- START_DIR="$1"
- NAME="$2"
- MISSING=""
- WHERE=$(dirname "$START_DIR")
- PREV_WHERE=$START_DIR
- while [ x"$WHERE" != x"$PREV_WHERE" ]
- do
- WHERE="$PREV_WHERE"
- if [ ! -d "$WHERE"/"$NAME" ]
- then
- MISSING="$WHERE"
- fi
- PREV_WHERE=$(dirname "$WHERE")
- done
- echo highest_missing returns $MISSING
-}
-
-#
-# Add all new directries to CVS, top-down
-# $1: name of a directory
-# $2: name of the CVS directory
-#
-add_cvs_dirs()
-{
- MISSING=foo
- while [ "$MISSING" != "" ]
- do
- highest_missing $1 $2
- if [ x"$MISSING" != "x" ]
- then
- if [ ! -d "$MISSING"/"$2" ]
- then
- doit cvs add $MISSING
- fi
- fi
- done
-}
-
-PATCHFILE=$1
-
-REMOVEDFILES=$(removed-by-patch $PATCHFILE)
-if [ "$REMOVEDFILES" != "" ]
-then
- doit cvs remove $REMOVEDFILES
-fi
-
-NEWFILES=$(added-by-patch $PATCHFILE)
-for i in $NEWFILES
-do
- DIRNAME=$(dirname $i)
- echo "Looking at $DIRNAME"
- add_cvs_dirs $DIRNAME CVS
-done
-
-if [ "$NEWFILES" != "" ]
-then
- doit cvs add $NEWFILES
-fi
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "export_patch: export the patches listed in ./series" 1>&2
- echo "usage: export_patch destination-directory [prefix] " 1>&2
- exit 1
-}
-
-DIR="$1"
-PREFIX="$2""_"
-
-if [ "$DIR" = "" ]
-then
- usage
-fi
-
-if [ -e "$DIR" -a ! -d "$DIR" ]
-then
- echo "$DIR exists already, but is not a directory." 1>&2
- exit 1
-fi
-
-if [ ! -r ./series ]
-then
- echo "./series is not readable." 1>&2
- exit 1
-fi
-
-mkdir -p "$DIR" || exit 1
-
-count=1
-for x in `cat ./series`
-do
- fname=`echo "$count" "$PREFIX" "$x" |\
- awk '{ if ( $2 != "_" )
- printf("p%05d_%s%s\n", $1, $2, $3);
- else
- printf("p%05d_%s\n", $1, $3);
- }'`
- if [ ! -r $P/patches/"$x" ]
- then
- echo "$P/patches/"$x" is not readable. skipping." 1>&2
- continue;
- fi
- cp -f $P/patches/"$x" "$DIR"/"$fname" || continue;
- count=`expr $count + 1`
-done
-
+++ /dev/null
-#!/bin/sh
-
-insert_line()
-{
- PATTERN="$1"
- LINE="$2"
- FILE="$3"
- awk ' BEGIN { found=0; }
- /'"$PATTERN"'/ {
- print;
- if (!found)
- printf("%s\n", "'$LINE'");
- found=1;
- next;
- }
- { print; }
- ' < "$FILE"
-}
-
-# extract the description from the top of a patch
-# filter stdin
-# collapse adjacent blank lines to a single blank line
-# remove any lines that look like diffstat output
-# stop output on encountering a line beginning with '---' (beginning of patch)
-
- TMPFILE=`mktemp /tmp/xdtmp.XXXXXX` || exit 1
- formail -kfcb -X 'From:' -X 'Subject:' |\
- awk '
- BEGIN { found_end=0; lastone="x"; }
- /^ .* [|] +[0-9]+ [+-]+$/ {
- #/* we found something like diffstat output... */
- if (found_end == 1) {
- /* we are past end of diffstat, let it pass */
- print;
- }
- next;
- }
- /^ [1-9][0-9]* files changed/ {
- #/* end of diffstat output, stop filtering diffstat */
- found_end=1;
- next;
- }
- /^--- / { exit; }
- {
- #/* collapse adjacent blank lines to 1 blank line */
- if ( $0 == "" && lastone == "" )
- next;
- else
- print;
- lastone=$0;
- }
- ' | awk '{ if ($0 == "" && FNR == 1) next; print; }' > "$TMPFILE"
-
- descs=`head -10 $TMPFILE | grep -c '^[ ]*DESC[ ]*$'`
- if [ "$descs" = "0" ]
- then
- # DESC is not 1st non blank line in the file
- echo "DESC"
- descs=0
- fi
- edescs=`grep -c '^EDESC$' "$TMPFILE"`
- subjects=`grep -c '^[ ]*Subject[:]' "$TMPFILE"`
- froms=`grep -c '^[ ]*From[:]' "$TMPFILE"`
- if [ "$edescs" = "0" ]
- then
- if [ "$subjects" != "0" ]
- then
- insert_line '^Subject[:]' 'EDESC' "$TMPFILE"
- else
- if [ "$froms" != "0" ]
- then
- insert_line '^From[:]' 'EDESC' "$TMPFILE"
- else
- if [ "$descs" = "0" ]
- then
- # blank DESC line...
- echo '(undescribed patch)'
- echo EDESC
- cat "$TMPFILE"
- else
- insert_line '^DESC$' "EDESC" "$TMPFILE"
- fi
- fi
- fi
- else
- cat $TMPFILE
- fi
+++ /dev/null
-#!/bin/sh
-
-#
-# Fork the next patch in the series
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: forkpatch <newname>"
- exit 1
-}
-
-if [ $# -ne 1 ]
-then
- usage
-fi
-
-NEW=$1
-BASE=`stripit $NEW`
-SERIES=series
-
-if [ ! -e $SERIES ]
-then
- echo 'File "series" not found'
- exit 1
-fi
-
-if [ -f $P/$BASE.patch ] ; then
- echo "Patch $NEW already exists as a file"
- exit 1
-fi
-
-if grep $BASE $SERIES >& /dev/null ; then
- echo "Patch $NEW already exists in series"
- exit 1
-fi
-
-TMPSERIES=$(mktemp /tmp/series-XXXXXXXX)
-top=$(toppatch)
-if [ x"$top" == x ]
-then
- todo=$(head -1 $SERIES)
-else
- last_in_series=$(stripit $(tail -1 $SERIES))
- if [ $last_in_series == $top ]
- then
- echo "Series fully applied. Ends at $top"
- exit 0
- fi
- todo=$(grep -C1 "^$top\.patch" $SERIES | tail -1)
- if [ x$todo = x ]
- then
- todo=$(head -1 $SERIES)
- fi
-fi
-
-basetodo=`stripit $todo`
-
-sed "s/$todo/$BASE.patch/" < $SERIES > $TMPSERIES
-cat $TMPSERIES > $SERIES
-rm -f $TMPSERIES
-cp -f $P/patches/$todo $P/patches/$BASE.patch
-cp -f $P/pc/$basetodo.pc $P/pc/$BASE.pc
-if [ -f $P/txt/$basetodo.txt ]; then
- cp -f $P/txt/$basetodo.txt $P/txt/$BASE.txt
-else
- echo "Warning no documentation for $BASE"
-fi
-
-echo "Cloned $todo to $BASE"
+++ /dev/null
-#!/bin/sh
-
-#
-# Add a file to a patch.
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: fpatch patchname filename"
- echo " fpatch filename"
- exit 1
-}
-
-if [ $# == 1 ]
-then
- PATCH_NAME=$(top_patch)
- FILENAME=$1
-elif [ $# == 2 ]
-then
- PATCH_NAME=$(stripit $1)
- FILENAME=$2
-else
- usage
-fi
-
-
-if is_applied_last $PATCH_NAME
-then
- true
-else
- if is_applied $PATCH_NAME
- then
- echo $PATCH_NAME is not the last-applied patch
- exit 1
- else
- echo $PATCH_NAME >> $DB
- fi
-fi
-
-if file_in_patch $FILENAME $PATCH_NAME
-then
- echo File $FILENAME is already in patch $PATCH_NAME
- exit 1
-fi
-
-install_file_in_patch $FILENAME $PATCH_NAME
-
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "usage: import_patch [ -p prefix-pattern ] patchfile [...]" 1>&2
- exit 1
-}
-
-XPATTERN=""
-if [ "$1" = "-p" ]
-then
- XPATTERN="$2"
- shift;
- shift;
-fi
-
-if [ "$1" = "" ]
-then
- usage
-fi
-
-if [ ! -e applied-patches ]
-then
- touch applied-patches
-fi
-
-mkdir -p patches || exit 1
-mkdir -p txt || exit 1
-mkdir -p pc || exit 1
-
-if [ ! -e ./series ]
-then
- touch ./series
- if [ "$?" != "0" ]
- then
- echo "Cannot create ./series" 1>&2
- exit 1
- fi
-fi
-
-if [ ! -w ./series ]
-then
- echo "./series is not writable." 1>&2
- exit 1
-fi
-
-PATTERN='s/^'"$XPATTERN"'//'
-for x in $*
-do
- if [ ! -r "$x" ]
- then
- echo "$x does not exist, skipping." 1>&2
- continue
- fi
- patchname=`basename $x .bz2`
- patchname=`basename $patchname .gz`
- patchname=`basename $patchname .Z`
- patchname=`basename $patchname .patch`
- if is_applied $patchname
- then
- echo $patchname is currently applied
- exit 1
- fi
- if [ "$XPATTERN" != "" ]
- then
- patchname=`echo $patchname | sed -e "$PATTERN"`
- fi
- pname=$P/patches/"$patchname".patch
- if [ -r "$pname" ]
- then
- echo "$pname exists already, skipping." 1>&2
- continue
- fi
- case "$x" in
- *.bz2)
- bunzip2 < "$x" > "$pname"
- ;;
- *.gz)
- gunzip < "$x" > "$pname"
- ;;
- *.Z) zcat < "$z" > "$pname"
- ;;
- *)
- cat "$x" > "$pname" || continue
- ;;
- esac
- echo "$patchname".patch >> series
- pcpatch "$pname"
- extract_description < "$pname" >$P/txt/"$patchname".txt
- grep '^[(]undescribed patch[)]$' < $P/txt/"$patchname".txt > /dev/null
- if [ "$?" = "0" ]
- then
- echo "Warning: $patchname has no description." 1>&2
- fi
-done
-
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: inpatch"
- exit 1
-}
-
-if [ $# != 0 ]
-then
- usage
-fi
-
-if [ -e $DB ]
-then
- TOP_PATCH=$(top_patch)
- if [ x$TOP_PATCH != x ]
- then
- cat $P/pc/$TOP_PATCH.pc
- fi
-fi
+++ /dev/null
-#!/bin/sh
-
-usage()
-{
- echo "Usage: join-patch patchname"
- exit 1
-}
-
-if [ $# -ne 1 ]
-then
- usage
-fi
-
-PATCHNAME=$(stripit $1)
-
-if ! can_apply $PATCHNAME
-then
- echo Patch $PATCHNAME does not apply
- exit 1
-fi
-
-pcpatch $PATCHNAME
-for i in $(cat $P/pc/$PATCHNAME.pc)
-do
- fpatch $i
-done
-
-patch -p1 -i "$P/patches/$PATCHNAME.patch" -f
+++ /dev/null
-#!/bin/sh
-#
-# Grab a patch frmo kernel.org, install it.
-#
-# Usage: linus-patch http://www.kernel.org/pub/linux/kernel/people/dwmw2/bk-2.5/cset-1.786.152.7-to-1.798.txt.gz
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-poppatch 999 || die poppatch
-wget $1 || die wget
-FILE=$(basename $1)
-gzip -d < $FILE > $P/patches/linus.patch
-pcpatch linus || die pcpatch
-(
- echo DESC
- echo $FILE
- echo EDESC
- echo
- echo $FILE
-) > $P/txt/linus.txt
-rm $FILE
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: mpatch patchname [output_dir]"
- exit 1
-}
-
-doit()
-{
- echo $* 1>&2
- $* || {
- echo oops
- exit 1
- }
-}
-
-epoch()
-{
-# doit touch -t 7001011000.00 $1
- doit touch -t 7001010000.00 $1
-}
-
-dirfor()
-{
- dir=$(dirname $1)
- if [ ! -d $dir ]
- then
- doit mkdir -p $dir
- RMDIRS="$RMDIRS $dir"
- fi
-}
-
-if [ $# == 0 ]
-then
- usage
-fi
-
-PATCH_NAME=$(stripit $1)
-OUTPUT_DIR=$2
-
-FILES=$(cat $P/pc/$PATCH_NAME.pc)
-OUT=$P/patches/$PATCH_NAME.patch
-TMPOUT=$(mktemp /tmp/patch-$PATCH_NAME-XXXXXX)
-TXT=$P/txt/$PATCH_NAME.txt
-OLDDIR=$(basename $(/bin/pwd))
-NEWDIR=$OLDDIR-$LOGNAME
-
-if is_applied_last $PATCH_NAME
-then
- true
-else
- echo $PATCH_NAME is not the last-applied patch
- exit 1
-fi
-
-doit rm -f $OUT
-echo "Placing patch in " $OUT
-
-if [ -e $TXT -a -s $TXT ]
-then
- echo >> $OUT
- body $TXT >> $OUT
- echo >> $OUT
- echo >> $OUT
-else
- echo "**** No patch description for $PATCH_NAME ****"
-fi
-
-rm -f $TMPOUT
-
-for file in $FILES
-do
- OLD_FILE="$file"~"$PATCH_NAME"
- if [ ! -e $OLD_FILE ]
- then
- OLD_FILE=/dev/null
- fi
- NEW_FILE=$file
- XDIFF_OPTS=""
- if [ ! -e $NEW_FILE ]
- then
- NEW_FILE=/dev/null
- XDIFF_OPTS="-L $file"
- fi
-
- echo diff -puN $XDIFF_OPTS $DIFF_OPTS $OLD_FILE $NEW_FILE
- diff -puN $XDIFF_OPTS $DIFF_OPTS $OLD_FILE $NEW_FILE | p0-2-p1 $OLDDIR $NEWDIR >> $TMPOUT
-done
-diffstat -p1 $TMPOUT >> $OUT 2>/dev/null
-echo >> $OUT
-cat $TMPOUT >> $OUT
-echo >> $OUT
-echo "_" >> $OUT
-rm -f $TMPOUT
+++ /dev/null
-#!/bin/sh
-
-usage()
-{
- echo "Usage: new-kernel linux-2.4.2-pre2 linux-2.4.3-pre3 linux-2.4.3 patch.gz cvs-dir"
- exit 1
-}
-
-wantdir()
-{
- if [ x$1 = x ]
- then
- usage
- fi
- if [ ! -d $1 ]
- then
- echo "directory $1 does not exist"
- usage
- fi
-}
-
-wantfile()
-{
- if [ x$1 = x ]
- then
- usage
- fi
- if [ ! -f $1 ]
- then
- echo "file $1 does not exist"
- usage
- fi
-}
-
-doit()
-{
- echo $* 1>&2
- $* || {
- echo oops
- exit 1
- }
-}
-
-
-CURRENT_KERNEL=$1
-NEXT_KERNEL=$2
-BASE_KERNEL=$3
-PATCH_FILE=$4
-CVS_DIR=$5
-
-TEMP_PATCH=$(mktemp /tmp/patch-XXXXXX)
-MY_DIFF="$CURRENT_KERNEL"--"$NEXT_KERNEL"
-
-wantdir $CURRENT_KERNEL
-wantdir $BASE_KERNEL
-wantdir $CVS_DIR
-wantfile $PATCH_FILE
-
-doit rm -rf $NEXT_KERNEL
-doit cp -a $BASE_KERNEL $NEXT_KERNEL
-doit rm -f $TEMP_PATCH
-doit gunzip < $PATCH_FILE > $TEMP_PATCH
-cd $NEXT_KERNEL
-doit patch -p1 --dry-run -i $TEMP_PATCH
-doit patch -p1 -s -i $TEMP_PATCH
-echo cd ..
-cd ..
-
-echo diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL
-diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL > $MY_DIFF
-
-echo cd $CVS_DIR
-cd $CVS_DIR
-doit patch -p1 --dry-run -s -i ../$MY_DIFF
-doit patch -p1 -s -i ../$MY_DIFF
-cvs-take-patch ../$MY_DIFF
-cvs commit -m "'doing $NEXT_KERNEL'"
-cvs update -ko -d -P
-
-TAG=$(echo $NEXT_KERNEL | sed -e 's@\.@_@g')
-cvs tag $TAG
-rm -f $TEMP_PATCH
+++ /dev/null
-#!/bin/sh
-#
-# Usage: p0-2-p1 olddir newdir
-#
-OLDDIR=$1
-NEWDIR=$2
-
-sed -e "s/^--- \([^\/].*\)/--- $OLDDIR\/\1/" |
-sed -e "s/^+++ \([^\/].*\)/+++ $NEWDIR\/\1/"
-
+++ /dev/null
-#!/bin/sh
-
-#
-# Bring up a patched file in diff. We show the diffs
-# in the topmost patch, unless it was specified
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: pdiff [patchname] filename"
- echo " pdiff [patchname] -"
- exit 1
-}
-
-if [ $# == 1 ]
-then
- PATCH_NAME=$(top_patch)
- FILENAME=$1
-elif [ $# == 2 ]
-then
- PATCH_NAME=$(stripit $1)
- FILENAME=$2
-else
- usage
-fi
-
-if ! is_applied $PATCH_NAME
-then
- echo $PATCH_NAME is not applied
- exit 1
-fi
-
-doit()
-{
- filename=$1
- unpatched_file=$filename"~"$PATCH_NAME
- need_file_there $filename
- if [ -e $unpatched_file ]
- then
- diff -u $unpatched_file $filename
- else
- echo pdiff: $filename appears to not be in $PATCH_NAME
- fi
-}
-
-if [ x"$FILENAME" = "x-" ]
-then
- FILENAME=$(cat $P/pc/$PATCH_NAME.pc)
-fi
-
-for i in $FILENAME
-do
- doit $i
-done
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-desc1()
-{
- PATCH=$(stripit $1)
- TXT=$P/txt/$PATCH.txt
- echo $PATCH.patch
- desc < $TXT
- echo
-}
-
-for i in $*
-do
- desc1 $i
-done
+++ /dev/null
-DB=applied-patches
-
-#
-# Work out where the user's pc/, patch/ and txt/ directories live.
-#
-# If the user specified PATCHSCRIPTS in environment then use that (it's
-# probably a relative path)
-#
-# If there is a directory ./patch-scripts then use that
-#
-# Otherwise use "."
-#
-
-if [ x$PATCHSCRIPTS_LIBDIR != x ]
-then
- P=$PATCHSCRIPTS_LIBDIR
-elif [ -d ./patch-scripts ]
-then
- P=./patch-scripts
-elif [ -d ./patches ]
-then
- P=.
-else
- echo "could not locate your pc/ and patches/ directories"
- exit 1
-fi
-
-top_patch()
-{
- tail -1 $DB
-}
-
-die()
-{
- echo error: $*
- exit 1
-}
-
-is_numeric()
-{
- if echo $1 | egrep '^[0-9]*$' > /dev/null
- then
- return 0
- fi
- return 1
-}
-
-is_applied_last()
-{
- name="$(stripit $1)"
- top_patch >$DB.1
- if grep "^$name$" "$DB.1" > /dev/null 2>&1
- then
- rm $DB.1
- return 0
- else
- rm $DB.1
- return 1
- fi
-}
-
-is_applied()
-{
- name=$(stripit "$1")
- if grep "^$name$" "$DB" > /dev/null 2>&1
- then
- return 0
- else
- return 1
- fi
-}
-check_pc_match()
-{
- if [ -f /usr/bin/lsdiff ]; then
- tmpfile=$(mktemp /tmp/p_XXXXXX) || exit 1
- lsdiff --strip=1 $1 > $tmpfile
- diff $2 $tmpfile > /dev/null
- if [ $? != 0 ]; then
- echo " $1 do not match with $2 "
- echo " $2 will be changed to match $2"
- # cat $tmpfile > $P/pc/$PATCH_NAME.pc
- fi
- rm -rf $tmpfile
- fi
-}
-can_apply()
-{
- if patch -p1 --dry-run -i "$1" -f
- then
- return 0
- else
- return 1
- fi
-}
-
-can_remove()
-{
- if patch -R -p1 --dry-run -i $P/patches/"$1".patch -f
- then
- return 0
- else
- return 1
- fi
-}
-
-remove_from_db()
-{
- tmpfile=$(mktemp /tmp/p_XXXXXX)
- name="$1"
- sed -e "/^$name$/d" < "$DB" > $tmpfile
- mv $tmpfile "$DB"
-}
-
-stripit()
-{
- ret=$(basename $1)
- ret=$(echo $ret | sed -e 's/\.patch$//')
- ret=$(echo $ret | sed -e 's/\.pc$//')
- ret=$(echo $ret | sed -e 's/\.txt$//')
- echo $ret
-}
-
-top_is_current()
-{
- patch_name=$(top_patch)
- if [ x$patch_name == x ]
- then
- return 1
- else
- patch_file=$P/patches/"$patch_name".patch
- files=$(cat $P/pc/$patch_name.pc)
- for file in $files
- do
- if [ $file -nt $patch_file ]
- then
- echo $file newer than $patch_file
- return 0
- fi
- done
- fi
- return 1
-}
-
-need_top_current()
-{
- if top_is_current
- then
- echo "Error: Top patch is not up-to-date"
- exit 1
- fi
-}
-
-warn_top_current()
-{
- if top_is_current
- then
- echo "Warning: Top patch is not up-to-date"
- fi
-}
-
-file_in_patch()
-{
- file=$1
- patch=$2
-
- if [ -e $P/pc/$patch.pc ]
- then
- if grep "^"$file"$" $P/pc/$patch.pc > /dev/null
- then
- return 0
- fi
- fi
- return 1
-}
-
-# copy_file_to_bup filename patchname
-copy_file_to_bup()
-{
- file=$1
- patch=$2
- bup="$file"~"$patch"
- orig="$file"~"orig"
- src_dir=`pwd`
-
- if [ -e $bup ]
- then
- echo "Cannot install file $file in patch $patch: backup $bup exists"
- exit 1
- fi
- if [ -e $file ]
- then
- cp -p $file "$file"~"$patch"
- else
- echo "file $file appears to be newly added"
- fi
- if [ ! -L "$orig" ]; then
- ln -s "$src_dir/$bup" $orig
- fi
-}
-
-install_file_in_patch()
-{
- file=$1
- patch=$2
-
- copy_file_to_bup $file $patch
- echo $file >> $P/pc/$patch.pc
-# touch $P/txt/$patch.txt
-}
-
-need_file_there()
-{
- if [ ! -e $1 ]
- then
- echo "File $1 does not exist"
- exit 1
- fi
-}
-
-desc()
-{
- state=0
- while read x
- do
- if [ x"$x" = xDESC ]
- then
- state=1
- elif [ x"$x" = xEDESC ]
- then
- state=0
- elif [ $state = 1 ]
- then
- echo " $x"
- fi
- done
-}
-
-body()
-{
- file=$1
-
- did_stuff=0
- while read x
- do
- if [ x"$x" = xEDESC ]
- then
- cat
- did_stuff=1
- fi
- done < $file
-
- if [ $did_stuff = 0 ]
- then
- cat $file
- fi
-}
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "pcpatch: recreate the pc file from patches/{patchname}.patch"
- exit 1
-}
-
-doit()
-{
- echo $* 1>&2
- $* || {
- echo oops
- exit 1
- }
-}
-
-if [ $# != 1 -o "$1" = "help" ]
-then
- usage
-fi
-PATCH=$1
-PATCH_NAME=$(stripit $PATCH)
-PC=$P/pc/$PATCH_NAME.pc
-
-if [ ! -e $P/patches/$PATCH_NAME.patch ]
-then
- echo "$P/patches/$PATCH_NAME.patch does not exist"
- exit 1
-fi
-
-if is_applied "$PATCH"
-then
- echo $PATCH is applied!
- exit 1
-fi
-
-touched-by-patch $P/patches/$PATCH_NAME.patch > $PC
-echo Recreated $PC
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: poppatch [npatches]"
- exit 1
-}
-
-doit()
-{
- echo $* 1>&2
- $* || {
- echo oops
- exit 1
- }
-}
-
-if [ $# -gt 1 ]
-then
- usage
-fi
-
-NR=1
-STOP_AT=""
-if [ $# -eq 1 ]
-then
- if is_numeric $1
- then
- NR=$1
- else
- NR=1000
- STOP_AT=$(stripit $1)
- fi
-fi
-
-pop_one()
-{
- TOP_PATCH=$(top_patch)
- if [ x$TOP_PATCH == x ]
- then
- echo "no patches applied"
- exit 0
- else
- popped_patch="$(top_patch)"
- if ! rpatch $(top_patch)
- then
- echo still at $(top_patch)
- exit 1
- fi
- echo
- fi
-}
-
-for i in $(seq 1 $NR)
-do
- pop_one
- if [ x$STOP_AT != "x" ]
- then
- if [ $STOP_AT == $(toppatch) ]
- then
- sum-series applied-patch
- exit 0
- fi
- fi
-done
-sum-series applied-patch
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-if [ $# -ne 1 ]
-then
- echo "Usage prep-patch patchname"
- exit 1
-fi
-
-PATCHNAME=$(stripit $1)
-
-xcb -s 2 < $P/patches/$PATCHNAME.patch
-head -2 $P/txt/$PATCHNAME.txt | tail -1 | tr -d '\n' | xcb -s 1
+++ /dev/null
-#!/bin/sh
-
-# print out patch status. Usage: pstatus [ patchfile ... ]
-#
-# Stephen Cameron <steve.cameron@hp.com>
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-if [ ! -f ./series ]
-then
- echo "./series does not exist." 1>&2
- exit 1
-fi
-
-if [ ! -d ./patches ]
-then
- echo "Directory ./patches does not exist." 1>&2
- exit 1
-fi
-
-
-PATCHLIST="$*"
-if [ "$PATCHLIST" = "" ]
-then
- series_optimize=yes
- PATCHLIST=`cat series | sed -e 's/[.]patch[ ]*$//'`
- SORTSERIES=`mktemp /tmp/ser.XXXXXX` || exit 1
- SORTPATCHES=`mktemp /tmp/pat.XXXXXX` || exit 1
- sed -e 's/^[ ]//' -e 's/[.]patch[ ]*$//' < series | \
- sort > $SORTSERIES
- exists="`echo $P/patches/*.patch 2>/dev/null`"
- if [ "$exists" != "$P/patches/*.patch" ]
- then
- ls -1 $P/patches/*.patch | sed -e 's/^.*\/patches\///' \
- -e 's/[.]patch[ ]*$//' | sort > $SORTPATCHES
- PATCHLIST="$PATCHLIST"" `comm -1 -3 $SORTSERIES $SORTPATCHES`"
- fi
- rm -f $SORTPATCHES $SORTSERIES
-else
- series_optimize=no
-fi
-
-NSERIES=`wc -l series | awk '{ print $1; }'`
-series=1
-for PATCH_NAME in $PATCHLIST
-do
- PATCH_NAME=$(stripit $PATCH_NAME)
- # see if this patch even exists
- if [ ! -f $P/patches/"$PATCH_NAME".patch ]
- then
- echo "$PATCH_NAME does not exist."
- continue
- fi
- # see if this patch is applied
- applied="-"
- if [ -f applied-patches ]
- then
- grep '^'"$PATCH_NAME"'$' applied-patches > /dev/null
- if [ "$?" = "0" ]
- then
- applied="a"
- fi
- fi
-
- # figure the status of this patch, that is,
- # if it needs changelog, pcpatch, refpatch
-
- stat=""
- if [ ! -f $P/txt/"$PATCH_NAME".txt ]
- then
- stat="changelog "
- fi
- if [ ! -f $P/pc/"$PATCH_NAME".pc ]
- then
- stat="$stat""pcpatch "
- elif [ "$applied" != '-' ]
- then
- rpatch=n
-
- # for each file this patch touches
- for y in `cat $P/pc/"$PATCH_NAME".pc`
- do
- # is the patch adding the file?
- if [ ! -e "$y"'~'"$PATCH_NAME" -a -f "$y" ]
- then
- # file is newer than the patch?
- if [ "$y" -nt $P/patches/"$PATCH_NAME".patch ]
- then
- rpatch=y
- stat="$stat""refpatch "
- break
- fi
- else
- # modified file is newer than the patch?
- if [ "$y"'~'"$PATCH_NAME" -nt \
- $P/patches/"$PATCH_NAME".patch ]
- then
- rpatch=y
- stat="$stat""refpatch "
- break
- fi
- if [ "`toppatch`" = "$PATCH_NAME" -a \
- "$y" -nt $P/patches/"$PATCH_NAME".patch ]
- then
- # toppatch, so check if the file
- # is newer than the patch?
- rpatch=y
- stat="$stat""refpatch "
- break
- fi
- fi
- done
- fi
- # check if they changed the changelog recently
- if [ "$rpatch" = "n" -a -f $P/txt/"$PATCH_NAME".txt \
- -a $P/txt/"$PATCH_NAME".txt -nt \
- $P/patches/"$PATCH_NAME".patch ]
- then
- rpatch=y
- stat="$stat""refpatch "
- fi
- if [ "$stat" != "" ]
- then
- stat="Needs ""$stat"
- fi
-
- if [ "$series_optimize" != "yes" ]
- then
- # have to find the series number the hard way.
- series=`grep -n '^'"$PATCH_NAME"'\.patch$' series |\
- awk -F: '{ printf "%d", $1}' `
- if [ "$series" = "" ]
- then
- series="?"
- fi
- fi
-
- echo "$series":"$applied":"$PATCH_NAME $stat"
-
- if [ "$series_optimize" = "yes" ]
- then
- if [ "$series" != "?" ]
- then
- series=`expr $series + 1`
- if [ $series -gt $NSERIES ]
- then
- series="?"
- fi
- fi
- fi
-done
+++ /dev/null
-#!/bin/sh
-
-#
-# Bring up a patched file in tkdiff. We show the diffs
-# in the topmost patch, unless it was specified
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: ptkdiff filename ..."
- echo " ptkdiff -"
- exit 1
-}
-
-PATCH_NAME=$(top_patch)
-
-doit()
-{
- filename=$1
- unpatched_file=$filename"~"$PATCH_NAME
- need_file_there $filename
- if [ -e $unpatched_file ]
- then
- tkdiff $unpatched_file $filename
- else
- echo ptkdiff: $filename appears to not be in $PATCH_NAME
- fi
-}
-
-if [ x"$1" = "x-" ]
-then
- FILENAME=$(cat $P/pc/$PATCH_NAME.pc)
-else
- FILENAME="$*"
-fi
-
-for i in $FILENAME
-do
- doit $i &
-done
+++ /dev/null
-#!/bin/sh
-
-#
-# Add next patch in series
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: pushpatch [npatches]"
- exit 1
-}
-
-opt_force=0
-
-for i in $*
-do
- case "$i" in
- -f)
- opt_force=1;;
- *)
- if [ -n "$NR" -o -n "$STOP_AT" ]
- then
- usage
- fi
- if is_numeric $i
- then
- NR=$i
- else
- NR=1000
- STOP_AT=$(stripit $i)
- fi;;
- esac
-done
-
-[ $opt_force = 1 ] && force="-f"
-
-SERIES=series
-
-if [ ! -e $SERIES ]
-then
- echo 'File "series" not found'
- exit 1
-fi
-
-push_one()
-{
- top=$(toppatch)
- if [ x"$top" == x ]
- then
- todo=$(head -1 $SERIES)
- else
- last_in_series=$(stripit $(tail -1 $SERIES))
- if [ $last_in_series == $top ]
- then
- echo "Series fully applied. Ends at $top"
- exit 0
- fi
- todo=$(grep -C1 "^$top\.patch" $SERIES | tail -1)
- if [ x$todo = x ]
- then
- todo=$(head -1 $SERIES)
- fi
- fi
-
- apatch $force $todo
-}
-
-for i in $(seq 1 $NR)
-do
- push_one
- if [ x$STOP_AT != "x" ]
- then
- if [ $STOP_AT == $(toppatch) ]
- then
- sum-series applied-patch
- exit 0
- fi
- fi
-done
-sum-series applied-patch
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: refpatch"
- exit 1
-}
-
-doit()
-{
- echo $* 1>&2
- $* || {
- echo oops
- exit 1
- }
-}
-
-if [ $# != 0 ]
-then
- usage
-fi
-
-TOP_PATCH=$(top_patch)
-mpatch $* $(top_patch)
-sum-series applied-patch
-echo "Refreshed $TOP_PATCH"
+++ /dev/null
-#!/bin/sh
-# Extract names of new files from a patch, print them out
-
-PATCHFILE=$1
-case "$PATCHFILE" in
-*.gz) CMD="gzip -d < $PATCHFILE";;
-*) CMD="cat $PATCHFILE";;
-esac
-
-TMP=$(mktemp /tmp/rbp-XXXXXX)
-
-eval $CMD | egrep '^\+\+\+.*1970|\+\+\+.*1969' > $TMP
-sed -e 's@[^/]*/\([^ ]*\).*@\1@' < $TMP | sed -e 's@^linux/@@' | sort
-rm -f $TMP
+++ /dev/null
-#!/bin/sh
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-OLD=$(stripit $1)
-NEW=$(stripit $2)
-
-mv $P/pc/$OLD.pc $P/pc/$NEW.pc
-mv $P/patches/$OLD.patch $P/patches/$NEW.patch
-mv $P/txt/$OLD.txt $P/txt/$NEW.txt
-
-cvs remove $P/pc/$OLD.pc
-cvs remove $P/patches/$OLD.patch
-cvs remove $P/txt/$OLD.txt
-
-cvs add $P/pc/$NEW.pc
-cvs add $P/patches/$NEW.patch
-cvs add $P/txt/$NEW.txt
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: rolled-up-patch"
- exit 1
-}
-
-if [ $# != 0 ]
-then
- usage
-fi
-
-RUP=$(mktemp /tmp/rup-XXXXXX)
-rm -f $RUP
-
-for i in $(cat applied-patches)
-do
- patch_name=$(stripit $i)
- cat $P/pc/$patch_name.pc
-done | sort | uniq > $RUP
-
-kdiff $(cat $RUP)
-rm -f $RUP
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-# do_remove()
-# {
-# if patch -R -p1 -s -i $P/patches/"$1".patch
-# then
-# true
-# else
-# echo SOMETHING WENT WRONG
-# exit 1
-# fi
-# }
-
-do_remove()
-{
- FILES=$(cat $P/pc/$1.pc)
- for file in $FILES ; do
- base_dir=`pwd`
- if [ -L "$file"~"orig" ]; then
- if [ `readlink "$file"~"orig"` = "$base_dir/""$file"~"$1" ]; then
- rm -rf "$file"~"orig"
- fi
- fi
- if [ -f "$file"~"$1" ]; then
- mv -f "$file"~"$1" "$file"
- else
- rm -f "$file"
- fi
- done
- true
-}
-
-kill_old_ones()
-{
- FILES=$(cat $P/pc/$1.pc)
- for file in $FILES
- do
- rm -f "$file"~"$1"
- done
-}
-
-usage()
-{
- echo "Usage: rpatch patchname"
- exit 1
-}
-
-if [ $# == 0 ]
-then
- usage
-fi
-
-PATCH_NAME=$(stripit $1)
-
-warn_top_current
-if is_applied "$PATCH_NAME"
-then
-# if can_remove "$PATCH_NAME"
-# then
- if [ ! -f $P/pc/$PATCH_NAME.pc ]; then
- exit 1
- fi
- do_remove "$PATCH_NAME"
- kill_old_ones "$PATCH_NAME"
- remove_from_db "$PATCH_NAME"
-# else
-# echo "$PATCH_NAME" does not remove cleanly
-# exit 1
-# fi
-else
- echo "$PATCH_NAME" is not applied
- exit 1
-fi
-
-top=$(top_patch)
-if [ x"$top" == x ]
-then
- msg="no patches applied"
-else
- msg="now at $top"
-fi
-
-echo Removed $PATCH_NAME, $msg
-
+++ /dev/null
-#!/usr/bin/perl -w
-$out = "";
-while (<>) {
- next if (/^Only/);
- next if (/^Binary/);
- if (/^diff/ || /^Index/) {
- if ($out) {
- close OUT;
- }
- (@out) = split(' ', $_);
- shift(@out) if (/^diff/);
- $out = pop(@out);
- $out =~ s:/*usr/:/:;
- $out =~ s:/*src/:/:;
- $out =~ s:^/*linux[^/]*::;
- $out =~ s:\(w\)::;
- next if ($out eq "");
- $out = "/var/tmp/patches/$out";
- $dir = $out;
- $dir =~ s:/[^/]*$::;
- print STDERR "$out\n";
- system("mkdir -p $dir");
- open(OUT, ">$out") || die("cannot open $out");
- }
- if ($out) {
- print OUT $_;
- }
-}
-
+++ /dev/null
-#!/bin/sh
-
-#
-# Make superpatch from current series using combinediff.
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: sum-series output-file"
- exit 1
-}
-
-if [ $# -ne 1 ]
-then
- usage
-fi
-
-need_file_there applied-patches
-CURRENT=$(mktemp /tmp/cmbd-XXXXXXXX)
-for FILE in $(cat applied-patches)
-do
-# echo "Adding patch $FILE...."
- if [ -f $P/patches/$FILE ]
- then
- cat $P/patches/$FILE >> $CURRENT
- elif [ -f $P/patches/$FILE.patch ]
- then
- cat $P/patches/$FILE.patch >> $CURRENT
- elif [ -f $FILE ]
- then
- cat $FILE >> $CURRENT
- fi
-done
-
-mv $CURRENT "$1"
+++ /dev/null
-#!/bin/sh
-
-# tag-series tagname series-file-name
-#
-# Does a `cvs tag tagname' of all the .pc, .txt and .patch files mentioned
-# in series-file-name. Also tags series-file-name.
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-# tag_one tag patchname
-#
-tag_one()
-{
- PN=$(stripit $2)
- if [ -r $P/txt/$PN.txt ]
- then
- cvs tag $1 $P/pc/$PN.pc $P/patches/$PN.patch $P/txt/$PN.txt
- else
- cvs tag $1 $P/pc/$PN.pc $P/patches/$PN.patch
- fi
-}
-
-if [ $# -ne 2 ]
-then
- echo Usage: tag-series tagname series-file-name
- exit 1
-fi
-
-TAG=$1
-SERIES=$2
-
-for p in $(cat $SERIES)
-do
- tag_one $TAG $p
-done
-cvs tag $TAG $SERIES
+++ /dev/null
-#!/bin/sh
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: toppatch"
- exit 1
-}
-
-if [ $# != 0 ]
-then
- usage
-fi
-
-if [ -e $DB ]
-then
- TOP_PATCH=$(top_patch)
- if [ x$TOP_PATCH != x ]
- then
- echo $TOP_PATCH
- fi
-fi
+++ /dev/null
-#!/bin/sh
-# Extract names of new files from a patch, print them out
-
-PATCHFILE=$1
-case "$PATCHFILE" in
-*.gz) CMD="gzip -d < $PATCHFILE";;
-*) CMD="cat $PATCHFILE";;
-esac
-
-TMP=$(mktemp /tmp/tbp-XXXXXX) || exit 1
-TMP2=$(mktemp /tmp/tbp2-XXXXXX) || exit 1
-
-eval $CMD | egrep '^\+\+\+ |^\-\-\- ' > $TMP
-
-cat $TMP | sed -e 's@[^/]*/\([^ ]*\).*@\1@' \
- | grep -v '^dev\/null$' \
- | sort \
- | uniq \
- > $TMP2
-
-rm -f $TMP
-grep < $TMP2 '^[+][+][+]' > /dev/null
-if [ "$?" = "0" ]
-then
- echo "WARNING: $PATCHFILE appears to be -p0 form rather than -p1." 1>&2
- echo " Use "\'"p0-2-p1 . . < $PATCHFILE"\'" to fix" 1>&2
- awk '{ print $2 }' < $TMP2
-else
- cat $TMP2
-fi | grep -v '~'
-
-rm -f $TMP2
+++ /dev/null
-#!/bin/sh
-
-#
-# Fork the next patch in the series
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: trypatch <newname>"
- exit 1
-}
-
-if [ $# -ne 1 ]
-then
- usage
-fi
-
-NEW=$1
-BASE=`stripit $NEW`
-SERIES=series
-
-if [ ! -e $SERIES ]
-then
- echo 'File "series" not found'
- exit 1
-fi
-
-if grep $BASE $SERIES >& /dev/null ; then
- echo "Patch $NEW already exists in series"
- exit 1
-fi
-
-if [ ! -f $P/patches/$BASE.patch ] ; then
- echo "Patch $NEW doesn't exist as a file"
- exit 1
-fi
-
-$TMPSERIES=$(mktemp /tmp/series-XXXXXXXX)
-top=$(toppatch)
-if [ x"$top" == x ]
-then
- todo=$(head -1 $SERIES)
-else
- last_in_series=$(stripit $(tail -1 $SERIES))
- if [ $last_in_series == $top ]
- then
- echo "Series fully applied. Ends at $top"
- exit 0
- fi
- todo=$(grep -C1 "^$top\.patch" $SERIES | tail -1)
- if [ x$todo = x ]
- then
- todo=$(head -1 $SERIES)
- fi
-fi
-
-if patch -p1 -i $P/patches/$BASE.patch ; then
- patch -R -p1 -i $P/patches/$BASE.patch
-
- $basetodo=$(basename $todo)
- sed "s/$todo/$BASE/" < $SERIES > $TMPSERIES
- mv -f $TMPSERIES $SERIES
- echo "Replaced $todo with $BASE"
-else
- echo "Failed to replace $todo with $BASE"
-fi
+++ /dev/null
-#!/usr/bin/python
-
-import sys
-import re
-import string
-
-#TODO
-# clean up rest/file
-# clean up +6 and like (assumptions). should be turned into 'find'
-# make regession tests for all cases (Only in, etc)
-
-try:
- filename = sys.argv[1]
-except:
- print 'requires a file name'
- sys.exit(1)
-
-filefd = open(filename)
-file = filefd.read()
-filefd.close()
-
-rest = file
-pat = "(^(?:diff .*\n)?--- .*\n\+\+\+ .*)?\n@@ -(\d+),?(\d+)? \+(\d+),?(\d+)? @@|^(Only in .*)"
-startpat = re.compile(pat, re.M)
-
-pos = 0
-oldpos = 0
-filelen = len(rest)
-oldrest = ""
-while(1):
- rexp = startpat.search(rest)
- if not rexp:
- break
-
- if rexp.group(6):
- print rexp.group(6)
- rest = rest[rexp.end(6)+1:]
- continue
-
- header = rexp.group(1)
- orgfile_start = string.atoi(rexp.group(2))
- if rexp.group(3):
- orgfile_len = string.atoi(rexp.group(3))
- else:
- orgfile_len = -1
- newfile_start = string.atoi(rexp.group(4))
- if rexp.group(5):
- newfile_len = string.atoi(rexp.group(5))
- else:
- newfile_len = -1
- rest = rest[rexp.start(2):]
- rest = rest[string.find(rest, "\n")+1:]
-
- rexp2 = startpat.search(rest)
- if rexp2:
- if rexp2.start(6) != -1:
- oldrest = rest[rexp2.start(6)-1:]
- rest = rest[:rexp2.start(6)]
- elif rexp2.start(1) == -1:
- oldrest = rest[rexp2.start(2)-5:]
- rest = rest[:rexp2.start(2)-4]
- else:
- oldrest = rest[rexp2.start(1)-1:]
- rest = rest[:rexp2.start(1)]
- else:
- oldrest = rest
-
-# pos = filelen - len(oldrest)
-# if pos - oldpos > 100:
-# sys.stderr.write(`pos`+'/'+`filelen`+'\n')
-# oldpos = pos
-
- first = 1
- oldminuses = 0
- oldplusses = 0
- oldoffset = 0
- while(1):
- #erstat early line stuff med lookbehind paa {1,2}-dims
- #nedenfor RAA
- linepat = "^([^-+\n]*)\n?(((^[-+].*\n)|^(.*\n){1,2}(?=^[-+].*\n))+)(.*)\n?"
- compat = re.compile(linepat, re.M)
- rexp = compat.search(rest)
- if not rexp:
- break
-
- prematch = rexp.group(1)
- match = rexp.group(2)
- muddle = len(match)
-
-# print rest
-# print 'prematch ', rexp.start(1), rexp.end(1), prematch
-# print 'match ---------'
-# print match
-# print 'match --------'
-
- # dump unwanted early lines...
- if match[0] != "+" and match[0] != "-":
- while(1):
- next = string.find(match, '\n')
- if next == -1:
- break
- if match[next+1] == "+" or match[next+1] == "-":
- prematch = match[:next]
- match = match[next+1:]
- break
- match = match[next+1:]
-
-
-# print 'prematch ', rexp.start(1), rexp.end(1), len(prematch)
-# print '('+prematch+')'
-# if prematch == ' ':
-# print 'space'
- muddle = muddle - len(match)
-
- lines = string.count(match, "\n")
- compat = re.compile("^-", re.M)
- minuses = len(compat.findall(match))
- compat = re.compile("^\+", re.M)
- plusses = len(compat.findall(match))
- orgsize = minuses + 2 + (lines - minuses - plusses)
- newsize = plusses + 2 + (lines - minuses - plusses)
-
- noeol = "^(\\\ No newline at end of file)$"
- compnoeol = re.compile(noeol, re.M)
- if compnoeol.search(match) or compnoeol.search(rexp.group(6)):
- orgsize = orgsize - 1
- newsize = newsize - 1
-
- coherent = 0
- if lines - plusses == 0:
- coherent = 1
- elif lines - minuses == 0:
- coherent = 1
-
- # RAA FIXME
- if not len(prematch):#or len(prematch) == 1 and prematch == ' ':
- orgsize = orgsize -1
- newsize = newsize -1
- if rexp.start(6) == rexp.end(6):
- orgsize = orgsize -1
- newsize = newsize -1
-
-# print "lines in match: ", lines
-# print "number of minuses: ", minuses
-# print "number of plusses: ", plusses
-
- matchpos = rexp.start(2) + muddle
- offset = string.count(rest[:matchpos], "\n")
-
-# print 'offset/oldoffset: ', offset,oldoffset
-# print 'oldplusses/oldminuses: ', oldplusses, oldminuses
-# print 'orgfile_start/newfile_start: ', orgfile_start, newfile_start
-
- orgstart = orgfile_start + offset + oldoffset - oldplusses
- newstart = newfile_start + offset - oldminuses + oldoffset
-
- # RAA: Bwadr. Fix antagelse om prematch paa en anden
- # maade
- orgstartmod = 0
- newstartmod = 0
- if orgfile_start == 1 and not len(prematch):
- orgstartmod = 1
- if newfile_start == 1 and not len(prematch):
- newstartmod = 1
- if orgfile_start == 0 and orgfile_len == 0:
- orgstartmod = 1
- # RAA Hack!
- plusses = plusses + 1
- minuses = minuses +1
- if newfile_start == 0 and newfile_len == 0:
- newstartmod = 1
- # RAA Hack!
- plusses = plusses + 1
- minuses = minuses +1
-
- if header and first:
- print header
- first = 0
-
- # should the start(1) == 0 be orgstart == 1? RAA
- if orgstart == 1 and newstart == 1 and plusses == 0 and coherent:
- print "@@ -"+`orgstart`+","+`orgsize`+" +"+`newstart`+" @@"
- print match[:string.rfind(match, "\n")]
- print rexp.group(6)
- elif rexp.start(6) == rexp.end(6) and plusses == 0 and coherent:
- if orgstartmod:
- orgstart = orgstart + 1
- if newstartmod:
- newstart = newstart + 1
- print "@@ -"+`orgstart-1`+","+`orgsize`+" +"+`newstart-1`+" @@"
- print prematch
- print match[:string.rfind(match, "\n")]
- elif orgstart == 1 and orgstart == 1 and minuses == 0 and coherent:
- print "@@ -"+`orgstart`+" +"+`newstart`+","+`newsize`+" @@"
- print match[:string.rfind(match, "\n")]
- print rexp.group(6)
- elif rexp.start(6) == rexp.end(6) and minuses == 0 and coherent:
- if orgstartmod:
- orgstart = orgstart + 1
- if newstartmod:
- newstart = newstart + 1
- print "@@ -"+`orgstart-1`+" +"+`newstart-1`+","+`newsize`+" @@"
- print prematch
- print match[:string.rfind(match, "\n")]
- else:
- if orgstartmod:
- orgstart = orgstart + 1
- if newstartmod:
- newstart = newstart + 1
- print "@@ -"+`orgstart-1`+","+`orgsize`+" +"+`newstart-1`+","+`newsize`+" @@"
- if len(prematch):
- print prematch
- print match[:string.rfind(match, "\n")]
- if rexp.start(6) != rexp.end(6):
- print rexp.group(6)
-
- rest = rest[rexp.end(6):]
- oldminuses = minuses + oldminuses
- oldplusses = plusses + oldplusses
- oldoffset = oldoffset + offset + lines #include match()-lines
-
-
- rest = oldrest
+++ /dev/null
-#!/bin/sh
-
-#
-# List unused patches
-#
-
-. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
- echo "Impossible to find my library 'patchfns'."
- echo "Check your install, or go to the right directory"
- exit 1
-}
-
-usage()
-{
- echo "Usage: unused-patches"
- exit 1
-}
-
-if [ $# -ne 0 ]
-then
- usage
-fi
-
-for FILE in $(ls $P/patches)
-do
- BASE=`stripit $FILE`
-# echo checking $BASE in $P/patches
- if grep $FILE $P/series/* >& /dev/null ; then
- true
-# echo $FILE found in $P/series
- else
- if [ $BASE != CVS ]; then
- echo patches/$FILE
- echo txt/$BASE.txt
- echo pc/$BASE.pc
- fi
- fi
-done
-
+++ /dev/null
-#!/bin/sh
-#
-# llite-group.sh : Cluster Manager service script for Lustre
-#
-# This must be named llite-<group>.sh, where group is the device
-# group that is being managed by the cluster manager service.
-#
-
-set -e
-set -vx
-
-[ -f ${LUSTRE_CFG:=/etc/lustre/lustre.cfg} ] && . ${LUSTRE_CFG}
-
-LDAPURL=${LDAPURL:-ldap://localhost}
-CONFIG=${CONFIG:-test23}
-
-LACTIVE=${LACTIVE:-/usr/sbin/lactive}
-LCONF=${LCONF:-/usr/sbin/lconf}
-
-group=`basename $0 .sh| cut -d- -f2`
-confopt="--ldapurl $LDAPURL --config $CONFIG"
-
-[ -z "$group" ] && exit 0
-
-node=`hostname -s`
-
-[ -d ${STATUS_DIR:=/var/lustre} ] || mkdir -p $STATUS_DIR
-
-start() {
- echo -n "Starting $SERVICE: "
- python2 $LACTIVE $confopt --group $group --active $node
- python2 $LCONF -v $confopt
- RETVAL=$?
- echo done
-}
-
-stop() {
- echo -n "Shutting down $SERVICE: "
- python2 $LCONF -v --cleanup --force --failover $confopt
- RETVAL=$?
- echo done
-}
-
-status() {
- RETVAL=0
-}
-
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- status)
- status $SERVICE
- ;;
- *)
- echo "Usage: $0 {start|stop|status}"
- exit 1
-esac
-
-exit $RETVAL
+++ /dev/null
-/Makefile.in
-/*.pyc
+++ /dev/null
-if UTILS
-pymod_SCRIPTS = __init__.py lustredb.py error.py cmdline.py
-endif
-EXTRA_DIST = __init__.py lustredb.py error.py cmdline.py
+++ /dev/null
-__all__ = ["lustredb"]
-
-from lustredb import LustreDB, LustreDB_XML, LustreDB_LDAP
-from error import LconfError, OptionError
-from cmdline import Options
-
-CONFIG_VERSION="2003070801"
+++ /dev/null
-#!/usr/bin/env python
-# GPL HEADER START
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 only,
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License version 2 for more details (a copy is included
-# in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU General Public License
-# version 2 along with this program; If not, see
-# http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
-# copy of GPLv2].
-#
-# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-# GPL HEADER END
-#
-
-#
-# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# This file is part of Lustre, http://www.lustre.org/
-# Lustre is a trademark of Sun Microsystems, Inc.
-#
-# Author: Robert Read <rread@clusterfs.com>
-#
-# Standard the comand line handling for all the python tools.
-
-import sys, getopt, types
-import string
-import error
-
-class Options:
- FLAG = 1
- PARAM = 2
- INTPARAM = 3
- PARAMLIST = 4
- def __init__(self, cmd, remain_help, options):
- self.options = options
- shorts = ""
- longs = []
- options.append(('help,h', "Print this help"))
- for opt in options:
- long = self.long(opt)
- short = self.short(opt)
- if self.type(opt) in (Options.PARAM, Options.INTPARAM,
- Options.PARAMLIST):
- if short: short = short + ':'
- if long:
- long = long + '='
- if string.find(long, '_') >= 0:
- longs.append(string.replace(long, '_', '-'))
- shorts = shorts + short
- longs.append(long)
- self.short_opts = shorts
- self.long_opts = longs
- self.cmd = cmd
- self.remain_help = remain_help
-
- def init_values(self):
- values = {}
- for opt in self.options:
- values[self.key(opt)] = self.default(opt)
- return values
-
- def long(self, option):
- n = string.find(option[0], ',')
- if n < 0: return option[0]
- else: return option[0][0:n]
-
- def key(self, option):
- key = self.long(option)
- return string.replace(key, '-', '_')
-
- def short(self, option):
- n = string.find(option[0], ',')
- if n < 0: return ''
- else: return option[0][n+1:]
-
- def help(self, option):
- return option[1]
-
- def type(self, option):
- if len(option) >= 3:
- return option[2]
- return Options.FLAG
-
- def default(self, option):
- if len(option) >= 4:
- return option[3]
- if self.type(option) == Options.PARAMLIST:
- return []
- return None
-
- def lookup_option(self, key, key_func):
- for opt in self.options:
- if key_func(opt) == key:
- return opt
-
- def lookup_short(self, key):
- return self.lookup_option(key, self.short)
-
- def lookup_long(self, key):
- key = string.replace(key, '-', '_')
- return self.lookup_option(key, self.long)
-
- def handle_opts(self, opts):
- values = self.init_values()
- for o, a in opts:
- if o[0:2] != '--':
- option = self.lookup_short(o[1:])
- else:
- option = self.lookup_long(o[2:])
- if self.type(option) == Options.PARAM:
- val = a
- elif self.type(option) == Options.INTPARAM:
- try:
- val = int(a)
- except ValueError, e:
- raise error.OptionError("option: '%s' expects integer value, got '%s' " % (o,a))
- elif self.type(option) == Options.PARAMLIST:
- val = values[self.key(option)];
- val.append(a)
- else:
- val = 1
- values[self.key(option)] = val
- return values
-
-
- class option_wrapper:
- def __init__(self, values):
- self.__dict__['values'] = values
- def __getattr__(self, name):
- if self.values.has_key(name):
- return self.values[name]
- else:
- raise error.OptionError("bad option name: " + name)
- def __getitem__(self, name):
- if self.values.has_key(name):
- return self.values[name]
- else:
- raise error.OptionError("bad option name: " + name)
- def __setattr__(self, name, value):
- self.values[name] = value
-
- def parse(self, argv):
- try:
- opts, args = getopt.getopt(argv, self.short_opts, self.long_opts)
- values = self.handle_opts(opts)
- if values["help"]:
- self.usage()
- sys.exit(0)
- return self.option_wrapper(values), args
- except getopt.error, e:
- raise error.OptionError(str(e))
-
- def usage(self):
- ret = 'usage: %s [options] %s\n' % (self.cmd, self.remain_help)
- for opt in self.options:
- s = self.short(opt)
- if s: str = "-%s|--%s" % (s,self.long(opt))
- else: str = "--%s" % (self.long(opt),)
- if self.type(opt) in (Options.PARAM, Options.INTPARAM):
- str = "%s <arg>" % (str,)
- help = self.help(opt)
- n = string.find(help, '\n')
- if self.default(opt) != None:
- if n < 0:
- str = "%-15s %s (default=%s)" %(str, help,
- self.default(opt))
- else:
- str = "%-15s %s (default=%s)%s" %(str, help[0:n],
- self.default(opt),
- help[n:])
- else:
- str = "%-15s %s" %(str, help)
- ret = ret + str + "\n"
- print ret
-
-# Test driver
-if __name__ == "__main__":
- cl = Options("test", "xml_file", [
- ('verbose,v', "verbose ", Options.FLAG, 0),
- ('cleanup,d', "shutdown"),
- ('gdb', "Display gdb module file ", Options.FLAG, 0),
- ('device', "device path ", Options.PARAM),
- ('ldapurl', "LDAP server URL ", Options.PARAM),
- ('lustre', "Lustre source dir ", Options.PARAM),
- ('portals', "Portals source dir ", Options.PARAM),
- ('maxlevel', """Specify the maximum level
- Levels are aproximatly like:
- 70 - mountpoint, echo_client, osc, mdc, lov""",
- Options.INTPARAM, 100),
-
- ])
-
- conf, args = cl.parse(sys.argv[1:])
-
- for key in conf.values.keys():
- print "%-10s = %s" % (key, conf.values[key])
+++ /dev/null
-import exceptions
-
-class LconfError (exceptions.Exception):
- def __init__(self, args):
- self.args = args
-
-class OptionError (exceptions.Exception):
- def __init__(self, args):
- self.args = args
-
+++ /dev/null
-import sys, types, string, os
-import re, exceptions
-import xml.dom.minidom
-import Lustre
-
-# ============================================================
-# XML processing and query
-
-class LustreDB:
- caching_enabled = 1
-
- def __init__(self):
- self.lookup_uuid_cache = {}
- self.lookup_name_cache = {}
- self.lookup_class_cache = {}
- self.lookup_val_cache = {}
- self.lookup_refs_cache = {}
- self.lookup_lovtgts_cache = {}
- self.lookup_nid2srv_cache = {}
- self.lookup_activedev_cache = {}
- self.lookup_tgtdev_cache = {}
- self.lookup_group_cache = {}
-
- self.lookup_allrefs_cache = None
- self.lookup_networks_cache = None
-
- def lookup(self, uuid):
- """ lookup returns a new LustreDB instance"""
- if self.caching_enabled and self.lookup_uuid_cache.has_key(uuid):
- res = self.lookup_uuid_cache[uuid]
- else:
- res = self._lookup_by_uuid(uuid)
- if self.caching_enabled:
- self.lookup_uuid_cache[uuid] = res
- return res
-
- def lookup_name(self, name, class_name = ""):
- """ lookup returns a new LustreDB instance"""
- if self.caching_enabled and self.lookup_name_cache.has_key((name, class_name)):
- res = self.lookup_name_cache[(name, class_name)]
- else:
- res = self._lookup_by_name(name, class_name)
- if self.caching_enabled:
- self.lookup_name_cache[(name, class_name)] = res
- return res
-
- def lookup_class(self, class_name):
- """ lookup returns a new LustreDB instance"""
- if self.caching_enabled and self.lookup_class_cache.has_key(class_name):
- res = self.lookup_class_cache[class_name]
- else:
- res = self._lookup_by_class(class_name)
- if self.caching_enabled:
- self.lookup_class_cache[class_name] = res
- return res
-
- def get_val(self, tag, default=None):
- if self.caching_enabled and self.lookup_class_cache.has_key(tag):
- v = self.lookup_val_cache[tag]
- else:
- v = self._get_val(tag)
- if self.caching_enabled:
- self.lookup_val_cache[tag] = v
- if v:
- return v
- if default != None:
- return default
- return None
-
- def get_class(self):
- return self._get_class()
-
- def get_val_int(self, tag, default=0):
- str = self.get_val(tag)
- try:
- if str:
- return int(str)
- return default
- except ValueError:
- raise Lustre.LconfError("text value is not integer: " + str)
-
- def get_first_ref(self, tag):
- """ Get the first uuidref of the type TAG. Only
- one is expected. Returns the uuid."""
- uuids = self.get_refs(tag)
- if len(uuids) > 0:
- return uuids[0]
- return None
-
- def get_refs(self, tag):
- """ Get all the refs of type TAG. Returns list of uuids. """
- if self.caching_enabled and self.lookup_refs_cache.has_key(tag):
- uuids = self.lookup_refs_cache[tag]
- else:
- uuids = self._get_refs(tag)
- if self.caching_enabled:
- self.lookup_refs_cache[tag] = uuids
- return uuids
-
- def get_all_refs(self):
- """ Get all the refs. Returns list of uuids. """
- if self.caching_enabled and self.lookup_allrefs_cache:
- uuids = self.lookup_allrefs_cache
- else:
- uuids = self._get_all_refs()
- if self.caching_enabled:
- self.lookup_allrefs_cache = uuids
- return uuids
-
- def get_lov_tgts(self, tag):
- """ Returns list of lov tgts. """
- if self.caching_enabled and self.lookup_lovtgts_cache.has_key(tag):
- tgts = self.lookup_lovtgts_cache[tag]
- else:
- tgts = self._get_lov_tgts(tag)
- if self.caching_enabled:
- self.lookup_lovtgts_cache[tag] = tgts
- return tgts
-
- def nid2server(self, nid, net_type, cluster_id):
- if self.caching_enabled and self.lookup_nid2srv_cache.has_key((nid, net_type, cluster_id)):
- res = self.lookup_nid2srv_cache[(nid, net_type, cluster_id)]
- else:
- netlist = self.lookup_class('network')
- for net_db in netlist:
- if (net_db.get_val('nid') == nid and
- net_db.get_val('nettype') == net_type and
- net_db.get_val('clusterid') == cluster_id):
- res = net_db
- break
- if self.caching_enabled:
- self.lookup_nid2srv_cache[(nid, net_type, cluster_id)] = res
- return res
-
- # Find the target_device for target on a node
- # node->profiles->device_refs->target
- def get_node_tgt_dev(self, node_name, target_uuid):
- node_db = self.lookup_name(node_name)
- if not node_db:
- return None
- return node_db.get_tgt_dev(target_uuid)
-
- # get all network uuids for this node
- def get_networks(self):
- if self.caching_enabled and self.lookup_networks_cache:
- ret = self.lookup_networks_cache
- else:
- ret = []
- prof_list = self.get_refs('profile')
- for prof_uuid in prof_list:
- prof_db = self.lookup(prof_uuid)
- net_list = prof_db.get_refs('network')
- for net_uuid in net_list:
- ret.append(net_uuid)
- if self.caching_enabled:
- self.lookup_networks_cache = ret
- return ret
-
- def get_active_dev(self, tgtuuid):
- if self.caching_enabled and self.lookup_activedev_cache.has_key(tgtuuid):
- tgt_dev_uuid = self.lookup_activedev_cache[tgtuuid]
- else:
- tgt = self.lookup(tgtuuid)
- tgt_dev_uuid = tgt.get_first_ref('active')
- if self.caching_enabled:
- self.lookup_activedev_cache[tgtuuid] = tgt_dev_uuid
- return tgt_dev_uuid
-
- def get_tgt_dev(self, tgtuuid):
- if self.caching_enabled and self.lookup_tgtdev_cache.has_key(tgtuuid):
- res = self.lookup_tgtdev_cache[tgtuuid]
- else:
- prof_list = self.get_refs('profile')
- res = None
- for prof_uuid in prof_list:
- prof_db = self.lookup(prof_uuid)
- if not prof_db:
- panic("profile:", profile, "not found.")
- for ref_class, ref_uuid in prof_db.get_all_refs():
- if ref_class in ('osd', 'mdsdev'):
- devdb = self.lookup(ref_uuid)
- uuid = devdb.get_first_ref('target')
- if tgtuuid == uuid:
- res = ref_uuid
- break
- if not res is None:
- break
- if self.caching_enabled:
- self.lookup_tgtdev_cache[tgtuuid] = res
- return res
-
- def get_group(self, group):
- if self.caching_enabled and self.lookup_group_cache.has_key(group):
- ret = self.lookup_group_cache[group]
- else:
- ret = []
- devs = self.lookup_class('mds')
- for tgt in devs:
- if tgt.get_val('group', tgt.get_val('name')) == group:
- ret.append(tgt.getUUID())
- devs = self.lookup_class('ost')
- for tgt in devs:
- if tgt.get_val('group', tgt.get_val('name')) == group:
- ret.append(tgt.getUUID())
- if self.caching_enabled:
- self.lookup_group_cache[group] = ret
- return ret
-
- # Change the current active device for a target
- def update_active(self, tgtuuid, new_uuid):
- self._update_active(tgtuuid, new_uuid)
-
- def get_version(self):
- return self.get_val('version')
-
- def get_mtime(self):
- return self.get_val('mtime')
-
-class LustreDB_XML(LustreDB):
- def __init__(self, dom, root_node):
- LustreDB.__init__(self)
-
- # init xmlfile
- self.dom_node = dom
- self.root_node = root_node
-
- def close(self):
- # do nothing
- return None
-
- def xmltext(self, dom_node, tag):
- list = dom_node.getElementsByTagName(tag)
- if len(list) > 0:
- dom_node = list[0]
- dom_node.normalize()
- if dom_node.firstChild:
- txt = string.strip(dom_node.firstChild.data)
- if txt:
- return txt
-
- def xmlattr(self, dom_node, attr):
- return dom_node.getAttribute(attr)
-
- def _get_val(self, tag):
- """a value could be an attribute of the current node
- or the text value in a child node"""
- ret = self.xmlattr(self.dom_node, tag)
- if not ret:
- ret = self.xmltext(self.dom_node, tag)
- return ret
-
- def _get_class(self):
- return self.dom_node.nodeName
-
- def get_ref_type(self, ref_tag):
- res = string.split(ref_tag, '_')
- return res[0]
-
- #
- # [(ref_class, ref_uuid),]
- def _get_all_refs(self):
- list = []
- for n in self.dom_node.childNodes:
- if n.nodeType == n.ELEMENT_NODE:
- ref_uuid = self.xml_get_ref(n)
- ref_class = self.get_ref_type(n.nodeName)
- list.append((ref_class, ref_uuid))
-
- list.sort()
- return list
-
- def _get_refs(self, tag):
- """ Get all the refs of type TAG. Returns list of uuids. """
- uuids = []
- refname = '%s_ref' % tag
- reflist = self.dom_node.getElementsByTagName(refname)
- for r in reflist:
- uuids.append(self.xml_get_ref(r))
- return uuids
-
- def _get_lov_tgts(self, tag):
- """ Get all the refs of type TAG. Returns list of lov_tgts. """
- tgts = []
- tgtlist = self.dom_node.getElementsByTagName(tag)
- for tgt in tgtlist:
- uuidref = tgt.getAttribute('uuidref')
- index = tgt.getAttribute('index')
- generation = tgt.getAttribute('generation')
- active = int(tgt.getAttribute('active'))
- tgts.append((uuidref, index, generation, active))
- return tgts
-
- def xmllookup_by_uuid(self, dom_node, uuid):
- for n in dom_node.childNodes:
- if n.nodeType == n.ELEMENT_NODE:
- if self.xml_get_uuid(n) == uuid:
- return n
- else:
- n = self.xmllookup_by_uuid(n, uuid)
- if n: return n
- return None
-
- def _lookup_by_uuid(self, uuid):
- dom = self. xmllookup_by_uuid(self.root_node, uuid)
- if dom:
- return LustreDB_XML(dom, self.root_node)
-
- def xmllookup_by_name(self, dom_node, name):
- for n in dom_node.childNodes:
- if n.nodeType == n.ELEMENT_NODE:
- if self.xml_get_name(n) == name:
- return n
- else:
- n = self.xmllookup_by_name(n, name)
- if n: return n
- return None
-
- def _lookup_by_name(self, name, class_name):
- dom = self.xmllookup_by_name(self.root_node, name)
- if dom:
- return LustreDB_XML(dom, self.root_node)
-
- def xmllookup_by_class(self, dom_node, class_name):
- return dom_node.getElementsByTagName(class_name)
-
- def _lookup_by_class(self, class_name):
- ret = []
- domlist = self.xmllookup_by_class(self.root_node, class_name)
- for node in domlist:
- ret.append(LustreDB_XML(node, self.root_node))
- return ret
-
- def xml_get_name(self, n):
- return n.getAttribute('name')
-
- def getName(self):
- return self.xml_get_name(self.dom_node)
-
- def xml_get_ref(self, n):
- return n.getAttribute('uuidref')
-
- def xml_get_uuid(self, dom_node):
- return dom_node.getAttribute('uuid')
-
- def getUUID(self):
- return self.xml_get_uuid(self.dom_node)
-
- # Convert routes from the router to a route that will be used
- # on the local system. The network type and gw are changed to the
- # interface on the router the local system will connect to.
- def get_local_routes(self, type, gw):
- """ Return the routes as a list of tuples of the form:
- [(type, gw, lo, hi),]"""
- res = []
- tbl = self.dom_node.getElementsByTagName('routetbl')
- for t in tbl:
- routes = t.getElementsByTagName('route')
- for r in routes:
- net_type = self.xmlattr(r, 'type')
- if type != net_type:
- lo = self.xmlattr(r, 'lo')
- hi = self.xmlattr(r, 'hi')
- tgt_cluster_id = self.xmlattr(r, 'tgtclusterid')
- res.append((type, gw, tgt_cluster_id, lo, hi))
- return res
-
- def get_route_tbl(self):
- ret = []
- for r in self.dom_node.getElementsByTagName('route'):
- net_type = self.xmlattr(r, 'type')
- gw = self.xmlattr(r, 'gw')
- gw_cluster_id = self.xmlattr(r, 'gwclusterid')
- tgt_cluster_id = self.xmlattr(r, 'tgtclusterid')
- lo = self.xmlattr(r, 'lo')
- hi = self.xmlattr(r, 'hi')
- ret.append((net_type, gw, gw_cluster_id, tgt_cluster_id, lo, hi))
- return ret
-
- def get_hostaddr(self):
- ret = []
- list = self.dom_node.getElementsByTagName('hostaddr')
- for node in list:
- ret.append(node.firstChild.data)
- return ret
-
- def _update_active(self, tgt, new):
- raise Lustre.LconfError("updates not implemented for XML")
-
-# ================================================================
-# LDAP Support
-class LustreDB_LDAP(LustreDB):
- def __init__(self, name, attrs,
- base = "fs=lustre",
- parent = None,
- url = "ldap://localhost",
- user = "cn=Manager, fs=lustre",
- pw = ""
- ):
- LustreDB.__init__(self)
-
- self._name = name
- self._attrs = attrs
- self._base = base
- self._parent = parent
- self._url = url
- self._user = user
- self._pw = pw
- if parent:
- self.l = parent.l
- self._base = parent._base
- else:
- self.open()
-
- def open(self):
- import ldap
- try:
- self.l = ldap.initialize(self._url)
- # Set LDAP protocol version used
- self.l.protocol_version=ldap.VERSION3
- # user and pw only needed if modifying db
- self.l.bind_s(self._user, self._pw, ldap.AUTH_SIMPLE);
- except ldap.LDAPError, e:
- raise Lustre.LconfError('Unable to connect to ldap server:' + self._url)
-
- try:
- self._name, self._attrs = self.l.search_s(self._base,
- ldap.SCOPE_BASE)[0]
- except ldap.LDAPError, e:
- raise Lustre.LconfError("no config found in ldap: %s"
- % (self._base,))
- def close(self):
- self.l.unbind_s()
-
- def ldap_search(self, filter):
- """Return list of uuids matching the filter."""
- import ldap
- dn = self._base
- ret = []
- uuids = []
- try:
- for name, attrs in self.l.search_s(dn, ldap.SCOPE_ONELEVEL,
- filter, ["uuid"]):
- for v in attrs['uuid']:
- uuids.append(v)
- except ldap.NO_SUCH_OBJECT, e:
- pass
- except ldap.LDAPError, e:
- print e # FIXME: die here?
- if len(uuids) > 0:
- for uuid in uuids:
- ret.append(self._lookup_by_uuid(uuid))
- return ret
-
- def _lookup_by_name(self, name, class_name):
- list = self.ldap_search("lustreName=%s" %(name))
- if len(list) == 1:
- return list[0]
- return None
-
- def _lookup_by_class(self, class_name):
- return self.ldap_search("objectclass=%s" %(string.upper(class_name)))
-
- def _lookup_by_uuid(self, uuid):
- import ldap
- dn = "uuid=%s,%s" % (uuid, self._base)
- ret = None
- try:
- for name, attrs in self.l.search_s(dn, ldap.SCOPE_BASE,
- "objectclass=*"):
- ret = LustreDB_LDAP(name, attrs, parent = self)
-
- except ldap.NO_SUCH_OBJECT, e:
- pass # just return empty list
- except ldap.LDAPError, e:
- print e # FIXME: die here?
- return ret
-
-
- def _get_val(self, k):
- ret = None
- if k == 'name':
- k = 'lustreName'
- if self._attrs.has_key(k):
- v = self._attrs[k]
- if type(v) == types.ListType:
- ret = str(v[0])
- else:
- ret = str(v)
- return ret
-
- def _get_class(self):
- return string.lower(self._attrs['objectClass'][0])
-
- def get_ref_type(self, ref_tag):
- return ref_tag[:-3]
-
- def _get_lov_tgts(self, tag):
- """ Get all the refs of type TAG. Returns list of lov_tgts. """
- tgts = []
- return tgts
-
- #
- # [(ref_class, ref_uuid),]
- def _get_all_refs(self):
- reflist = []
- for k in self._attrs.keys():
- if re.search('.*Ref', k):
- for uuid in self._attrs[k]:
- ref_class = self.get_ref_type(k)
- reflist.append((ref_class, uuid))
- return reflist
-
- def _get_refs(self, tag):
- """ Get all the refs of type TAG. Returns list of uuids. """
- refname = '%sRef' % tag
-
- if self._attrs.has_key(refname):
- return self._attrs[refname]
-
- reflist = []
- for obj in self._lookup_by_class("*"):
- if obj._attrs.has_key(refname):
- reflist.extend(obj._attrs[refname])
-
- return reflist
-
- def getName(self):
- return self._get_val('lustreName')
-
- def getUUID(self):
- return self._get_val('uuid')
-
- def get_route_tbl(self):
- return []
-
- def get_hostaddr(self):
- return self._get_refs('hostaddr')
-
- def _update_active(self, tgtuuid, newuuid):
- """Return list of uuids matching the filter."""
- import ldap
- dn = "uuid=%s,%s" %(tgtuuid, self._base)
- ret = []
- uuids = []
- try:
- self.l.modify_s(dn, [(ldap.MOD_REPLACE, "activeRef", newuuid)])
- except ldap.NO_SUCH_OBJECT, e:
- print e
- except ldap.LDAPError, e:
- print e # FIXME: die here?
- return