/
mbox2send
executable file
·79 lines (63 loc) · 1.56 KB
/
mbox2send
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl -W
#
# This takes a mbox of email, created with 'quilt mail --mbox'
# and formats it in the proper way to send off a -stable kernel review.
#
# This means:
# - strip off some quilt headers and the threading
# - add some text at the top of every message.
#
# Written in perl because the bash version is broken, it doesn't pass
# through the patch correctly :(
#
my $line;
my $version = shift;
if ($version eq "") {
print "must provide kernel version number\n";
die;
}
my $mbox = shift;
if ($mbox eq "") {
print "must provide the name of the mbox file\n";
die;
}
$mboxnew = "$mbox.new";
chomp($mboxnew);
open MBOX, "$mbox" || die "Failed to open $mbox";
open FILE, ">$mboxnew" || die "Failed to create $mboxnew";
my $header = "true";
my $eat = "false";
while ($line = <MBOX>) {
$eat = "false";
if ($header eq "false") {
if ($line =~ m/^From /) {
# start of a message, this is the header
$header = "true";
}
}
if ($header eq "true") {
# strip out References line
if ($line =~ m/^References:/) {
# eat the line
$eat = "true";
}
# strip out the Content-Disposition line
if ($line =~ m/Content-Disposition:/) {
# eat the line
$eat = "true";
# we are now out of the header
$header = "false";
# write out our custom header too
print FILE "\n";
print FILE "$version-stable review patch. If anyone has any objections, please let me know.\n";
print FILE "\n";
print FILE "------------------\n";
}
}
if ($eat eq "false") {
print FILE $line;
}
}
close MBOX;
close FILE;
print "new mailbox is in $mboxnew\n";