Skip to content

Commit

Permalink
Handle config file for author/maintainer/cc
Browse files Browse the repository at this point in the history
e.g.

author = NeilBrown <[email protected]>
header = X-Face: whatever
header = "       and whatever

maintainer = [email protected]
[Nfsd]
 tag=kNFSd
 [email protected]
[Md]
 tag=md
 [email protected]

Signed-off-by: Neil Brown <[email protected]>
  • Loading branch information
neilbrown committed Jun 13, 2006
1 parent c3e7c53 commit 9edfa92
Showing 1 changed file with 65 additions and 15 deletions.
80 changes: 65 additions & 15 deletions p
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,34 @@ get_meta()
status=`cat .patches/status 2> /dev/null`
}

nl='
'
get_conf()
{
name=$1
context=$2
result=
active=yes
sep=
[ -f .patches/config ] || >> .patches/config
while read a b c
do
case $a in
'[global]' ) active=yes ;;
"[$context]") active=yes ;;
"["*"]" ) active= ;;
* ) if [ " $b" == " =" -a " $a" = " $name" -a -n "$active" ];
then
result="$result$sep$c"
sep=$nl
fi
;;
esac
done < .patches/config
result=$(echo "$result" | sed 's/^"//' )
eval $name=\"\$result\"
}

upgrade_one()
{
# move $1~current~ to .patches/current/$1 and same for orig
Expand Down Expand Up @@ -842,14 +870,29 @@ case $cmd in
exit 1;
fi
mkdir .patches/mail
if [ ! -s .patches/maintainer ] ; then
echo "No maintainer - please add one"
exit 1;

get_conf author $1
get_conf header $1
if [ -n "$author" ]
then
headers="From: $author$nl$header$nl"
elif [ -s .patches/owner ]; then
headers=`cat .patches/owner`;
else
echo Please add add auther information to .patches/config
exit 1
fi
if [ ! -s .patches/owner ] ; then
echo "Your address and other headers must be in .patches/owner"
get_conf maintainer $1
if [ -z "$maintainer" -a -s .patches/maintainer ]
then
mantainer=`cat .patches/maintainer`
fi

if [ -z "$maintainer" ] ; then
echo "No maintainer - please add one"
exit 1;
fi

messid="<`date +'%Y%m%d%H%M%S'`.$$.patches@`uname -n`>"
cnt=0
for patch in .patches/applied/???${1}*
Expand All @@ -860,16 +903,21 @@ case $cmd in
if [ -n "$3" ] && [ $3 -lt $n ] ; then continue; fi
cnt=$(expr $cnt + 1 )
done
get_conf cc $1
get_conf tag $1
this=1
if [ $cnt -gt 1 ]
then
{
if [ -s .patches/owner.$1 ] ; then
cat .patches/owner.$1
else
cat .patches/owner
echo "$headers"
echo "To: $maintainer"

if [ -z "$cc" ]; then
echo "Cc: $cc"
fi
if [ -z "$tag" ]; then
sprefix="$tag: "
fi
echo "To: `cat .patches/maintainer`"
if [ -s .patches/cc ] ; then
while read word prefix addr
do if [ " $word" = " $1" ] ; then
Expand Down Expand Up @@ -898,12 +946,14 @@ case $cmd in
if [ -n "$3" ] && [ $3 -lt $n ] ; then continue; fi
{
sprefix=
if [ -s .patches/owner.$1 ] ; then
cat .patches/owner.$1
else
cat .patches/owner
echo "$headers"
echo "To: $maintainer"
if [ -z "$cc" ]; then
echo "Cc: $cc"
fi
if [ -z "$tag" ]; then
sprefix="$tag: "
fi
echo "To: `cat .patches/maintainer`"
if [ -s .patches/cc ] ; then
while read word prefix addr
do if [ " $word" = " $1" ] ; then
Expand Down

0 comments on commit 9edfa92

Please sign in to comment.