merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / makemani.pl
blobca6ff5a0b4e3ef244268e2ab909ba93c6d7204a6
1 #! /usr/bin/perl -w
2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if 0; #$running_under_some_shell
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 #
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: makemani.pl,v $
14 # $Revision: 1.5 $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
35 use strict;
36 use File::Find ();
37 use Cwd qw (cwd);
39 my @findlist;
41 # Set the variable $File::Find::dont_use_nlink if you're using AFS,
42 # since AFS cheats.
44 # for the convenience of &wanted calls, including -eval statements:
45 use vars qw/*name *dir *prune/;
46 *name = *File::Find::name;
47 *dir = *File::Find::dir;
48 *prune = *File::Find::prune;
50 sub wanted;
54 sub wanted {
55 /^.*\.xc(s|u)\z/s
56 && ( push @findlist, $name );
57 # && ( push @findlist, $name ) && print("$name\n");
60 sub usage
62 print STDERR "\n$0 - append *.xcu file entries to .oxt manifest.xml\n\n";
63 print STDERR "usage: $0 <static_part> <start dir> <search dir> <destination dir>\n\n";
64 print STDERR " static part - file containig all other content for mainfest.xml\n";
65 print STDERR " start dir - directory to change to before starting search\n";
66 print STDERR " out dir - destination directory to write manifes.xml to\n\n";
67 exit 1;
70 if ( $#ARGV != 3 ) { usage(); };
72 my $manifest_head = $ARGV[0];
73 my $start_dir = $ARGV[1];
74 my $dynamic_dir = $ARGV[2];
75 my $out_dir = $ARGV[3];
77 print "################################################\n";
78 print "# #\n";
79 print "# just a prototype - for testing purpose only! #\n";
80 print "# #\n";
81 print "################################################\n\n";
84 # Traverse desired filesystems
85 my $work_dir = cwd();
86 chdir $start_dir or die "$0: ERROR - cannot change directory to \"$start_dir\"\n";
87 File::Find::find({wanted => \&wanted}, $dynamic_dir);
88 chdir $work_dir or die "$0: ERROR - oops... cannot change dir to where i came from!\n";
90 open (HEAD, "$manifest_head") or die "$0: ERROR - Cannot open $manifest_head\n";
91 my @headlines = <HEAD>;
92 close HEAD;
93 chomp @headlines;
94 chomp @findlist;
96 my @bodylines;
97 my @taillines = ("</manifest:manifest>");
99 foreach my $i (@findlist) {
100 if ($i =~ m/^.*\.xcu\z/s) {
101 push @bodylines, " <manifest:file-entry manifest:media-type=\"application/vnd.sun.star.configuration-data\"";
102 } else {
103 push @bodylines, " <manifest:file-entry manifest:media-type=\"application/vnd.sun.star.configuration-schema\"";
105 push @bodylines, " manifest:full-path=\"$i\"/>";
108 open (MANIOUT,">$out_dir/manifest.xml") or die "$0: ERROR - cannot open \"$out_dir/manifest.xml\" for writing.\n";
109 binmode MANIOUT;
111 foreach my $j (@headlines, @bodylines, @taillines) {
112 print MANIOUT "$j\n";
115 close MANIOUT;