author | Wolfgang Rosenauer <wr@rosenauer.org> |
Thu, 02 Jan 2014 22:32:12 +0100 | |
branch | firefox26 |
changeset 695 | 81c8f51dbf67 |
parent 225 | 5a7504b93699 |
permissions | -rw-r--r-- |
225
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl -w |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
2 |
use XML::Simple; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
3 |
|
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
4 |
my $file = shift || die "Usage: $0 [install.rdf|somefile.xpi]\n"; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
5 |
my $xml; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
6 |
|
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
7 |
if ($file =~ /\.xpi$/) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
8 |
use Archive::Zip qw/:ERROR_CODES :CONSTANTS/; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
9 |
my $zip = Archive::Zip->new(); |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
10 |
if ( $zip->read($file) != AZ_OK ) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
11 |
die "zip file read error\n"; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
12 |
} |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
13 |
my $data = $zip->contents("install.rdf"); |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
14 |
die "missing install.rdf in $file\n" unless $data; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
15 |
$xml = XMLin($data) || die "$!\n"; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
16 |
} elsif ($file =~ /install.rdf/) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
17 |
$xml = XMLin($file) || die "$!\n"; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
18 |
} else { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
19 |
die "unsupported file format\n"; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
20 |
} |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
21 |
|
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
22 |
my $desc; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
23 |
for my $tag (qw/RDF:Description Description/) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
24 |
if (exists $xml->{$tag}) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
25 |
if (ref $xml->{$tag} eq 'ARRAY') { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
26 |
$desc = $xml->{$tag}; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
27 |
} else { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
28 |
$desc = [ $xml->{$tag} ]; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
29 |
} |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
30 |
} |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
31 |
} |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
32 |
|
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
33 |
my $uuid; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
34 |
my $id; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
35 |
for my $x (@$desc) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
36 |
if ($x->{"em:id"} =~ /{[[:xdigit:]]+-/) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
37 |
print STDERR "Warning: multiple uuids!\n" if defined $uuid; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
38 |
$uuid = $x->{"em:id"}; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
39 |
} elsif ($x->{"em:id"} =~ /@/) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
40 |
print STDERR "Warning: multiple ids!\n" if defined $id; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
41 |
$id = $x->{"em:id"}; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
42 |
} |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
43 |
} |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
44 |
|
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
45 |
if (defined $id) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
46 |
print "$id\n"; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
47 |
} elsif (defined $uuid) { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
48 |
print "$uuid\n"; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
49 |
} else { |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
50 |
exit 1; |
5a7504b93699
Provide devel package with helper script and rpm macros for easier addon packaging. (patch submitted from Ludwig Nussel)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
51 |
} |