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