xref: /trunk/main/solenv/bin/gen_update_info.pl (revision cdf0e10c)
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3        if 0;
4
5#*************************************************************************
6#
7# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8#
9# Copyright 2000, 2010 Oracle and/or its affiliates.
10#
11# OpenOffice.org - a multi-platform office productivity suite
12#
13# This file is part of OpenOffice.org.
14#
15# OpenOffice.org is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Lesser General Public License version 3
17# only, as published by the Free Software Foundation.
18#
19# OpenOffice.org is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22# GNU Lesser General Public License version 3 for more details
23# (a copy is included in the LICENSE file that accompanied this code).
24#
25# You should have received a copy of the GNU Lesser General Public License
26# version 3 along with OpenOffice.org.  If not, see
27# <http://www.openoffice.org/license.html>
28# for a copy of the LGPLv3 License.
29#
30#*************************************************************************
31
32
33#*********************************************************************
34#
35# main
36#
37
38my($product, $buildid, $id, $os, $arch, $lstfile, $languages, $productname, $productversion, $productedition);
39
40while ($_ = $ARGV[0], /^-/) {
41    shift;
42    last if /^--$/;
43    if (/^--product/) {
44        $product= $ARGV[0];
45        shift;
46    }
47    if (/^--buildid/) {
48        $buildid = $ARGV[0];
49        shift;
50    }
51    if (/^--os/) {
52        $os = $ARGV[0];
53        shift;
54    }
55    if (/^--arch/) {
56        $arch = $ARGV[0];
57        shift;
58    }
59    if (/^--lstfile/) {
60        $lstfile = $ARGV[0];
61        shift;
62    }
63    if (/^--languages/) {
64        $languages = $ARGV[0];
65        shift;
66    }
67}
68
69$sourcefile = $ARGV[0];
70
71if( $^O =~ /cygwin/i ) {
72    # We might get paths with backslashes, fix that.
73    $lstfile =~ s/\\/\//g;
74    $sourcefile =~ s/\\/\//g;
75}
76
77# read openoffice.lst
78# reading Globals section
79unless(open(LSTFILE, "sed -n \"/^Globals\$/,/^}\$/ p\" $lstfile |")) {
80    print STDERR "Can't open $lstfile file: $!\n";
81    return;
82}
83
84while (<LSTFILE>) {
85    if( /\bPRODUCTNAME / ) {
86        chomp;
87        s/.*PRODUCTNAME //;
88        $productname = $_;
89    }
90    if( /\bPACKAGEVERSION / ) {
91        chomp;
92        s/.*PACKAGEVERSION //;
93        $productversion = $_;
94    }
95    if( /\bPRODUCTEDITION / ) {
96        chomp;
97        s/.*PRODUCTEDITION //;
98        $productedition = $_;
99    }
100}
101
102close(LSTFILE);
103
104### may be hierarchical ...
105if(open(LSTFILE, "sed -n \"/^$product:/,/^}\$/ p\" $lstfile |")) {
106    while (<LSTFILE>) {
107        if ( /^$product\s?:\s?(\w+)$/ ) {
108            $product = $1;
109        }
110        if( /\bPRODUCTEDITION / ) {
111            chomp;
112            s/.*PRODUCTEDITION //;
113            $productedition = $_;
114        }
115    }
116}
117close(LSTFILE);
118
119# Reading product specific settings
120
121unless(open(LSTFILE, "sed -n \"/^$product\$/,/^}\$/ p\" $lstfile |")) {
122    print STDERR "Can't open $lstfile file: $!\n";
123    return;
124}
125
126while (<LSTFILE>) {
127    if( /\bPRODUCTNAME / ) {
128        chomp;
129        s/.*PRODUCTNAME //;
130        $productname = $_;
131    }
132    if( /\bPACKAGEVERSION / ) {
133        chomp;
134        s/.*PACKAGEVERSION //;
135        $productversion = $_;
136    }
137    if( /\bPRODUCTEDITION / ) {
138        chomp;
139        s/.*PRODUCTEDITION //;
140        $productedition = $_;
141    }
142}
143
144close(LSTFILE);
145
146# simulate the behavior of make_installer.pl when writing versionrc
147unless( "$os" eq "Windows" ) {
148  $languages =~ s/_.*//;
149}
150
151$id = $productversion;
152$id =~ s/\..*//;
153$id = $productname . "_" . $id . "_" . $languages;
154
155# open input file
156unless (open(SOURCE, $sourcefile)) {
157    print STDERR "Can't open $sourcefile file: $!\n";
158    return;
159}
160
161while (<SOURCE>) {
162   s/:id></:id>$id</;
163   s/buildid></buildid>$buildid</;
164   s/os></os>$os</;
165   s/arch></arch>$arch</;
166   if ( $productedition ) {
167       s/edition></edition>$productedition</;
168   } else {
169       next if ( /edition></ );
170   }
171   s/version></version>$productversion</;
172   s/name></name>$productname</;
173   print;
174}
175
176close(SOURCE);
177