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