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