chiark / gitweb /
metadata as tsv text header
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 25 Jul 2009 11:05:52 +0000 (12:05 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 25 Jul 2009 11:05:52 +0000 (12:05 +0100)
pctb/commod-update-receiver

index 11064cd7d9b6897f9194116690602eebb71e3e81..532bf316bfbec43d24cb6b2e2352b1a25c85b495 100755 (executable)
@@ -119,16 +119,29 @@ foreach my $cs (qw(client server)) {
     $o{"${cs}spec"}= join ' ', map { $o{$cs.$_} } qw(name version fixes);
 }
 
-foreach my $vn (sort keys %o) {
-    my $mpart= MIME::Entity->build(Top => 0,
-                                  Type => 'text/plain',
-                                  Charset => 'utf-8',
-                                  Disposition => 'attachment',
-                                  Filename => $vn,
-                                  Data => $o{$vn});
-    $mcontent->add_part($mpart);
+my $metadata= '';
+
+sub ksmap ($) {
+    my ($v) = @_;
+    my $i=0; grep { return $i if $_ eq $v; $i++ } qw(ocean island timestamp);
+    sprintf "z %d %s", (length $v) / 8, $v;
 }
 
+foreach my $vn (sort { ksmap($a) cmp ksmap($b) } keys %o) {
+    my $val= $o{$vn};
+    die if $val =~ m/\n|\r|\t/;
+    $metadata .= "$vn\t$o{$vn}\n";
+}
+
+my $mdpart= MIME::Entity->build(Top => 0,
+                               Type => 'text/plain',
+                               Charset => 'utf-8',
+                               Disposition => 'inline',
+                               Encoding => 'quoted-printable',
+                               Filename => 'metadata',
+                               Data => $metadata);
+$mcontent->add_part($mdpart);
+
 my $gunzchild= open(GZ, "-|"); defined $gunzchild or die $!;
 if (!$gunzchild) {
     open STDIN, "<&=", $indatafh or die $!;