Accepting request 320566 from mozilla:addons
- Recognize <Description> XML tags with arbitrary namespace prefixes OBS-URL: https://build.opensuse.org/request/show/320566 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mozaddon-devel?expand=0&rev=3
This commit is contained in:
commit
ae2ba79b7e
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Aug 5 09:41:47 UTC 2015 - jengelh@inai.de
|
||||||
|
|
||||||
|
- Recognize <Description> XML tags with arbitrary namespace
|
||||||
|
prefixes
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Apr 1 20:36:52 UTC 2013 - jengelh@inai.de
|
Mon Apr 1 20:36:52 UTC 2013 - jengelh@inai.de
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package mozaddon-devel
|
# spec file for package mozaddon-devel
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: mozaddon-devel
|
Name: mozaddon-devel
|
||||||
Version: 0
|
Version: 1
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: RPM macros for building Mozilla extensions under openSUSE
|
Summary: RPM macros for building Mozilla extensions under openSUSE
|
||||||
License: SUSE-Public-Domain
|
License: SUSE-Public-Domain
|
||||||
|
@ -3,53 +3,82 @@
|
|||||||
# authored by Jan Engelhardt, 2011-03-24
|
# authored by Jan Engelhardt, 2011-03-24
|
||||||
# released into the Public Domain
|
# released into the Public Domain
|
||||||
#
|
#
|
||||||
|
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
|
||||||
use XML::Simple;
|
use XML::Simple;
|
||||||
|
&main();
|
||||||
|
|
||||||
my $file = shift || die "Usage: $0 [install.rdf|somefile.xpi]\n";
|
sub get_rdf
|
||||||
my $xml;
|
{
|
||||||
|
my $file = shift @_;
|
||||||
|
|
||||||
if ($file =~ /\.xpi$/) {
|
if ($file eq "install.rdf") {
|
||||||
use Archive::Zip qw/:ERROR_CODES :CONSTANTS/;
|
return XMLin($file);
|
||||||
|
}
|
||||||
|
if (substr($file, -4, 4) eq ".xpi") {
|
||||||
my $zip = Archive::Zip->new();
|
my $zip = Archive::Zip->new();
|
||||||
if ( $zip->read($file) != AZ_OK ) {
|
if ($zip->read($file) != AZ_OK) {
|
||||||
die "zip file read error\n";
|
die "zip file read error\n";
|
||||||
}
|
}
|
||||||
my $data = $zip->contents("install.rdf");
|
my $data = $zip->contents("install.rdf");
|
||||||
die "missing install.rdf in $file\n" unless $data;
|
die "missing install.rdf in $file\n" unless $data;
|
||||||
$xml = XMLin($data) || die "$!\n";
|
return XMLin($data);
|
||||||
} elsif ($file =~ /install.rdf/) {
|
}
|
||||||
$xml = XMLin($file) || die "$!\n";
|
|
||||||
} else {
|
|
||||||
die "unsupported file format\n";
|
die "unsupported file format\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $desc;
|
sub get_desc
|
||||||
for my $tag (qw/RDF:Description Description/) {
|
{
|
||||||
if (exists $xml->{$tag}) {
|
my $xml = shift @_;
|
||||||
if (ref $xml->{$tag} eq 'ARRAY') {
|
my $desc;
|
||||||
$desc = $xml->{$tag};
|
foreach my $tag (keys %$xml) {
|
||||||
} else {
|
if ($tag !~ m{^(\w+:)?Description$}) {
|
||||||
$desc = [ $xml->{$tag} ];
|
next;
|
||||||
}
|
}
|
||||||
|
if (ref($xml->{$tag}) eq "ARRAY") {
|
||||||
|
return $xml->{$tag};
|
||||||
|
}
|
||||||
|
return [$xml->{$tag}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $uuid;
|
sub get_id
|
||||||
my $id;
|
{
|
||||||
for my $x (@$desc) {
|
my $desc = shift @_;
|
||||||
if ($x->{"em:id"} =~ /{[[:xdigit:]]+-/) {
|
my $id;
|
||||||
print STDERR "Warning: multiple uuids!\n" if defined $uuid;
|
|
||||||
$uuid = $x->{"em:id"};
|
foreach (qw(id em:id)) {
|
||||||
} elsif ($x->{"em:id"} =~ /@/) {
|
if (exists($desc->{$_})) {
|
||||||
print STDERR "Warning: multiple ids!\n" if defined $id;
|
$id = $desc->{$_};
|
||||||
$id = $x->{"em:id"};
|
last;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $id) {
|
sub main
|
||||||
print "$id\n";
|
{
|
||||||
} elsif (defined $uuid) {
|
my $file = shift @ARGV;
|
||||||
print "$uuid\n";
|
if (!defined($file)) {
|
||||||
} else {
|
print "Usage: $0 {install.rdf|something.xpi}\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
|
}
|
||||||
|
my $xml = get_rdf($file);
|
||||||
|
if (!defined($xml)) {
|
||||||
|
die "xml: $!\n";
|
||||||
|
}
|
||||||
|
my $desc_list = &get_desc($xml);
|
||||||
|
my $id;
|
||||||
|
foreach my $one_desc (@$desc_list) {
|
||||||
|
my $value = &get_id($one_desc);
|
||||||
|
if ($value =~ /\@|{[[:xdigit:]]+-/) {
|
||||||
|
if (defined($id)) {
|
||||||
|
print STDERR "Warning: multiple IDs/UUIDs!\n";
|
||||||
|
}
|
||||||
|
$id = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!defined($id)) {
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
print "$id\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user