xref: /aoo4110/main/solenv/bin/makemani.pl (revision b1cdbd2c)
1#! /usr/bin/perl -w
2    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3        if 0; #$running_under_some_shell
4#**************************************************************
5#
6#  Licensed to the Apache Software Foundation (ASF) under one
7#  or more contributor license agreements.  See the NOTICE file
8#  distributed with this work for additional information
9#  regarding copyright ownership.  The ASF licenses this file
10#  to you under the Apache License, Version 2.0 (the
11#  "License"); you may not use this file except in compliance
12#  with the License.  You may obtain a copy of the License at
13#
14#    http://www.apache.org/licenses/LICENSE-2.0
15#
16#  Unless required by applicable law or agreed to in writing,
17#  software distributed under the License is distributed on an
18#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19#  KIND, either express or implied.  See the License for the
20#  specific language governing permissions and limitations
21#  under the License.
22#
23#**************************************************************
24
25
26
27use strict;
28use File::Find ();
29use Cwd qw (cwd);
30
31my @findlist;
32
33# Set the variable $File::Find::dont_use_nlink if you're using AFS,
34# since AFS cheats.
35
36# for the convenience of &wanted calls, including -eval statements:
37use vars qw/*name *dir *prune/;
38*name   = *File::Find::name;
39*dir    = *File::Find::dir;
40*prune  = *File::Find::prune;
41
42sub wanted;
43
44
45
46sub wanted {
47    /^.*\.xc(s|u)\z/s
48    && ( push @findlist, $name );
49#    && ( push @findlist, $name ) && print("$name\n");
50}
51
52sub usage
53{
54    print STDERR "\n$0 - append *.xcu file entries to .oxt manifest.xml\n\n";
55    print STDERR "usage: $0 <static_part> <start dir> <search dir> <destination dir>\n\n";
56    print STDERR "  static part - file containig all other content for mainfest.xml\n";
57    print STDERR "  start dir - directory to change to before starting search\n";
58    print STDERR "  out dir - destination directory to write manifes.xml to\n\n";
59    exit 1;
60}
61
62if ( $#ARGV != 3 ) { usage(); };
63
64my $manifest_head = $ARGV[0];
65my $start_dir = $ARGV[1];
66my $dynamic_dir = $ARGV[2];
67my $out_dir = $ARGV[3];
68
69print "################################################\n";
70print "#                                              #\n";
71print "# just a prototype - for testing purpose only! #\n";
72print "#                                              #\n";
73print "################################################\n\n";
74
75
76# Traverse desired filesystems
77my $work_dir = cwd();
78chdir $start_dir or die "$0: ERROR - cannot change directory to \"$start_dir\"\n";
79File::Find::find({wanted => \&wanted}, $dynamic_dir);
80chdir $work_dir or die "$0: ERROR - oops... cannot change dir to where i came from!\n";
81
82open (HEAD, "$manifest_head") or die "$0: ERROR - Cannot open $manifest_head\n";
83my @headlines = <HEAD>;
84close HEAD;
85chomp @headlines;
86chomp @findlist;
87
88my @bodylines;
89my @taillines = ("</manifest:manifest>");
90
91foreach my $i (@findlist) {
92    if ($i =~ m/^.*\.xcu\z/s) {
93        push @bodylines, " <manifest:file-entry manifest:media-type=\"application/vnd.sun.star.configuration-data\"";
94    } else {
95        push @bodylines, " <manifest:file-entry manifest:media-type=\"application/vnd.sun.star.configuration-schema\"";
96    }
97    push @bodylines, "              manifest:full-path=\"$i\"/>";
98}
99
100open (MANIOUT,">$out_dir/manifest.xml") or die "$0: ERROR - cannot open \"$out_dir/manifest.xml\" for writing.\n";
101binmode MANIOUT;
102
103foreach my $j (@headlines, @bodylines, @taillines) {
104    print MANIOUT "$j\n";
105}
106
107close MANIOUT;
108
109