alpine/chappa-cherrypick.sh

375 lines
12 KiB
Bash

# abort on any error:
set -e
# Used by --update and --apply:
chappa_patchdir=chappa-patches
echo_others() {
# Note: This function is updated by the function update_OTHERS_section, it's
# very sensitive to change, the part below must stay as it is or
# you will loose this script in the update process if you say "y":
cat<<OTHERS
<LI><A NAME= which makes Alpine warn if no fcc folder has been defined before sending the message. See also: <A HREF="http://homepage.ntlworld.com/phil.brooke/alpine/patch-alpine-1.00-warn_about_fcc-20071223a">author's patch web page</A>.
OTHERS
}
echo_patch_help() {
cat <<END
fancy Enhanced fancy thread interface. <A HREF="h_config_enhanced_thread">(more...)</A>
maildir Maildir Patch. <A HREF="h_config_maildir">(more...)</A>
fillpara Pine justifies paragraphs with more than one level of indentation. <A HREF="h_compose_justify">(more...)</A>
rules Rules patch, to make Pine flexible. <A HREF="h_config_new_rules">(more...)</A>
compose Send mail from the command line.
WrtAcc Write accents like &aacute;, &eacute;, &ntilde; etc.
circtab Tab check folders on cycles. <A HREF="h_config_circular_tab">(more...)</A>
count Get the number of new messages when opening a folder.
insertpat Reinsert the pattern you searched for last.
patchlevel Shows the patchlevel of alpine
picoreplacecrash Fix a bug that makes Pico crash in the replace command
replacebug Fix a bug in Pico which makes it not update the screen
digestbug Fix a bug that makes Alpine not display digests
stuffingbug Fix a bug that makes Alpine add spaces to flowed text messages
reply New Reply command menu.<A HREF="h_config_alt_reply_menu">(more...)</A>
fromheader Change your From header without any effort!
composeurl Choose a role when composing a message from a mailto: link.
colortext Paint special text in the body of the message in any custom color. <A HREF="h_config_special_text_to_color">(more...)</A>
searchheader Select messages by the content of an arbitrary header.
DelText Delete until the the end of a file, or message (press ^W^X).
quota Get the QUOTA information from an IMAP server (if such server supports e QUOTA command).
help Get the internal name of a help topic to use it with a x-pine-help URL scheme.
ignoresize Decide if you want to ignore errors in size changes of a message when saving a message from an IMAP server.
status Fix the update of the status line information in pico
unverified Fix a bug that makes Alpine not to give a warning if the Newsgroup header is present
utf8bug Fix a bug that makes Alpine filter incorrectly in the UTF-8 filter.
END
echo_others
}
#==================================================================================
# The following functions are only used for --update:
#
#
# This function decided which patches are downloaded, and packaged:
# Every patch which shall be, is echoed, every patch which shall be not is not.
# If it encounters a new patch, it is printed on stderror
#
print_which_shall_be_packaged() {
#grep '"info/' index.html | sed 's/.LI.\(.*\)<.*NAME="\([^"]*\)".*/\2 \1/'|
wget -m http://staff.washington.edu/chappa/alpine/readme/README.upgrade >&2
error_out=
while read name text
do
case "$name" in
cygwin|all|windows) : 'always ignored';;
WrtAcc|fancy|maildir|colortext|insertpat|[ors]*bug|*crash)
: 'really wanted'
echo "$name";;
utf8bug|digestbug|ignoresize|searchheader)
: 'also wanted'
echo "$name";;
unverified)
: 'also wanted'
echo "$name";;
rules) : 'conflicts with others and would need extra work'
#echo "$name"
;;
help|status|reply|DelText|outgoing|count)
: 'not important enough';;
quota|composeurl|fromheader|circtab)
: 'rather not';;
patchlevel)
: 'lets see';;
marksmtpbug)
: 'not found';;
fillpara)
: 'rather dangerous';;
password|'#')
: 'internal';;
*) error_out=1;echo NEW $name;;
esac
done <staff.washington.edu/chappa/alpine/readme/README.upgrade
if [ "$error_out" ]; then
echo "Unhandled patches found!"
return 5
fi
# echo_others
}
#print_which_shall_be_packaged
#exit
get_patch_path() {
echo staff.washington.edu/chappa/alpine/patches/alpine-$version/$1.patch.gz
}
list_packaged_patches_urls() {
print_which_shall_be_packaged | while read name rest; do
get_patch_path $name
done
}
update_OTHERS_section() {
return
wget --timestamping http://staff.washington.edu/chappa/alpine/patches/others.html
grep alpine-$version others.html |
sed 's/.*alpine-$version\///;s/.patch.gz//;s/".*A>,//;s/ Posted.*//;s/which fixes/Fix/;s/which changes/Change/;s/which adds/Add/' \
>others
sed '/^cat..OTHERS$/,/^OTHERS$/{/^cat..OTHERS$/b ins;/^OTHERS/p;d};p;d;:ins;r others' ../$0 >change
diff ../$0 change || {
echo -n "DANGEROUS may loose script work: Apply these changes to $0 (y/*)?"
read answer
if [ "$answer" = y ]; then
cat change >../$0
rm change
echo "OTHERS_section updated, restarting from scratch!"
cd ..
exec bash $0 --update $2
else
echo "OTHERS_section updated, please check and do it."
exit
fi
}
rm change
}
check_patch_list() {
missing=
for name in `ls $chappa_patchdir`
do
helpentry=`echo_patch_help | sed -n "s/^$name //p"`
printf "%-22s %s\n" $name "'$helpentry'"
if [ -z "$helpentry" ]; then
missing="$missing $name"
fi
done
if [ "$missing" ]; then
echo "=======> help entries for $missing are missing, existing - please fix!"
exit 4
else
echo "---> No help entries are missing" >&2
fi
}
update_packaged_patches() {
mkdir -p test;cd test
do_update=true
print_which_shall_be_packaged || exit
#do_update=false
if $do_update;then
update_OTHERS_section
rm -f index.html
wget http://staff.washington.edu/chappa/alpine/
wget -m $(list_packaged_patches_urls)
fi
#print_which_shall_be_packaged | sed 's/.*/^& /' >shall-be-packaged.patterns
#grep '"info/' index.html | sed 's/.LI.\(.*\)<.*NAME="\([^"]*\)".*/\2 \1/'|
# grep -f shall-be-packaged.patterns | sed 's/[^ ]* //' >patch-summaries.txt
rm -rf $chappa_patchdir
mkdir $chappa_patchdir
print_which_shall_be_packaged | while read name rest; do
if [ "$name" = NEW: ]; then
exit
fi
zcat `get_patch_path $name` >$chappa_patchdir/$name
touch -r `get_patch_path $name` $chappa_patchdir/$name
done
check_patch_list
print_which_shall_be_packaged | while read name rest; do
if echo_patch_help | sed -n "s/^$name //p"| grep HREF; then
:
else
wget --timestamping -x http://staff.washington.edu/chappa/alpine/info/$name.html || :
if [ -s staff.washington.edu/chappa/alpine/info/$name.html ]; then
sed '0,/is available for version/d;/\/'$name'.patch/d;/<.[tT][dD]><.[tT][rR]><.[tT][aA][bB][lL][eE]>/,$d' \
staff.washington.edu/chappa/alpine/info/$name.html |
iconv -f latin1 -t UTF-8 >$chappa_patchdir/$name.hlp
fi
fi
zcat `get_patch_path $name` >$chappa_patchdir/$name
done
find $chappa_patchdir -name '*.hlp' -size 0|xargs --no-run-if-empty rm
cd -
lzma -dc $chappa_patchdir.tar.lzma | tar xvf -
diff -r $chappa_patchdir test/$chappa_patchdir | less
echo -n 'Changes OK, update $chappa_patchdir.tar.lzma (y/*)? '
read answer
if [ "$answer" = y ]; then
cd test
tar cf ../$chappa_patchdir.tar $chappa_patchdir
cd ..
tar tfv $chappa_patchdir.tar | sort +5
echo "Compressing using lzma..."
old chappa-patches.tar.lzma
lzma -9 $chappa_patchdir.tar
else
echo "$chappa_patchdir.tar.lzma NOT updated!"
fi
}
if [ "$1" = "--update" ]; then
set -eu
version=$2
update_packaged_patches
exit
fi
if [ "$1" = "--cleanup" ]; then
rm -rf test
exit
fi
# Everything above is only for update and cleanup
if [ "$1" != "--apply" ]; then
echo "cherrypick.sh can either update $chappa_patchdir.tar.lzma, cleanup or apply the patches"
echo "usage: cherrypick [ --update | --cleanup | --apply ]"
exit 5
fi
if [ "$0" -nt "$2" ]; then
echo "Attention:
$0 is newer than
$2
If the update of ${0##*/} needs to change $chappa_patchdir.tar.lzma, you should run:
sh ${0##*/} --update
otherwise run:
touch -r chappa-cherrypick.sh chappa-patches.tar.lzma
"
exit 4
fi
# Everything below is only for apply, it applies all patches in $2
# and generates a patch to pine.hlp which describes the applied patches.
print_hlp_pages() {
ls $chappa_patchdir | while read name; do
if [ -f $chappa_patchdir/$name.hlp ]; then
title=`echo_patch_help | sed -n "s/^$name //p"`
cat <<END
====== h_chappa_patch_$name ======
<html>
<head>
<TITLE>$title</TITLE>
</head>
<body>
<H1>$title</H1>
<P>
END
# Unlike pure html, alpine's hlp viewer needs
# backslashes escaped:
sed 's/\\/\\\\/g;s/\\\\"/\\\\\&quot;/g' $chappa_patchdir/$name.hlp
echo '</body></html>'
fi
done
}
echo_patch_list() {
ls $chappa_patchdir | while read name; do
case "$name" in *.hlp) continue;; esac
helpentry=`echo_patch_help | sed -n "s/^$name //p"`
echo "<LI> $helpentry"
if [ -f $chappa_patchdir/$name.hlp ]; then
echo " <A HREF=\"h_chappa_patch_$name\">(more...)</A>"
fi
done
}
generate_patch_help() {
(
print_hlp_pages
cat <<END
====== h_opensuse_issues ======
<html>
<head>
<TITLE>Information on checking for known issues and reporting new issues</TITLE>
</head>
<body>
<H1>Information on checking for known issues and reporting new issues</H1>
<P>If you have any issues while using this release of Alpine, please search
the Novell bugzilla using the advanced search form at
<A HREF="http://bugzilla.novell.com/query.cgi">
http://bugzilla.novell.com/query.cgi</A> and enter "alpine"
into the search field for "Summary".
In order to see all issues which have been reported so far,
unselect all preselections in the Status list of the Impact Section,
by holding the Control key while clicking on NEW, ASSIGNED, NEEDINFO
an REOPENED before clicking on "Search".
<P>If your issue is not found in the Novell Bugzilla, please sign in
to the Novell Bugzilla and report the issue.
You can also visit the
<A HREF="http://www.washington.edu/alpine/">Alpine Information Center</A>,
and the
<A HREF="https://mailman1.u.washington.edu/mailman/private/alpine-alpha/">
Alpine-alpha mailing list archive</A>. On the
<A HREF="https://mailman1.u.washington.edu/mailman/listinfo/alpine-alpha">
Alpine-alpha mailing list</A>, you can also report and discuss issues.<P>
Be sure to include the full openSUSE version
of alpine (found at the top of this release notes page) in all reports
which you make.</body></html>
====== h_opensuse_patches ======
<html>
<head>
<TITLE>Information on patches added to this release</TITLE>
</head>
<body>
<H1>Information on patches added to this release</H1>
<P>
This version of Alpine has been modified by including patches from
<A HREF="http://staff.washington.edu/chappa/alpine/">
http://staff.washington.edu/chappa/alpine/</A>. These patches include
new features and bug fixes. More complete information on each patch
included in this version can be found in the web.
<P>If you have any problems with this release of Pine, please
follow the suggestions <A HREF="h_opensuse_issues">here</A>
<P>The list of patches included in this release are:<UL>
END
echo_patch_list
echo "</UL></body></html>"
)
}
generate_help_patch() {
cat <<END
--- alpine-$version/pith/pine.hlp
+++ alpine-$version/pith/pine.hlp
@@ -157,6 +157,10 @@
<BR>University of Washington
</DIV>
+<P>Note: <A HREF="h_opensuse_patches">This version of Alpine has been built for openSUSE with
+patches of Eduardo Chappa for latest bugfixes and enhanced functionality</A>.
+Press ENTER on the link above for more information.
+
<P>
Alpine is an &quot;Alternatively Licensed Program for Internet
News and Email&quot; produced by the University of Washington.
END
lines=$(generate_patch_help |wc -l)
start=1171
echo "@@ -$start,6 +`expr $start + 1`,`expr $lines + 6` @@"
cat <<END
&lt;End of Configuration Notes&gt;
</BODY>
</HTML>
END
generate_patch_help | sed 's/^/+/'
cat <<END
====== h_news_legal ======
<html>
<head>
END
}
lzma -dc $2 | tar xf -
if generate_help_patch | patch -p1; then
echo "generated patch applied"
else
echo "generated patch failed to apply"
exit 5
fi
rm $chappa_patchdir/*.hlp
for patch in $chappa_patchdir/*;do
echo
echo "Applying $patch"
if patch -p1 -i$patch; then
echo "$patch applied"
else
echo "$patch failed to apply"
exit 5
fi
done
exit