chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
metadata as tsv text header means we don't care about = in values
[ypp-sc-tools.db-test.git]
/
pctb
/
commod-update-receiver
diff --git
a/pctb/commod-update-receiver
b/pctb/commod-update-receiver
index ac52fec7fe89499ab5feed1ca168ec858c0f1776..4b52251b9967896aa7b1e70985a3082197df9b26 100755
(executable)
--- a/
pctb/commod-update-receiver
+++ b/
pctb/commod-update-receiver
@@
-102,9
+102,6
@@
$o{'timestamp'}= must_param('timestamp', "^([1-9]\\d{1,20})\$");
my $now= time; defined $now or die $!;
fail("clock skew") if $o{'timestamp'} >= $now;
my $now= time; defined $now or die $!;
fail("clock skew") if $o{'timestamp'} >= $now;
-die if $o{'ocean'} =~ m/\=/;
-die if $o{'island'} =~ m/\=/;
-
my $indatafh= upload('data');
defined $indatafh or fail("data is not a file");
my $datafile= must_param('data',"^(deduped\\.tsv\\.gz)\$");
my $indatafh= upload('data');
defined $indatafh or fail("data is not a file");
my $datafile= must_param('data',"^(deduped\\.tsv\\.gz)\$");
@@
-119,14
+116,29
@@
foreach my $cs (qw(client server)) {
$o{"${cs}spec"}= join ' ', map { $o{$cs.$_} } qw(name version fixes);
}
$o{"${cs}spec"}= join ' ', map { $o{$cs.$_} } qw(name version fixes);
}
-foreach my $vn (sort keys %o) {
- my $mpart= MIME::Entity->build(Type => 'text/plain',
- Charset => 'utf-8',
- Disposition => 'inline',
- 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 $!;
my $gunzchild= open(GZ, "-|"); defined $gunzchild or die $!;
if (!$gunzchild) {
open STDIN, "<&=", $indatafh or die $!;
@@
-156,15
+168,21
@@
while (<GZ>) {
GZ->error and die $!;
$?=0; close GZ; $? and fail("gunzip for check failed code $?");
GZ->error and die $!;
$?=0; close GZ; $? and fail("gunzip for check failed code $?");
-my $mdatafile= MIME::Entity->build(Type => 'application/octet-stream',
+my $mdatafile= MIME::Entity->build(Top => 0,
+ Type => 'application/octet-stream',
Disposition => 'attachment',
Encoding => 'base64',
Disposition => 'attachment',
Encoding => 'base64',
- File => $datafile);
+ Filename => 'deduped.tsv.gz',
+ Path => $datafile);
$mcontent->add_part($mdatafile);
$mcontent->add_part($mdatafile);
-open M, "|/usr/sbin/sendmail -t -oi -oee -od
q
"
+open M, "|/usr/sbin/sendmail -t -oi -oee -od
b
"
or fail("fork sendmail failed! ($!)");
$mcontent->print(\*M);
M->error and fail("write sendmail failed! ($!)");
$?=0; close M; $? and fail("sendmail failed code $?");
or fail("fork sendmail failed! ($!)");
$mcontent->print(\*M);
M->error and fail("write sendmail failed! ($!)");
$?=0; close M; $? and fail("sendmail failed code $?");
+
+print header(-type=>'text/plain', -charset=>'us-ascii'),
+ "OK\n"
+ or die $!;