]> git.mxchange.org Git - flightgear.git/commitdiff
fg-check: speedup, minor fixes, cleanup
authormfranz <mfranz>
Thu, 8 Mar 2007 16:45:48 +0000 (16:45 +0000)
committermfranz <mfranz>
Thu, 8 Mar 2007 16:45:48 +0000 (16:45 +0000)
fg-submit:
- takes alternative optional basename (used instead of dirname)
- calls optional user defined fg-upload script at the end (example on top)
- minor fixes, different color for changed binary files
- cleanup, improved documentation

scripts/tools/fg-check
scripts/tools/fg-submit

index 101f66da9fbabac617ebd880ebb16920d16fcf6d..138d7585aa52256b2924d97380b162ec3ca76d9b 100755 (executable)
@@ -24,16 +24,16 @@ LOG "checking for spaces in filenames ..."
 find .|grep " "|while read i; do RESULT "$i"; done
 
 
-LOG "checking for upper-case extensions ..."       # except *.TXT
+LOG "checking for upper-case extensions ..."
 find .|while read i; do
-       case "$i" in .|..|CVS/*|*/CVS/*|*.Opt|*.README|*.Po) continue ;; esac
+       case "$i" in .|..|CVS/*|*/CVS/*|*.Opt|*.README|*.Po|*.TXT) continue ;; esac
        base=${i/#.*\/}
        ext=${base/#*./}
        [ "$base" == "$ext" ] && continue          # has no extension
-       ext=$(echo $ext|sed -e 's,[^A-Za-z],,'g)
-       [ -z "$ext" ] && continue                  # only non-letters
+       ext=${ext//[^a-zA-Z]/}
+       [ "$ext" ] || continue                     # only non-letters
        lcext=$(echo $ext|sed -e 's,\(.*\),\L\1,')
-       [ "$ext" != "$lcext" -a "$lcext" != "txt" ] && RESULT "$i"
+       [ "$ext" != "$lcext" ] && RESULT "$i"
 done
 
 
@@ -52,7 +52,7 @@ find . -iname \*.rgb -o -iname \*.rgba|while read i; do
        if file "$i"|grep -v RLE >/dev/null; then
                new=$TMP/sgi.rgb
                convert "$i" -compress RLE sgi:$new
-               [ "$RLE" ] && $RLE $new 2>/dev/null
+               [ -x "$RLE" ] && $RLE $new 2>/dev/null
                perl -e '
                        my $file = shift;
                        my $old = -s $file;
@@ -66,7 +66,7 @@ find . -iname \*.rgb -o -iname \*.rgba|while read i; do
 done
 
 
-if [ "$AC3D_SCAN" ]; then
+if [ -x "$AC3D_SCAN" ]; then
        LOG "checking for AC3D sanity ..."
        find . -iname \*.ac|while read i; do
                case "$i" in configure.ac|*/configure.ac) continue ;; esac
@@ -78,7 +78,7 @@ fi
 
 LOG "checking for XML syntax ..."
 find . -name \*.xml|while read i; do
-       xmllint $i >/dev/null || RESULT "... min file \e[36m$i\e[m"
+       xmllint $i >/dev/null || RESULT "... in file \e[36m$i\e[m"
 done
 
 
index af740a23e483310ffb2aeb2fb62f100e9ee36bbe..f054403eb97289f812cf97528a002061d5452bd3 100755 (executable)
@@ -1,24 +1,69 @@
 #!/bin/bash
 #
-# This script called in a CVS directory generates an archive in that
-# same directory, which contains all locally added new files (except
-# those rejected by the script) and a diff with all local changes.
-# This archive can then be offered to one of the CVS maintainers for
-# committing.
+# This script called in a CVS directory compares local files with
+# the repository, and prepares an update package containing all
+# changes and new files for submission to a CVS maintainer. If there
+# are only changes in text files, then a compressed unified diff is
+# made (foo.diff.bz2). If there are also changed binary or new files,
+# then an archive is made instead (foo.tar.bz2). The base name ("foo")
+# can be given as command line argument. Otherwise the directory name
+# is used. The script also leaves a diff in uncompressed/unpackaged
+# form. This is only for developer convenience -- for a quick check
+# of the diff correctness. It is not to be submitted. The script will
+# not overwrite any file, but rather rename conflicting files.
 #
-# Usage:
-#         $ cd $FG_ROOT/Aircraft/foo
-#         $ fg-submit      # generates foo.tar.bz2 and foo.diff
+# Usage:  fg-submit [<basename>]
 #
