xref: /trunk/main/sc/util/createExtPackage.pl (revision cdf0e10c)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28use Archive::Zip qw(:ERROR_CODES);
29use File::Basename;
30
31my $zipName = shift || die 'must provide a ext name';
32my $rdbName = shift || die 'must provide a types library';
33my $libName = shift || die 'must provide a component library';
34
35die "can't access type library $rdbName" unless -f $rdbName;
36die "can't access component library $libName" unless -f $libName;
37
38# Read the zip
39my $zip = Archive::Zip->new();
40
41if ( -f $zipName )
42{
43    # be stupid and recreate zip every time
44    # in another iteration lets try to overwrite it instead
45    my $result = 0;
46    $result = unlink($zipName);
47    if ( result != 0 )
48    {
49        die 'can not delete old extension';
50    }
51}
52my $rdb = basename( $rdbName );
53my $lib = basename( $libName );
54
55my $content2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
56$content2 .= "<!DOCTYPE manifest:manifest PUBLIC \"-//OpenOffice.org//DTD Manifest 1.0//EN\" \"Manifest.dtd\">\n";
57$content2 .= "<manifest:manifest xmlns:manifest=\"http://openoffice.org/2001/manifest\">\n";
58$content2 .= "  <manifest:file-entry manifest:media-type=\"application/vnd.sun.star.uno-typelibrary;type=RDB\" manifest:full-path=\"$rdb\"/>\n";
59$content2 .= "  <manifest:file-entry manifest:media-type=\"application/vnd.sun.star.uno-component;type=native\"  manifest:full-path=\"$lib\"/>\n";
60$content2 .= "</manifest:manifest>\n";
61
62$zip->addFile( $rdbName, $rdb );
63$zip->addFile( $libName, $lib );
64$zip->addDirectory( "META-INF" );
65$zip->addFile( "META-INF/manifest.xml", "manifest.xml" );
66$zip->addString( $content2, "META-INF/manifest.xml" );
67exit( $zip->writeToFileNamed($zipName) );
68