xref: /trunk/main/solenv/bin/gen_update_info.pl (revision 7e90fac2)
1cdf0e10cSrcweir:
2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
3cdf0e10cSrcweir        if 0;
4cdf0e10cSrcweir
5*7e90fac2SAndrew Rist#**************************************************************
6*7e90fac2SAndrew Rist#
7*7e90fac2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
8*7e90fac2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
9*7e90fac2SAndrew Rist#  distributed with this work for additional information
10*7e90fac2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
11*7e90fac2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
12*7e90fac2SAndrew Rist#  "License"); you may not use this file except in compliance
13*7e90fac2SAndrew Rist#  with the License.  You may obtain a copy of the License at
14*7e90fac2SAndrew Rist#
15*7e90fac2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
16*7e90fac2SAndrew Rist#
17*7e90fac2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
18*7e90fac2SAndrew Rist#  software distributed under the License is distributed on an
19*7e90fac2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20*7e90fac2SAndrew Rist#  KIND, either express or implied.  See the License for the
21*7e90fac2SAndrew Rist#  specific language governing permissions and limitations
22*7e90fac2SAndrew Rist#  under the License.
23*7e90fac2SAndrew Rist#
24*7e90fac2SAndrew Rist#**************************************************************
25*7e90fac2SAndrew Rist
26*7e90fac2SAndrew Rist
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir#*********************************************************************
30cdf0e10cSrcweir#
31cdf0e10cSrcweir# main
32cdf0e10cSrcweir#
33cdf0e10cSrcweir
34cdf0e10cSrcweirmy($product, $buildid, $id, $os, $arch, $lstfile, $languages, $productname, $productversion, $productedition);
35cdf0e10cSrcweir
36cdf0e10cSrcweirwhile ($_ = $ARGV[0], /^-/) {
37cdf0e10cSrcweir    shift;
38cdf0e10cSrcweir    last if /^--$/;
39cdf0e10cSrcweir    if (/^--product/) {
40cdf0e10cSrcweir        $product= $ARGV[0];
41cdf0e10cSrcweir        shift;
42cdf0e10cSrcweir    }
43cdf0e10cSrcweir    if (/^--buildid/) {
44cdf0e10cSrcweir        $buildid = $ARGV[0];
45cdf0e10cSrcweir        shift;
46cdf0e10cSrcweir    }
47cdf0e10cSrcweir    if (/^--os/) {
48cdf0e10cSrcweir        $os = $ARGV[0];
49cdf0e10cSrcweir        shift;
50cdf0e10cSrcweir    }
51cdf0e10cSrcweir    if (/^--arch/) {
52cdf0e10cSrcweir        $arch = $ARGV[0];
53cdf0e10cSrcweir        shift;
54cdf0e10cSrcweir    }
55cdf0e10cSrcweir    if (/^--lstfile/) {
56cdf0e10cSrcweir        $lstfile = $ARGV[0];
57cdf0e10cSrcweir        shift;
58cdf0e10cSrcweir    }
59cdf0e10cSrcweir    if (/^--languages/) {
60cdf0e10cSrcweir        $languages = $ARGV[0];
61cdf0e10cSrcweir        shift;
62cdf0e10cSrcweir    }
63cdf0e10cSrcweir}
64cdf0e10cSrcweir
65cdf0e10cSrcweir$sourcefile = $ARGV[0];
66cdf0e10cSrcweir
67cdf0e10cSrcweirif( $^O =~ /cygwin/i ) {
68cdf0e10cSrcweir    # We might get paths with backslashes, fix that.
69cdf0e10cSrcweir    $lstfile =~ s/\\/\//g;
70cdf0e10cSrcweir    $sourcefile =~ s/\\/\//g;
71cdf0e10cSrcweir}
72cdf0e10cSrcweir
73cdf0e10cSrcweir# read openoffice.lst
74cdf0e10cSrcweir# reading Globals section
75cdf0e10cSrcweirunless(open(LSTFILE, "sed -n \"/^Globals\$/,/^}\$/ p\" $lstfile |")) {
76cdf0e10cSrcweir    print STDERR "Can't open $lstfile file: $!\n";
77cdf0e10cSrcweir    return;
78cdf0e10cSrcweir}
79cdf0e10cSrcweir
80cdf0e10cSrcweirwhile (<LSTFILE>) {
81cdf0e10cSrcweir    if( /\bPRODUCTNAME / ) {
82cdf0e10cSrcweir        chomp;
83cdf0e10cSrcweir        s/.*PRODUCTNAME //;
84cdf0e10cSrcweir        $productname = $_;
85cdf0e10cSrcweir    }
86cdf0e10cSrcweir    if( /\bPACKAGEVERSION / ) {
87cdf0e10cSrcweir        chomp;
88cdf0e10cSrcweir        s/.*PACKAGEVERSION //;
89cdf0e10cSrcweir        $productversion = $_;
90cdf0e10cSrcweir    }
91cdf0e10cSrcweir    if( /\bPRODUCTEDITION / ) {
92cdf0e10cSrcweir        chomp;
93cdf0e10cSrcweir        s/.*PRODUCTEDITION //;
94cdf0e10cSrcweir        $productedition = $_;
95cdf0e10cSrcweir    }
96cdf0e10cSrcweir}
97cdf0e10cSrcweir
98cdf0e10cSrcweirclose(LSTFILE);
99cdf0e10cSrcweir
100cdf0e10cSrcweir### may be hierarchical ...
101cdf0e10cSrcweirif(open(LSTFILE, "sed -n \"/^$product:/,/^}\$/ p\" $lstfile |")) {
102cdf0e10cSrcweir    while (<LSTFILE>) {
103cdf0e10cSrcweir        if ( /^$product\s?:\s?(\w+)$/ ) {
104cdf0e10cSrcweir            $product = $1;
105cdf0e10cSrcweir        }
106cdf0e10cSrcweir        if( /\bPRODUCTEDITION / ) {
107cdf0e10cSrcweir            chomp;
108cdf0e10cSrcweir            s/.*PRODUCTEDITION //;
109cdf0e10cSrcweir            $productedition = $_;
110cdf0e10cSrcweir        }
111cdf0e10cSrcweir    }
112cdf0e10cSrcweir}
113cdf0e10cSrcweirclose(LSTFILE);
114cdf0e10cSrcweir
115cdf0e10cSrcweir# Reading product specific settings
116cdf0e10cSrcweir
117cdf0e10cSrcweirunless(open(LSTFILE, "sed -n \"/^$product\$/,/^}\$/ p\" $lstfile |")) {
118cdf0e10cSrcweir    print STDERR "Can't open $lstfile file: $!\n";
119cdf0e10cSrcweir    return;
120cdf0e10cSrcweir}
121cdf0e10cSrcweir
122cdf0e10cSrcweirwhile (<LSTFILE>) {
123cdf0e10cSrcweir    if( /\bPRODUCTNAME / ) {
124cdf0e10cSrcweir        chomp;
125cdf0e10cSrcweir        s/.*PRODUCTNAME //;
126cdf0e10cSrcweir        $productname = $_;
127cdf0e10cSrcweir    }
128cdf0e10cSrcweir    if( /\bPACKAGEVERSION / ) {
129cdf0e10cSrcweir        chomp;
130cdf0e10cSrcweir        s/.*PACKAGEVERSION //;
131cdf0e10cSrcweir        $productversion = $_;
132cdf0e10cSrcweir    }
133cdf0e10cSrcweir    if( /\bPRODUCTEDITION / ) {
134cdf0e10cSrcweir        chomp;
135cdf0e10cSrcweir        s/.*PRODUCTEDITION //;
136cdf0e10cSrcweir        $productedition = $_;
137cdf0e10cSrcweir    }
138cdf0e10cSrcweir}
139cdf0e10cSrcweir
140cdf0e10cSrcweirclose(LSTFILE);
141cdf0e10cSrcweir
142cdf0e10cSrcweir# simulate the behavior of make_installer.pl when writing versionrc
143cdf0e10cSrcweirunless( "$os" eq "Windows" ) {
144cdf0e10cSrcweir  $languages =~ s/_.*//;
145cdf0e10cSrcweir}
146cdf0e10cSrcweir
147cdf0e10cSrcweir$id = $productversion;
148cdf0e10cSrcweir$id =~ s/\..*//;
149cdf0e10cSrcweir$id = $productname . "_" . $id . "_" . $languages;
150cdf0e10cSrcweir
151cdf0e10cSrcweir# open input file
152cdf0e10cSrcweirunless (open(SOURCE, $sourcefile)) {
153cdf0e10cSrcweir    print STDERR "Can't open $sourcefile file: $!\n";
154cdf0e10cSrcweir    return;
155cdf0e10cSrcweir}
156cdf0e10cSrcweir
157cdf0e10cSrcweirwhile (<SOURCE>) {
158cdf0e10cSrcweir   s/:id></:id>$id</;
159cdf0e10cSrcweir   s/buildid></buildid>$buildid</;
160cdf0e10cSrcweir   s/os></os>$os</;
161cdf0e10cSrcweir   s/arch></arch>$arch</;
162cdf0e10cSrcweir   if ( $productedition ) {
163cdf0e10cSrcweir       s/edition></edition>$productedition</;
164cdf0e10cSrcweir   } else {
165cdf0e10cSrcweir       next if ( /edition></ );
166cdf0e10cSrcweir   }
167cdf0e10cSrcweir   s/version></version>$productversion</;
168cdf0e10cSrcweir   s/name></name>$productname</;
169cdf0e10cSrcweir   print;
170cdf0e10cSrcweir}
171cdf0e10cSrcweir
172cdf0e10cSrcweirclose(SOURCE);
173