App-tpnotify
view release on metacpan or search on metacpan
if ($status == -1) {
abend(EX_OSERR, "failed to run $cmd");
} elsif ($status & 127) {
abend(EX_UNAVAILABLE, "$cmd exited on signal " . ($status & 127));
} elsif (my $e = ($status >> 8)) {
abend(EX_UNAVAILABLE, "$cmd exited with status $e");
}
}
# verify
# ------
# Verifies the tarball. Determines canonical package name, extracts the POT
# file and checks if it lists the correct package name in its
# "Project-Id-Version" header and that its msgids differ from the ones
# already registered on the TP.
sub verify {
my ($in, $out);
my $pid = open2($out, $in, "m4 -P - $files{'configure.ac'}")
or abend(EX_NOINPUT, "can't open $files{'configure.ac'}: $!");
print $in <<'EOT';
m4_divert(-1)
m4_changequote([,])
m4_define([AC_INIT],[m4_divert(0)$1
$2[]m4_divert(-1)])
EOT
close $in;
"filename $archive_file does not begin with $package_base");
}
if ($package_base ne $topdir) {
abend(EX_DATAERR,
"toplevel directory $topdir does not begin with $package_base");
}
my $potfile = "po/$package_tarname.pot";
unless ($files{$potfile}) {
abend(EX_DATAERR, "potfile $potfile not found in archive");
}
verify_potfile($files{$potfile});
}
# po_header($FILENAME)
# --------------------
# Extract the PO header from the POT file $FILENAME.
# Returns a reference to a hash: header-name => value.
sub po_header {
my $name = shift;
(my $h = Locale::PO->load_file_asarray($name)->[0]->msgstr)
# po_cmp($A, $B)
# --------------
# Compares two POT files. Returns 'true' if the two files contain exactly
# the same set of msgids.
sub po_cmp {
my ($a,$b) = @_;
po_serialize($a) eq po_serialize($b);
}
# verify_potfile($FILENAME)
# -------------------------
# Verifies the potfile extracted from the archive.
# Checks if the POT file mentions the correct package string in its
# Project-Id-Version header. Downloads the POT file registered on the
# TP and makes sure its msgids are not the same as defined in the POT
# file from the archive.
sub verify_potfile {
my $potname = shift;
my $hdr = po_header($potname);
my $vs = $hdr->{'project-id-version'};
if ($vs ne "$package_name $package_version") {
err("$potname: Project-Id-Version does not match \"$package_name $package_version\"");
exit(EX_DATAERR) unless $force_option;
}
(my $url = $tp_url) =~ s/\$\{domain\}/$package_tarname/;
download($url, dest => \my $content);
unless exists($refile_tab{$refile_method});
abend(EX_USAGE, "refiling method not supported")
unless (&{$refile_tab{$refile_method}{supported}});
}
$wd = tempdir()
or abend(EX_CANTCREAT, "can't create temporary directory: $!");
chdir($wd) or abend(EX_OSERR, "can't change to temporary directory $wd: $!");
get_sources($archive_url);
verify;
notify;
__END__
=head1 NAME
tpnotify - Notifies translationproject.org about new POT file
=head1 SYNOPSIS
( run in 1.098 second using v1.01-cache-2.11-cpan-39bf76dae61 )