update dev300-m58
[ooovba.git] / sc / util / createExtPackage.pl
blob2eccb0488cc5ce0d722f6e8798115c0187666c9e
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: createExtPackage.pl,v $
11 # $Revision: 1.3 $
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);
33 use File::Basename;
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;
42 # Read the zip
43 my $zip = Archive::Zip->new();
45 if ( -f $zipName )
47 # be stupid and recreate zip every time
48 # in another iteration lets try to overwrite it instead
49 my $result = 0;
50 $result = unlink($zipName);
51 if ( result != 0 )
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) );