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