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