-# The archive contains a copy of the diff, so the extra diff file
-# shouldn't be submitted. It's only left for (in?)convenience.
+# Example:
+#     $ cd $FG_ROOT/Aircraft/bo105
+#     $ fg-submit                # -> bo105.diff.bz2 or bo105.tar.bz2
+#
+#     $ fg-submit update         # -> update.diff.bz2 or update.tar.bz2
+#
+#
+# Spaces in the basename are replaced with "%20". People who prefer
+# to have the date in the archive name can conveniently achieve this
+# by defining a shell alias in ~/.bashrc:
+#
+#     alias submit='fg-submit "${PWD/#*\/}-$(date +%Y-%m-%d)"'
+#
+#
+# If the script finds an application named "fg-upload", then it calls
+# this at the end with three arguments:
+#
+#     $1 ... working directory ($PWD)
+#     $2 ... archive or compressed diff for submission
+#     $3 ... accessory diff, *NOT* for submission!
+#
+# $2 and $3 are guaranteed not to contain spaces, only $1 is guaranteed
+# to actually exist. Such as script can be used to upload the file to an
+# ftp-/webserver, and/or to remove one or both files. Example using
+# KDE's kfmclient for upload (alternatives: ncftpput, gnomevfs-copy, ...):
+#
+#     $ cat ~/bin/fg-upload
+#     #!/bin/bash
+#     echo "uploading $2"
+#     if kfmclient copy $2 ftp://user:password@server.com; then
+#             echo "deleting $2 $3"
+#             rm -rf $2 $3
+#
+#             echo "Done.  URL: ftp://server.com/$2"
+#     else
+#             echo "arghh ... HELP! HELP!"
+#     fi
+
 
 SELF=${0/#*\/}
-AIRCRAFT=${PWD/#*\/}
+DIR=${PWD/#*\/}
+BASE=${1:-$DIR}
+BASE=${BASE// /%20}
+
+CVS=/usr/bin/cvs                 # avoid colorcvs wrapper from
+[ -x $CVS ] || CVS=cvs           # http://www.hakubi.us/colorcvs/
+UPLOAD=$(which fg-upload 2>/dev/null)
 
-CVS=/usr/bin/cvs
-ARCHIVE=$AIRCRAFT.tar.bz2
-DIFF=$AIRCRAFT.diff
+ARCHIVE=$BASE.tar.bz2
+DIFF=$BASE.diff
 CDIFF=$DIFF.bz2
 
 
@@ -39,10 +84,10 @@ function diffstat {
                                return
                        }
                        if (bin) {
-                               line("\033[m. . . .", "\033[mbinary", "\033[m. . . .", file)
+                               print "\t. . . . binary  . . . . \033[36m"file"\033[m"
                        } else {
                                line(a, r, c, file)
-                               at += a; rt += r; ct += c;
+                               at += a; rt += r; ct += c
                        }
                        a = r = c = 0
                }
@@ -50,12 +95,12 @@ function diffstat {
                        print "\tadded---removed-changed----------------------------------------"
                        a = r = c = at = rt = ct = n = bin = 0
                }
-               /^Index: / { dofile(); scan = bin = 0; file = $2; n += 1; next }
+               /^Index: / { dofile(); scan = bin = 0; file = $2; n++; next }
                /^@@/      { scan = 1; next }
-               /^Binary/  { if (!scan) { bin = 1 } next }
-               /^+/       { if (scan) { a += 1 } next }
-               /^-/       { if (scan) { r += 1 } next }
-               /^!/       { if (scan) { c += 1 } next }
+               /^Binary/  { if (!scan) bin = 1; next }
+               /^+/       { if (scan) a++; next }
+               /^-/       { if (scan) r++; next }
+               /^!/       { if (scan) c++; next }
                END        {
                        dofile()
                        print "\t----------------------------------------total------------------"
@@ -66,14 +111,14 @@ function diffstat {
 
 
 # create temporary dir that's automatcally removed on exit
-TMP=$(mktemp -d -t $SELF.$AIRCRAFT.XXX) || (echo "$0: can't create temporary dir"; exit 1)
+TMP=$(mktemp -d -t $SELF.$BASE.XXX) || (echo "$0: can't create temporary dir"; exit 1)
 trap "rm -rf $TMP" 0 1 2 3 13 15
 
 
-# move older archive or diff files out of the way
-[ -f $DIFF ] && mv $DIFF $(mktemp $DIFF.X)
-[ -f $CDIFF ] && mv $CDIFF $(mktemp $CDIFF.X)
-[ -f $ARCHIVE ] && mv $ARCHIVE $(mktemp $ARCHIVE.X)
+# move old files out of the way
+for i in $DIFF $CDIFF $ARCHIVE; do
+       [ -f $i ] && mv $i $(mktemp $i.X)
+done
 
 
 LOG "updating and checking for new files ..."
@@ -113,6 +158,7 @@ if [ -f $TMP/files ]; then
                CHANGED "$i"
        done
 fi
+
 grep "^? " $TMP/up|while read i; do
        find ${i#? } -type f >>$TMP/check
 done
@@ -153,15 +199,20 @@ if ! [ -f $TMP/files ]; then
 fi
 
 echo
-numfiles=$(awk '//{n+=1}END{print n}' <$TMP/files)
+numfiles=$(awk '//{n++}END{print n}' <$TMP/files)
 if [ -f $DIFF -a $numfiles == 1 ]; then
        LOG "only changed non-binary files found"
        LOG "creating compressed diff \e[1;37;40m$CDIFF\e[m\e[35m ..."
        bzip2 -k $DIFF
+       RESULT=$CDIFF
 else
        LOG "changed and/or new files found"
        LOG "creating archive \e[1;37;40m$ARCHIVE\e[m\e[35m ..."
        tar -cjf $ARCHIVE --files-from $TMP/files
+       RESULT=$ARCHIVE
 fi
+
+[ -x "$UPLOAD" -a -f $RESULT ] && $UPLOAD "$PWD" $RESULT $DIFF
+
 exit 0