line wrapping: Provide cr-fold-long-lines script
PATCH 1/4 line wrapping: Provide cr-fold-long-lines script
This is a reversible transformation which usually just introduces a \
where it splits lines.
We are going to use this to wrap the lines in our emails. SMTP has a 999-byte length limit (including a CR-LF pair). This can cause our emails to go astray. We don't really want our messages to be q-p or base64-encoded if we can avoid it, and MTAs don't do that anyway (so we would have to organise it). So instead, we will simply wrap any long lines that occur.
This transformation is not suitable for headers, but we don't intend or want to generate long lines which would need further wrapping. (A reversible transformation suitable for headers would be quite ugly and would only be right for a subset of headers anyway...)
--- cr-fold-long-lines | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 cr-fold-long-lines
cr-fold-long-lines new file +22 -0
@@ -0,0 +1,22 @@ +#!/usr/bin/perl -wp +# +# long lines are broken by inserting \ plus spaces/tabs, somewhere +# lines already ending with \ and maybe some $s have a $ postpended +# so they do not look broken +# +# unparsing: +# ooo\ | <SPC>bar => ooobar (<SPC> is >=0 tab/space) +# then: +# ooo\$ | any => ooo\ | any +# ooo\$$ | any => ooo\$ | any +# ooo\$$$ | any => ooo\$$ | any etc. +# others unchanged, specifically: +# ooo$ | any => ooo$ | any +# ooo$$ | any => ooo$$ | any +# ooo$$$ | any => ooo$$$ | any etc. +# (where in these diagrams ` | ' means a newline) + +use strict; + +s{\\(\$*)\n}{\\$1\$\n}; # $-stuffing, now does not end in backslash +s{.{500}}{$&\\\n }g; # insert \ \n SPC as needed
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/4 line wrapping: Use tmp/$flight.report in two extra places
The output from sg-report-flight might in principle contain long lines, although this is not expected. So we are going to want to feed it through the new cr-fold-long-lines.
Rather than piping, we are going to keep a copy of the .report file, like is done in mg-execute-flight. So for now, just make that change.
No overall change other than to leave behind the tmp/$flight.report file. It will be tidied up by the usual cleanup processes.
--- cri-args-hostlists | 3 ++- cri-bisect | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
cri-args-hostlists +2 -1
@@ -119,7 +119,8 @@ start_email () { ./sg-report-flight --html-dir=$flight_html_dir/$flight/ \ --allow=allow.all --allow=allow.$branch \ - $sgr_args $flight + $sgr_args $flight >tmp/$flight.report + cat tmp/$flight.report mkdir -p $host_html_dir with-lock-ex -w $globallockdir/report-lock \
cri-bisect +2 -1
@@ -107,7 +107,8 @@ END if [ "x$OSSTEST_HTMLPUB_DIR" != x ]; then sgr_args+=" --html-dir=$OSSTEST_HTMLPUB_DIR/$flight/" fi - ./sg-report-flight $sgr_args >&3 $flight + ./sg-report-flight $sgr_args $flight >tmp/$flight.report + cat tmp/$flight.report >&3 ./cr-publish-flight-logs --push-harness $flight fi exec 3>&-
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/4 line wrapping: Replace many uses of cat with cr-fold-long-lines
In reply to Ian JacksonThese are the nicely uniform bits of this change.
This arranges that many of the places where stuff gets put into emails has their lines wrapped.
--- cr-daily-branch | 2 +- cri-args-hostlists | 2 +- cri-bisect | 10 +++++----- mg-execute-flight | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-)
cr-daily-branch +1 -1
@@ -547,7 +547,7 @@ if [ -f $revlog ]; then revlog_lines=`wc -l <$revlog` if [ $revlog_lines -lt 300 ]; then echo ------------------------------------------------------------ - cat $revlog + ./cr-fold-long-lines $revlog else echo "(No revision log; it would be" $revlog_lines "lines long.)" fi
cri-args-hostlists +1 -1
@@ -120,7 +120,7 @@ start_email () { ./sg-report-flight --html-dir=$flight_html_dir/$flight/ \ --allow=allow.all --allow=allow.$branch \ $sgr_args $flight >tmp/$flight.report - cat tmp/$flight.report + ./cr-fold-long-lines tmp/$flight.report mkdir -p $host_html_dir with-lock-ex -w $globallockdir/report-lock \
cri-bisect +5 -5
@@ -90,25 +90,25 @@ job $job testid $testid END - cat >&3 $summaryfile - if $bisgraph; then cat >&3 <<END; fi + ./cr-fold-long-lines >&3 $summaryfile + if $bisgraph; then ./cr-fold-long-lines >&3 <<END; fi For bisection revision-tuple graph see: $OSSTEST_HTML_URL/$bisleaf.html Revision IDs in each graph node refer, respectively, to the Trees above. END - cat >&3 <<END + ./cr-fold-long-lines >&3 <<END ---------------------------------------- END - cat >&3 $reportfile + ./cr-fold-long-lines >&3 $reportfile if $flight_executed; then echo >&3 ---------------------------------------- if [ "x$OSSTEST_HTMLPUB_DIR" != x ]; then sgr_args+=" --html-dir=$OSSTEST_HTMLPUB_DIR/$flight/" fi ./sg-report-flight $sgr_args $flight >tmp/$flight.report - cat tmp/$flight.report >&3 + ./cr-fold-long-lines tmp/$flight.report >&3 ./cr-publish-flight-logs --push-harness $flight fi exec 3>&-
mg-execute-flight +2 -2
@@ -97,10 +97,10 @@ END git log -n1 --pretty=format:'harness %h: %s' | perl -pe 's/(.{70}).+/$1.../' echo -cat <tmp/$flight.report +./cr-fold-long-lines <tmp/$flight.report echo ============================================================ -cat <tmp/$flight.transcript +./cr-fold-long-lines <tmp/$flight.transcript exec >&2
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 4/4 line wrapping: In one place pipe through cr-fold-long-lines
In reply to Ian JacksonThis is the remaining place where long lines might get into emails.
--- mg-execute-flight | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mg-execute-flight +2 -1
@@ -94,7 +94,8 @@ $email_std_headers $OSSTEST_RESOURCE_PREINFO END -git log -n1 --pretty=format:'harness %h: %s' | perl -pe 's/(.{70}).+/$1.../' +git log -n1 --pretty=format:'harness %h: %s' | perl -pe 's/(.{70}).+/$1.../' \ + | ./cr-fold-long-lines echo ./cr-fold-long-lines <tmp/$flight.report
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel