xref: /trunk/main/sysui/desktop/share/brand.pl (revision 86e1cf34)
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4
5#**************************************************************
6#
7#  Licensed to the Apache Software Foundation (ASF) under one
8#  or more contributor license agreements.  See the NOTICE file
9#  distributed with this work for additional information
10#  regarding copyright ownership.  The ASF licenses this file
11#  to you under the Apache License, Version 2.0 (the
12#  "License"); you may not use this file except in compliance
13#  with the License.  You may obtain a copy of the License at
14#
15#    http://www.apache.org/licenses/LICENSE-2.0
16#
17#  Unless required by applicable law or agreed to in writing,
18#  software distributed under the License is distributed on an
19#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20#  KIND, either express or implied.  See the License for the
21#  specific language governing permissions and limitations
22#  under the License.
23#
24#**************************************************************
25
26
27
28
29#*********************************************************************
30#
31# main
32#
33
34$destdir = pop @ARGV;
35mkdir $destdir,0777;
36
37$productname = "OpenOffice";
38$productfilename = "apacheopenoffice";
39$prefix = "";
40$iconprefix = "";
41
42while ($_ = $ARGV[0], /^-/) {
43    shift;
44    last if /^--$/;
45    if (/^-p/) {
46        $productname = $ARGV[0];
47        shift;
48    }
49    if (/^-u/) {
50        $productfilename = $ARGV[0];
51        shift;
52    }
53    if (/^--prefix/) {
54        $prefix = $ARGV[0];
55        shift;
56    }
57    if (/^--iconprefix/) {
58        $iconprefix = $ARGV[0];
59        shift;
60    }
61    if (/^--category/) {
62        $category = $ARGV[0];
63        shift;
64    }
65}
66
67
68while (<>) {
69    unless (open INFILE,$ARGV) {
70        print STDOUT "Can't open input file $ARGV: $!\n";
71        exit 1;
72    }
73
74    $srcfile = substr($ARGV, rindex($ARGV, "/") + 1);
75
76    unless (open OUTFILE,"> $destdir/$prefix$srcfile") {
77        print STDOUT "Can't open output file $destdir/$prefix$srcfile: $!\n";
78        exit 1;
79    }
80
81    while (<INFILE>) {
82        # remove possible Windows line-ends
83        chomp;
84
85        # patch all occurrences of openoffice in ICON line with
86        # $prefix
87        s/Icon=/Icon=$iconprefix/;
88
89        # patch all occurrences of openoffice in icon_filename
90        # line with $prefix
91        s/icon_filename=/icon_filename=$iconprefix/;
92
93        # patch all occurrences of openoffice in EXEC line with
94        # $productfilename
95        if ( /Exec/ ) {
96            s/openoffice/$productfilename/;
97        }
98
99        # if $productfilename != "openoffice, add it to the list
100        # of applications.
101        if ( /user_level=$/ ) {
102		    $_ = $_ . $productfilename;
103		} elsif ( /user_level/ ) {
104            s/$productfilename,//;
105            s/user_level=/user_level=$productfilename,/
106        }
107
108        # append special category if specified
109        if ( /Categories/ ) {
110            if ( length($category) > 0 ) {
111                $_ = "$_$category;";
112            }
113        }
114
115        # replace %PRODUCTNAME placeholders
116        s/%PRODUCTNAME/$productname/g;
117
118        print OUTFILE "$_\n";
119    }
120
121    close(OUTFILE);
122    close(INFILE);
123}
124