before a day passes with no commits at all, better have some fg-submit stuff :-)
- drop the DEFAULT keyword in .fg-submit configuration files. That was a silly idea. The default rules are now always appended. One can still bypass them by ALLOWing or DENYing anything before, for example, by using DENY *, or ALLOW *. - fix a typo that broke ~/.fg-submitrc loading (but ~/.fg-submit worked anyway) - some minor improvments, cleanup and all that
This commit is contained in:
parent
5b683d1c8b
commit
f39ad54d93
1 changed files with 64 additions and 58 deletions
|
@ -39,7 +39,7 @@
|
||||||
# $2 ... accessory diff, *NOT* for submission!
|
# $2 ... accessory diff, *NOT* for submission!
|
||||||
#
|
#
|
||||||
# $1 and $2 are guaranteed not to contain spaces, only $1 is guaranteed
|
# $1 and $2 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
|
# to actually exist. Such a script can be used to upload the file to an
|
||||||
# ftp-/webserver, and/or to remove one or both files. Example using
|
# ftp-/webserver, and/or to remove one or both files. Example using
|
||||||
# KDE's kfmclient for upload (alternatives: ncftpput, gnomevfs-copy, wput):
|
# KDE's kfmclient for upload (alternatives: ncftpput, gnomevfs-copy, wput):
|
||||||
#
|
#
|
||||||
|
@ -70,7 +70,6 @@
|
||||||
# ALLOW <pattern-list> ... accept & report matching file
|
# ALLOW <pattern-list> ... accept & report matching file
|
||||||
# DENY <pattern-list> ... reject & report matching file
|
# DENY <pattern-list> ... reject & report matching file
|
||||||
# IGNORE <pattern-list> ... silently reject matching file
|
# IGNORE <pattern-list> ... silently reject matching file
|
||||||
# DEFAULT ... adds default rules
|
|
||||||
#
|
#
|
||||||
# A <pattern-list> is a space-separated list of shell pattern.
|
# A <pattern-list> is a space-separated list of shell pattern.
|
||||||
# It may also be empty, in which case it has no effect. Examples:
|
# It may also be empty, in which case it has no effect. Examples:
|
||||||
|
@ -78,27 +77,25 @@
|
||||||
# DENY test.blend
|
# DENY test.blend
|
||||||
# ALLOW *.xcf *.blend
|
# ALLOW *.xcf *.blend
|
||||||
#
|
#
|
||||||
# A config file that only contains the keyword DEFAULT causes the
|
# The list of pattern is checked in the same order in which it was
|
||||||
# same behavior as no config file at all. A config file without
|
# built. The first match causes a file to be accepted or rejected.
|
||||||
# DEFAULT drops the built-in default rules (with the exception of
|
# Further matches are not considered. Comments using the
|
||||||
# a few very basic ones, such as rejection of CVS files). Comments
|
# hash character '#' are allowed and ignored.
|
||||||
# using the hash character '#' are allowed and ignored.
|
#
|
||||||
|
# Some default rules are always added at the end. If you want to
|
||||||
|
# bypass them, then just add "ALLOW *" or "DENY *" at the end of
|
||||||
|
# your configuration, and no file will ever reach the default rules.
|
||||||
#
|
#
|
||||||
# The list of pattern is checked in the same in order in which it
|
|
||||||
# is built. The first match causes a file to be accepted or rejected.
|
|
||||||
# Further matches are not considered.
|
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
#
|
#
|
||||||
# DENY test.xcf # throw out the test graphic, but ...
|
# DENY test.xcf # throw out the test image, but ...
|
||||||
# ALLOW *.xcf # ... allow all other GIMP graphics (the following
|
# ALLOW *.xcf # ... allow all other GIMP images (the default
|
||||||
# # DEFAULT keyword throws them out otherwise)
|
# # rules would otherwise throw them out)
|
||||||
#
|
#
|
||||||
# DEFAULT # insert the default rules here
|
# ALLOW g.old # add this silly file, but ...
|
||||||
#
|
# IGNORE *.old # throw out all other "old" files (and don't
|
||||||
# ALLOW g.old # add this silly file :-)
|
# # report that to the terminal)
|
||||||
# IGNORE *.old # throw out the old files (and don't report
|
|
||||||
# # that to the terminal)
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# .fg-submit configuration files are "sourced" bash scripts, the
|
# .fg-submit configuration files are "sourced" bash scripts, the
|
||||||
|
@ -112,7 +109,6 @@
|
||||||
# */bo105*) DENY *.osg; ALLOW livery.xcf ;;
|
# */bo105*) DENY *.osg; ALLOW livery.xcf ;;
|
||||||
# */ufo*) DENY *.tiff ;;
|
# */ufo*) DENY *.tiff ;;
|
||||||
# esac
|
# esac
|
||||||
# DEFAULT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,13 +132,13 @@ ARCHIVE=$BASE.tar.bz2
|
||||||
DIFF=$BASE.diff
|
DIFF=$BASE.diff
|
||||||
CDIFF=$DIFF.bz2
|
CDIFF=$DIFF.bz2
|
||||||
|
|
||||||
# these rules are always prepended (the leading ! makes silent rejects)
|
# these rules are always prepended; the first letter decides if the
|
||||||
|
# rule accepts (+), rejects (-), or ignores (!) a matching file.
|
||||||
PREFIX_RULES="
|
PREFIX_RULES="
|
||||||
!$DIFF* !$CDIFF* !$ARCHIVE*
|
!$DIFF* !$CDIFF* !$ARCHIVE*
|
||||||
!CVS/* !*/CVS/*
|
!CVS/* !*/CVS/*
|
||||||
"
|
"
|
||||||
# these rules are used when no other rules are specified,
|
# these rules are always appended
|
||||||
# and wherever the DEFAULT keyword is used
|
|
||||||
DEFAULT_RULES="
|
DEFAULT_RULES="
|
||||||
+.cvsignore +*/.cvsignore
|
+.cvsignore +*/.cvsignore
|
||||||
-*~ -*. -*.bak -*.orig
|
-*~ -*. -*.bak -*.orig
|
||||||
|
@ -151,14 +147,13 @@ DEFAULT_RULES="
|
||||||
-*.blend -*.blend[0-9] -*blend[0-9][0-9] -*.blend[0-9][0-9][0-9]
|
-*.blend -*.blend[0-9] -*blend[0-9][0-9] -*.blend[0-9][0-9][0-9]
|
||||||
-*.gz -*.tgz -*.bz2 -*.zip -*.tar.gz* -*.tar.bz2*
|
-*.gz -*.tgz -*.bz2 -*.zip -*.tar.gz* -*.tar.bz2*
|
||||||
"
|
"
|
||||||
# these rules are always appended: ignore all hidden files that
|
|
||||||
# weren't explicitly allowed so far, and accept all the rest
|
|
||||||
POSTFIX_RULES="
|
POSTFIX_RULES="
|
||||||
!.* !*/.*
|
!.* !*/.*
|
||||||
+*
|
+*
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ERROR { echo -e "\e[31;1m$*\e[m"; }
|
function ERROR { echo -e "\e[31;1m$*\e[m"; }
|
||||||
function LOG { echo -e "\e[35m$*\e[m"; }
|
function LOG { echo -e "\e[35m$*\e[m"; }
|
||||||
function NEW { echo -e "\e[32m\t+ $*\e[m"; }
|
function NEW { echo -e "\e[32m\t+ $*\e[m"; }
|
||||||
|
@ -191,7 +186,7 @@ function diffstat {
|
||||||
/^Index: / { dofile(); scan = bin = 0; file = $2; n++; next }
|
/^Index: / { dofile(); scan = bin = 0; file = $2; n++; next }
|
||||||
/^@@/ { scan = 1; next }
|
/^@@/ { scan = 1; next }
|
||||||
/^Binary/ { if (!scan) bin = 1; next }
|
/^Binary/ { if (!scan) bin = 1; next }
|
||||||
/^\+/ { if (scan) a++; next }
|
/^\+/ { if (scan) a++; next }
|
||||||
/^-/ { if (scan) r++; next }
|
/^-/ { if (scan) r++; next }
|
||||||
/^!/ { if (scan) c++; next }
|
/^!/ { if (scan) c++; next }
|
||||||
END {
|
END {
|
||||||
|
@ -203,52 +198,58 @@ function diffstat {
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_filename {
|
function backup_filename {
|
||||||
i=1
|
for ((i = 1; 1; i = i + 1)); do
|
||||||
while true; do
|
|
||||||
name=$1.$i
|
name=$1.$i
|
||||||
if ! [ -a "$name" ]; then
|
if ! [ -a "$name" ]; then
|
||||||
touch $name
|
touch $name
|
||||||
echo $name
|
echo $name
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set up accept/reject rules
|
# set up accept/reject rules
|
||||||
function DEFAULT { RULES="$RULES $DEFAULT_RULES"; }
|
|
||||||
function ALLOW { for i in $*; do RULES="$RULES +$i"; done }
|
function ALLOW { for i in $*; do RULES="$RULES +$i"; done }
|
||||||
function DENY { for i in $*; do RULES="$RULES -$i"; done }
|
function DENY { for i in $*; do RULES="$RULES -$i"; done }
|
||||||
function IGNORE { for i in $*; do RULES="$RULES !$i"; done }
|
function IGNORE { for i in $*; do RULES="$RULES !$i"; done }
|
||||||
|
|
||||||
RULES=
|
|
||||||
HERE=$PWD
|
|
||||||
while true; do
|
|
||||||
if [ -f $CONFIG_FILE ]; then
|
|
||||||
CONFIG="$PWD/$CONFIG_FILE"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
[ "$PWD" == "/" ] && break
|
|
||||||
done
|
|
||||||
cd "$HERE"
|
|
||||||
|
|
||||||
if [ "$CONFIG" ]; then
|
function search_config {
|
||||||
DEBUG "reading config $CONFIG"
|
file="$1/$CONFIG_FILE"
|
||||||
|
DEBUG "checking for config file $file"
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
CONFIG="$file"
|
||||||
|
return 0
|
||||||
|
elif [ "$1" ]; then
|
||||||
|
search_config ${1%/${1/#*\/}} # parent dir
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RULES=
|
||||||
|
if search_config "$PWD"; then
|
||||||
|
LOG "loading config file $CONFIG"
|
||||||
source "$CONFIG"
|
source "$CONFIG"
|
||||||
elif [ -f ~/$CONFIG_FILE ]; then
|
elif [ -f ~/$CONFIG_FILE ]; then
|
||||||
DEBUG "reading config ~/$CONFIG_FILE"
|
DEBUG "loading config file $CONFIG"
|
||||||
source ~/$CONFIG_FILE
|
source ~/$CONFIG_FILE
|
||||||
elif [ -f ~/${CONFIG_FILE}rc ]; then
|
elif [ -f ~/${CONFIG_FILE}rc ]; then
|
||||||
DEBUG "reading config ~/${CONFIG_FILE}rc"
|
DEBUG "loading config file $CONFIG"
|
||||||
source ~/$CONFIG_FILE
|
source ~/${CONFIG_FILE}rc
|
||||||
else
|
|
||||||
DEBUG "no config file found; using default rules"
|
|
||||||
RULES="$RULES $DEFAULT_RULES"
|
|
||||||
fi
|
fi
|
||||||
RULES="$PREFIX_RULES $RULES $POSTFIX_RULES"
|
RULES="$PREFIX_RULES $RULES $DEFAULT_RULES $POSTFIX_RULES"
|
||||||
DEBUG "using these rules: $RULES"
|
|
||||||
|
|
||||||
|
if [ $DBG ]; then
|
||||||
|
DEBUG "using these rules: "
|
||||||
|
for i in $RULES; do echo -n "$i "; done
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# create temporary dir that's automatically removed on exit
|
# create temporary dir that's automatically removed on exit
|
||||||
|
@ -256,12 +257,14 @@ TMP=$(mktemp -d /tmp/$SELF.$BASE.XXXXXX) || (echo "$0: can't create temporary di
|
||||||
trap "rm -rf $TMP" 0 1 2 3 13 15
|
trap "rm -rf $TMP" 0 1 2 3 13 15
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# move old files out of the way giving sequential suffixes
|
# move old files out of the way giving sequential suffixes
|
||||||
for i in $DIFF $CDIFF $ARCHIVE; do
|
for i in $DIFF $CDIFF $ARCHIVE; do
|
||||||
[ -f $i ] && mv $i $(backup_filename $i)
|
[ -f $i ] && mv $i $(backup_filename $i)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LOG "updating and checking for new files ..."
|
LOG "updating and checking for new files ..."
|
||||||
$CVS -q up -dP >$TMP/up
|
$CVS -q up -dP >$TMP/up
|
||||||
|
|
||||||
|
@ -273,6 +276,7 @@ if grep "^C " $TMP/up &>/dev/null; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LOG "making diff ..."
|
LOG "making diff ..."
|
||||||
if ! $CVS -q diff -up >$DIFF; then
|
if ! $CVS -q diff -up >$DIFF; then
|
||||||
LOG "diff statistics:"
|
LOG "diff statistics:"
|
||||||
|
@ -293,6 +297,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LOG "checking for files to submit ..."
|
LOG "checking for files to submit ..."
|
||||||
if [ -f $TMP/files ]; then
|
if [ -f $TMP/files ]; then
|
||||||
cat $TMP/files|while read i; do
|
cat $TMP/files|while read i; do
|
||||||
|
@ -305,25 +310,26 @@ grep "^? " $TMP/up|while read i; do
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# filter files according to the pattern rules
|
# filter files according to the pattern rules
|
||||||
if [ -f $TMP/check ]; then
|
if [ -f $TMP/check ]; then
|
||||||
for i in $(cat $TMP/check); do
|
for i in $(cat $TMP/check); do
|
||||||
DEBUG "checking whether file '$i' matches"
|
DEBUG "checking whether file '$i' matches"
|
||||||
for r in $RULES; do
|
for r in $RULES; do
|
||||||
DEBUG "\t\trule $r"
|
DEBUG "\t\trule $r"
|
||||||
R=${r#?}
|
rule=${r#?}
|
||||||
case "!$i" in $r)
|
case "!$i" in $r)
|
||||||
DEBUG "\t\t\t\"silently\" rejected\t\t$R"
|
DEBUG "\t\t\t\"silently\" rejected\t\t$rule"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
case "-$i" in $r)
|
case "-$i" in $r)
|
||||||
REJECT "$i\t\t$R"
|
REJECT "$i\t\t$rule"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
case "+$i" in $r)
|
case "+$i" in $r)
|
||||||
NEW "$i\t\t$R"
|
NEW "$i\t\t$rule"
|
||||||
echo "$i" >>$TMP/files
|
echo "$i" >>$TMP/files
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
@ -333,6 +339,7 @@ if [ -f $TMP/check ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ! [ -f $TMP/files ]; then
|
if ! [ -f $TMP/files ]; then
|
||||||
LOG "no changed or new files found"
|
LOG "no changed or new files found"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -343,16 +350,15 @@ numfiles=$(awk '//{n++}END{print n}' <$TMP/files)
|
||||||
if [ -f $DIFF -a $numfiles == 1 ]; then
|
if [ -f $DIFF -a $numfiles == 1 ]; then
|
||||||
LOG "only changed non-binary files found"
|
LOG "only changed non-binary files found"
|
||||||
LOG "creating compressed diff \e[1;37;40m$CDIFF\e[m\e[35m ..."
|
LOG "creating compressed diff \e[1;37;40m$CDIFF\e[m\e[35m ..."
|
||||||
bzip2 -k $DIFF
|
bzip2 --keep $DIFF
|
||||||
RESULT=$CDIFF
|
RESULT=$CDIFF
|
||||||
else
|
else
|
||||||
LOG "changed and/or new files found"
|
LOG "changed and/or new files found"
|
||||||
LOG "creating archive \e[1;37;40m$ARCHIVE\e[m\e[35m ..."
|
LOG "creating archive \e[1;37;40m$ARCHIVE\e[m\e[35m ..."
|
||||||
tar -cjf $ARCHIVE --files-from $TMP/files
|
tar --create --bzip2 --file=$ARCHIVE --files-from $TMP/files
|
||||||
RESULT=$ARCHIVE
|
RESULT=$ARCHIVE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -x "$UPLOAD" -a -f $RESULT ] && $UPLOAD $RESULT $DIFF
|
|
||||||
|
|
||||||
exit 0
|
[ -x "$UPLOAD" -a -f $RESULT ] && exec $UPLOAD $RESULT $DIFF
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue