altomaltes / cross / slibtool

Forked from cross/slibtool 2 years ago
Clone

Blame contrib.sh

61a679
#!/bin/sh
61a679
61a679
# init vars
61a679
commit=$1; [ -z "$commit" ] && commit='HEAD'
61a679
blank=
61a679
bline=
61a679
fname=
61a679
61a679
# source.patch
61a679
git format-patch -1 $commit --stdout > source.patch	|| exit 2
61a679
cat contrib.msg >> source.patch				|| exit 2
61a679
61a679
# source.patch without the (noisy) first line
61a679
tail -n +2 source.patch > contrib.patch 		|| exit 2
61a679
61a679
# contrib.patch: first blank line
61a679
blank=`grep -n ^$ contrib.patch | head -n1`
61a679
[ -z "$blank" ] && exit 2
61a679
61a679
bline=`echo $blank | cut -f1 -d':'`
61a679
[ -z "$bline" ] && exit 2
61a679
61a679
# use sha256sum of the above for patch file name
61a679
fname=`sha256sum contrib.patch | cut -f1 -d' '`		|| exit 2
61a679
[ -z "$fname" ] && exit 2
61a679
61a679
# prepare for submission, sign the patch
61a679
mv   contrib.patch $fname.patch				|| exit 2
61a679
head -n$bline $fname.patch | tail -n +2 > $fname.sig	|| exit 2
61a679
61a679
[ -z "$PAGER" ] && PAGER='less'
61a679
$PAGER $fname.patch					|| exit 2
61a679
cat contrib.msg						|| exit 2
61a679
61a679
echo
61a679
echo 'press <enter> to continue, <ctrl-c> to abort>'
61a679
echo
61a679
61a679
read enter
61a679
61a679
gpg  --armor --detach-sign $fname.patch			|| exit 2
61a679
cat  $fname.patch.asc >> $fname.sig			|| exit 2
61a679
61a679
# verify
61a679
gpg --verify $fname.sig $fname.patch			|| exit 2
61a679
61a679
# clean up
61a679
rm source.patch
61a679
rm $fname.patch.asc
61a679
61a679
# info
61a679
echo
61a679
echo "commit $commit was successfully prepared for submission."
61a679
echo "$fname.patch: a patch file that can be imported by git-am."
61a679
echo "$fname.sig:   a gpg signature file of the above patch."
61a679
echo
61a679
61a679
# all done
61a679
exit 0