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