xref: /aoo4110/main/solenv/bin/gen_update_info.pl (revision b1cdbd2c)
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
34my($product, $buildid, $id, $os, $arch, $lstfile, $languages, $productname, $productversion, $productedition);
35
36while ($_ = $ARGV[0], /^-/) {
37    shift;
38    last if /^--$/;
39    if (/^--product/) {
40        $product= $ARGV[0];
41        shift;
42    }
43    if (/^--buildid/) {
44        $buildid = $ARGV[0];
45        shift;
46    }
47    if (/^--os/) {
48        $os = $ARGV[0];
49        shift;
50    }
51    if (/^--arch/) {
52        $arch = $ARGV[0];
53        shift;
54    }
55    if (/^--lstfile/) {
56        $lstfile = $ARGV[0];
57        shift;
58    }
59    if (/^--languages/) {
60        $languages = $ARGV[0];
61        shift;
62    }
63}
64
65$sourcefile = $ARGV[0];
66
67if( $^O =~ /cygwin/i ) {
68    # We might get paths with backslashes, fix that.
69    $lstfile =~ s/\\/\//g;
70    $sourcefile =~ s/\\/\//g;
71}
72
73# read openoffice.lst
74# reading Globals section
75unless(open(LSTFILE, "sed -n \"/^Globals\$/,/^}\$/ p\" $lstfile |")) {
76    print STDERR "Can't open $lstfile file: $!\n";
77    return;
78}
79
80while (<LSTFILE>) {
81    if( /\bPRODUCTNAME / ) {
82        chomp;
83        s/.*PRODUCTNAME //;
84        $productname = $_;
85    }
86    if( /\bPACKAGEVERSION / ) {
87        chomp;
88        s/.*PACKAGEVERSION //;
89        $productversion = $_;
90    }
91    if( /\bPRODUCTEDITION / ) {
92        chomp;
93        s/.*PRODUCTEDITION //;
94        $productedition = $_;
95    }
96}
97
98close(LSTFILE);
99
100### may be hierarchical ...
101if(open(LSTFILE, "sed -n \"/^$product:/,/^}\$/ p\" $lstfile |")) {
102    while (<LSTFILE>) {
103        if ( /^$product\s?:\s?(\w+)$/ ) {
104            $product = $1;
105        }
106        if( /\bPRODUCTEDITION / ) {
107            chomp;
108            s/.*PRODUCTEDITION //;
109            $productedition = $_;
110        }
111    }
112}
113close(LSTFILE);
114
115# Reading product specific settings
116
117unless(open(LSTFILE, "sed -n \"/^$product\$/,/^}\$/ p\" $lstfile |")) {
118    print STDERR "Can't open $lstfile file: $!\n";
119    return;
120}
121
122while (<LSTFILE>) {
123    if( /\bPRODUCTNAME / ) {
124        chomp;
125        s/.*PRODUCTNAME //;
126        $productname = $_;
127    }
128    if( /\bPACKAGEVERSION / ) {
129        chomp;
130        s/.*PACKAGEVERSION //;
131        $productversion = $_;
132    }
133    if( /\bPRODUCTEDITION / ) {
134        chomp;
135        s/.*PRODUCTEDITION //;
136        $productedition = $_;
137    }
138}
139
140close(LSTFILE);
141
142# simulate the behavior of make_installer.pl when writing versionrc
143unless( "$os" eq "Windows" ) {
144  $languages =~ s/_.*//;
145}
146
147$id = $productversion;
148$id =~ s/\..*//;
149$id = $productname . "_" . $id . "_" . $languages;
150
151# open input file
152unless (open(SOURCE, $sourcefile)) {
153    print STDERR "Can't open $sourcefile file: $!\n";
154    return;
155}
156
157while (<SOURCE>) {
158   s/:id></:id>$id</;
159   s/buildid></buildid>$buildid</;
160   s/os></os>$os</;
161   s/arch></arch>$arch</;
162   if ( $productedition ) {
163       s/edition></edition>$productedition</;
164   } else {
165       next if ( /edition></ );
166   }
167   s/version></version>$productversion</;
168   s/name></name>$productname</;
169   print;
170}
171
172close(SOURCE);
173