1cdf0e10cSrcweir: # -*- perl -*-
2*2123d757SAndrew Rist#**************************************************************
3*2123d757SAndrew Rist#
4*2123d757SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5*2123d757SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6*2123d757SAndrew Rist#  distributed with this work for additional information
7*2123d757SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8*2123d757SAndrew Rist#  to you under the Apache License, Version 2.0 (the
9*2123d757SAndrew Rist#  "License"); you may not use this file except in compliance
10*2123d757SAndrew Rist#  with the License.  You may obtain a copy of the License at
11*2123d757SAndrew Rist#
12*2123d757SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13*2123d757SAndrew Rist#
14*2123d757SAndrew Rist#  Unless required by applicable law or agreed to in writing,
15*2123d757SAndrew Rist#  software distributed under the License is distributed on an
16*2123d757SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*2123d757SAndrew Rist#  KIND, either express or implied.  See the License for the
18*2123d757SAndrew Rist#  specific language governing permissions and limitations
19*2123d757SAndrew Rist#  under the License.
20*2123d757SAndrew Rist#
21*2123d757SAndrew Rist#**************************************************************
22cdf0e10cSrcweir
23cdf0e10cSrcweir
24cdf0e10cSrcweir# generates of the component schema list mapping file, which
25cdf0e10cSrcweir# describes the mapping between OOR and LDAP
26cdf0e10cSrcweir
27cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
28cdf0e10cSrcweir	if 0;
29cdf0e10cSrcweir
30cdf0e10cSrcweir#creating the output file
31cdf0e10cSrcweiropen(OUTFILE, ">$ARGV[0]") or die "can't open >$ARGV[0]";
32cdf0e10cSrcweir
33cdf0e10cSrcweir#open the makefile
34cdf0e10cSrcweiropen(INFILE, "makefile.mk") or die "can't open makefile.mk";
35cdf0e10cSrcweir
36cdf0e10cSrcweir$inxcs=0;
37cdf0e10cSrcweir
38cdf0e10cSrcweir#search all schemas in the makefile except userprofile and format them as e.g org.openoffice.Inet
39cdf0e10cSrcweirwhile(<INFILE>) {
40cdf0e10cSrcweir	tr/\r\n//d;
41cdf0e10cSrcweir
42cdf0e10cSrcweir	if (/^\s*XCSFILES/) {
43cdf0e10cSrcweir		$inxcs++;
44cdf0e10cSrcweir	}
45cdf0e10cSrcweir	next unless $inxcs;
46cdf0e10cSrcweir
47cdf0e10cSrcweir	if ($inxcs) {
48cdf0e10cSrcweir
49cdf0e10cSrcweir		$inxcs=0 unless /\\$/;
50cdf0e10cSrcweir
51cdf0e10cSrcweir		next if (/^\s*XCSFILES/);
52cdf0e10cSrcweir		next if (/UserProfile/);
53cdf0e10cSrcweir
54cdf0e10cSrcweir		s/^\s+//;
55cdf0e10cSrcweir		s/\s*\\$//;
56cdf0e10cSrcweir		s/\.xcs.*$//;
57cdf0e10cSrcweir		s#\$/#.#g;
58cdf0e10cSrcweir
59cdf0e10cSrcweir		push(@comp_names, $_);
60cdf0e10cSrcweir	}
61cdf0e10cSrcweir}
62cdf0e10cSrcweirclose(INFILE);
63cdf0e10cSrcweir
64cdf0e10cSrcweir# create the properites file
65cdf0e10cSrcweir
66cdf0e10cSrcweirprint OUTFILE "# location of the component schema \n";
67cdf0e10cSrcweirprint OUTFILE "component-schema=schema\n\n";
68cdf0e10cSrcweir
69cdf0e10cSrcweirprint OUTFILE "# location of the component data \n";
70cdf0e10cSrcweirprint OUTFILE "component-data=data\n\n";
71cdf0e10cSrcweir
72cdf0e10cSrcweir$comps=join (';',@comp_names);
73cdf0e10cSrcweirprint OUTFILE "# installed components \n";
74cdf0e10cSrcweirprint OUTFILE "components=$comps\n\n";
75cdf0e10cSrcweir
76cdf0e10cSrcweirprint OUTFILE "# component mapping \n";
77cdf0e10cSrcweirforeach (@comp_names) {
78cdf0e10cSrcweir	$myCompName=$_;
79cdf0e10cSrcweir
80cdf0e10cSrcweir	s#org.openoffice.#oo-#g;
81cdf0e10cSrcweir	s#\.#-#g;
82cdf0e10cSrcweir
83cdf0e10cSrcweir	$myLdapName=lc $_;
84cdf0e10cSrcweir
85cdf0e10cSrcweir	print OUTFILE "component/$myCompName/attribute=$myLdapName-attr\n";
86cdf0e10cSrcweir	print OUTFILE "component/$myCompName/objectclass=$myLdapName-class\n\n";
87cdf0e10cSrcweir}
88cdf0e10cSrcweir
89cdf0e10cSrcweirclose(OUTFILE);
90cdf0e10cSrcweir
91cdf0e10cSrcweirexit 0;
92