As the quilt maintainer I was surprised to see Landry mention quilt on
icb as a port that depends on procmail; I didn't even realize that quilt
used procmail behind the scenes.  :)

Turns out, quilt really only uses formail, and only to extract the value
of headers.  Reading RFC 2822 I think we can safely do this with sed,
instead.  (Well, technically gsed in this case; in fact, testing this
exposed a few issues in our sed that I will investigate separately)

I'd really appreciate some extra eyeballs on this new patch.  quilt's
mail regress test looks pretty thorough and it still passes, and I also
manually verified the sed output matches formail's output.  Cc'ing
guenther@ in case he's got a spare minute or two to look this over and
chime in.

Once this goes in I'll push the patch upstream.

Ok?

Index: Makefile
===================================================================
RCS file: /work/cvsroot/ports/devel/quilt/Makefile,v
retrieving revision 1.7
diff -p -u -r1.7 Makefile
--- Makefile    18 Sep 2014 15:14:47 -0000      1.7
+++ Makefile    8 Jan 2015 00:06:50 -0000
@@ -3,7 +3,7 @@
 COMMENT=               manage large numbers of patches
 
 DISTNAME=              quilt-0.63
-REVISION=              0
+REVISION=              1
 CATEGORIES=            devel
 
 HOMEPAGE=              http://savannah.nongnu.org/projects/quilt/
@@ -22,7 +22,6 @@ USE_GMAKE=            Yes
 
 RUN_DEPENDS=           devel/gpatch \
                        lang/gawk \
-                       mail/procmail \
                        misc/findutils \
                        misc/gnugetopt \
                        shells/bash \
Index: patches/patch-quilt_mail_in
===================================================================
RCS file: patches/patch-quilt_mail_in
diff -N patches/patch-quilt_mail_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-quilt_mail_in 8 Jan 2015 05:08:10 -0000
@@ -0,0 +1,111 @@
+$OpenBSD$
+
+Remove formail/procmail dependency
+
+--- quilt/mail.in.orig Wed May  7 13:41:15 2014
++++ quilt/mail.in      Wed Jan  7 23:08:06 2015
+@@ -81,6 +81,18 @@ msgid()
+       echo "$timestamp@${opt_sender_address#*@}"
+ }
+ 
++# Extract RFC 2822 compliant header values, including Long Header Fields,
++# from messages
++
++extract_header_value()
++{
++      local header=$1
++
++      # Long Header Fields may span multiple lines, in which case CRLF
++      # is followed by space or tab (RFC 2822)
++      sed -n "/^${header}/,/^[^ \\t]/ { /^${header}/ { p; n; }; /^[^ \\t]/q; 
/^$/q; p; }" | sed "s/^${header}//"
++}
++
+ # See RFC 2822 Internet Message Format for how the In-Reply-To and
+ # References headers are generated...
+ 
+@@ -88,7 +100,7 @@ in_reply_to_header()
+ {
+       local message=$1 message_id
+ 
+-      message_id=$(formail -x Message-ID: < "$message")
++      message_id=$(extract_header_value Message-ID: < "$message")
+       message_id=${message_id# }
+       [ -n "$message_id" ] && echo "In-Reply-To: $message_id"
+ }
+@@ -97,14 +109,14 @@ references_header()
+ {
+       local message=$1 message_id references in_reply_to
+ 
+-      message_id=$(formail -x Message-ID: < "$message")
++      message_id=$(extract_header_value Message-ID: < "$message")
+       message_id=${message_id# }
+ 
+-      references=$(formail -x References: < "$message")
++      references=$(extract_header_value References: < "$message")
+       references=${references# }
+       if [ -z "$references" ]
+       then
+-              in_reply_to=$(formail -x In-Reply-To: < "$message")
++              in_reply_to=$(extract_header_value In-Reply-To: < "$message")
+               in_reply_to=${in_reply_to# }
+               if [ -n "$in_reply_to" ]
+               then
+@@ -256,13 +268,6 @@ then
+       usage
+ fi
+ 
+-# check if formail is installed before doing anything
+-if ! type formail &> /dev/null
+-then
+-      echo $"You have to install 'formail' to use 'quilt mail'" >&2
+-      exit 1
+-fi
+-
+ if [ $# -ge 1 ]
+ then
+       if [ "$1" = - ]
+@@ -333,7 +338,7 @@ then
+               local -a mh
+ 
+               # Does this patch have a Subject: line?
+-              subject=$(formail -x Subject: < $tmpdir/header)
++              subject=$(extract_header_value Subject: < $tmpdir/header)
+               if [ -n "$subject" ]
+               then
+                       awk '
+@@ -443,7 +448,7 @@ do
+       | quilt_mail_patch_filter "$patch" > "$tmpdir/$patch"
+       status=${PIPESTATUS[1]}
+ 
+-      subject=$(formail -x Replace-Subject: < "$tmpdir/$patch" | join_lines)
++      subject=$(extract_header_value Replace-Subject: < "$tmpdir/$patch" | 
join_lines)
+       if [ $status -ne 0 -o -z "$subject" ]
+       then
+               printf \
+@@ -486,7 +491,7 @@ then
+ 
+       if [ -z "$opt_subject" ]
+       then
+-              opt_subject="Re: $(formail -x Subject: < "$opt_reply_to" \
++              opt_subject="Re: $(extract_header_value Subject: < 
"$opt_reply_to" \
+                             | sed -e 's/^ *\([rR][eE]: *\)*//')"
+       fi
+ fi
+@@ -535,7 +540,7 @@ then
+       fi
+ fi
+ 
+-subject=$(formail -x Subject: < $introduction | join_lines)
++subject=$(extract_header_value Subject: < $introduction | join_lines)
+ if [ -z "$subject" ]
+ then
+       if [ -z "$opt_message" ]
+@@ -554,7 +559,7 @@ then
+       exec 1> $opt_mbox
+ fi
+ 
+-subject_prefix=$(formail -x Subject-Prefix: < $introduction | join_lines)
++subject_prefix=$(extract_header_value Subject-Prefix: < $introduction | 
join_lines)
+ [ -n "$subject_prefix" ] && subject_prefix="$subject_prefix "
+ 
+ subject_prefix=${subject_prefix//\'/\'\'}

Reply via email to