xref: /aoo41x/main/solenv/bin/release_prepare.pl (revision 9f91b7e3)
1c9b362f6SAndre Fischer#!/usr/bin/perl -w
2c9b362f6SAndre Fischer
3c9b362f6SAndre Fischer#**************************************************************
4c9b362f6SAndre Fischer#
5c9b362f6SAndre Fischer#  Licensed to the Apache Software Foundation (ASF) under one
6c9b362f6SAndre Fischer#  or more contributor license agreements.  See the NOTICE file
7c9b362f6SAndre Fischer#  distributed with this work for additional information
8c9b362f6SAndre Fischer#  regarding copyright ownership.  The ASF licenses this file
9c9b362f6SAndre Fischer#  to you under the Apache License, Version 2.0 (the
10c9b362f6SAndre Fischer#  "License"); you may not use this file except in compliance
11c9b362f6SAndre Fischer#  with the License.  You may obtain a copy of the License at
12c9b362f6SAndre Fischer#
13c9b362f6SAndre Fischer#    http://www.apache.org/licenses/LICENSE-2.0
14c9b362f6SAndre Fischer#
15c9b362f6SAndre Fischer#  Unless required by applicable law or agreed to in writing,
16c9b362f6SAndre Fischer#  software distributed under the License is distributed on an
17c9b362f6SAndre Fischer#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18c9b362f6SAndre Fischer#  KIND, either express or implied.  See the License for the
19c9b362f6SAndre Fischer#  specific language governing permissions and limitations
20c9b362f6SAndre Fischer#  under the License.
21c9b362f6SAndre Fischer#
22c9b362f6SAndre Fischer#**************************************************************
23c9b362f6SAndre Fischer
24c9b362f6SAndre Fischeruse lib ("$ENV{SOLARENV}/bin/modules");
25c9b362f6SAndre Fischeruse installer::patch::InstallationSet;
26c9b362f6SAndre Fischeruse installer::patch::Msi;
27c9b362f6SAndre Fischeruse installer::patch::ReleasesList;
28c9b362f6SAndre Fischeruse installer::ziplist;
29c9b362f6SAndre Fischeruse installer::logger;
30c9b362f6SAndre Fischer
31c9b362f6SAndre Fischeruse Getopt::Long;
32c9b362f6SAndre Fischeruse Pod::Usage;
33c9b362f6SAndre Fischeruse Digest;
34c9b362f6SAndre Fischer
35*9f91b7e3SAndre Fischeruse Carp::Always;
36*9f91b7e3SAndre Fischer
37c9b362f6SAndre Fischeruse strict;
38c9b362f6SAndre Fischer
39c9b362f6SAndre Fischer=head1 NAME
40c9b362f6SAndre Fischer
41c9b362f6SAndre Fischer    release_prepare.pl - Several functions to prepare release builds
42c9b362f6SAndre Fischer
43c9b362f6SAndre Fischer=head1 SYNOPSIS
44c9b362f6SAndre Fischer
45c9b362f6SAndre Fischer    release_prepare.pl [options] <language1> <language2> ...
46c9b362f6SAndre Fischer
47c9b362f6SAndre Fischer    Options:
48c9b362f6SAndre Fischer        --lst-file <filename>
49c9b362f6SAndre Fischer             Path to the .lst file, eg ../util/openoffice.lst
50c9b362f6SAndre Fischer        --product-name <product-name>
51c9b362f6SAndre Fischer             The product name, eg Apache_OpenOffice
52c9b362f6SAndre Fischer        --output-path <path>
53c9b362f6SAndre Fischer             Path to the instsetoo_native platform output tree
54c9b362f6SAndre Fischer        --source-version <major>.<minor>.<micro>
55c9b362f6SAndre Fischer             Override version number of the source.  If not given it is computed from the target version.
56c9b362f6SAndre Fischer
57c9b362f6SAndre Fischer=head1 DESCRIPTION
58c9b362f6SAndre Fischer
59c9b362f6SAndre Fischer    Prepare a release build:
60c9b362f6SAndre Fischer
61c9b362f6SAndre Fischer        - Provide installation sets of the previous version.
62c9b362f6SAndre Fischer          If they are not in ext_sources/ then they are downloaded.
63c9b362f6SAndre Fischer
64c9b362f6SAndre Fischer        - Unpack the installation sets.
65c9b362f6SAndre Fischer
66c9b362f6SAndre Fischer=cut
67c9b362f6SAndre Fischer
68c9b362f6SAndre Fischer
69c9b362f6SAndre Fischersub ProcessCommandline ()
70c9b362f6SAndre Fischer{
71c9b362f6SAndre Fischer    my $arguments = {
72c9b362f6SAndre Fischer        'lst-file' => undef,
73c9b362f6SAndre Fischer        'product-name' => undef,
74c9b362f6SAndre Fischer        'output-path' => undef,
75c9b362f6SAndre Fischer        'source-version' => undef};
76c9b362f6SAndre Fischer
77c9b362f6SAndre Fischer    if ( ! GetOptions(
78c9b362f6SAndre Fischer               "lst-file=s", \$arguments->{'lst-file'},
79c9b362f6SAndre Fischer               "product-name=s", \$arguments->{'product-name'},
80c9b362f6SAndre Fischer               "output-path=s", \$arguments->{'output-path'},
81c9b362f6SAndre Fischer               "source-version:s" => \$arguments->{'source-version'}
82c9b362f6SAndre Fischer        ))
83c9b362f6SAndre Fischer    {
84c9b362f6SAndre Fischer        pod2usage(1);
85c9b362f6SAndre Fischer    }
86c9b362f6SAndre Fischer
87c9b362f6SAndre Fischer    if ( ! defined $arguments->{'lst-file'})
88c9b362f6SAndre Fischer    {
89c9b362f6SAndre Fischer        print STDERR "lst-file missing, please provide --lst-file\n";
90c9b362f6SAndre Fischer        pod2usage(2);
91c9b362f6SAndre Fischer    }
92c9b362f6SAndre Fischer    if ( ! defined $arguments->{'product-name'})
93c9b362f6SAndre Fischer    {
94c9b362f6SAndre Fischer        print STDERR "product name missing, please provide --product-name\n";
95c9b362f6SAndre Fischer        pod2usage(2);
96c9b362f6SAndre Fischer    }
97c9b362f6SAndre Fischer    if ( ! defined $arguments->{'output-path'})
98c9b362f6SAndre Fischer    {
99c9b362f6SAndre Fischer        print STDERR "output path missing, please provide --output-path\n";
100c9b362f6SAndre Fischer        pod2usage(2);
101c9b362f6SAndre Fischer    }
102c9b362f6SAndre Fischer
103c9b362f6SAndre Fischer    $arguments->{'languages'} = \@ARGV;
104c9b362f6SAndre Fischer
105c9b362f6SAndre Fischer    return $arguments;
106c9b362f6SAndre Fischer}
107c9b362f6SAndre Fischer
108c9b362f6SAndre Fischer
109c9b362f6SAndre Fischer
110c9b362f6SAndre Fischer
111*9f91b7e3SAndre Fischersub ProcessLanguage ($$$$$)
112c9b362f6SAndre Fischer{
113*9f91b7e3SAndre Fischer    my ($version, $is_current_version, $language, $package_format, $product_name) = @_;
114c9b362f6SAndre Fischer
115c9b362f6SAndre Fischer    $installer::logger::Info->printf("%s\n", $language);
116c9b362f6SAndre Fischer    $installer::logger::Info->increase_indentation();
117c9b362f6SAndre Fischer
118c9b362f6SAndre Fischer    # For every language we need
119c9b362f6SAndre Fischer    # 1. have downloadable installation set available (download if missing)
120c9b362f6SAndre Fischer    # 2. unpack it to get access to .cab and .msi
121c9b362f6SAndre Fischer    # 3. unpack .cab so that msimsp.exe can be run
122c9b362f6SAndre Fischer
123*9f91b7e3SAndre Fischer    installer::patch::InstallationSet::ProvideUnpackedCab(
124*9f91b7e3SAndre Fischer        $version,
125*9f91b7e3SAndre Fischer        $is_current_version,
126c9b362f6SAndre Fischer        $language,
127c9b362f6SAndre Fischer        $package_format,
128c9b362f6SAndre Fischer        $product_name);
129c9b362f6SAndre Fischer
130c9b362f6SAndre Fischer    $installer::logger::Info->decrease_indentation();
131c9b362f6SAndre Fischer}
132c9b362f6SAndre Fischer
133c9b362f6SAndre Fischer
134c9b362f6SAndre Fischer
135c9b362f6SAndre Fischer
136*9f91b7e3SAndre Fischersub main ()
137*9f91b7e3SAndre Fischer{
138*9f91b7e3SAndre Fischer    installer::logger::SetupSimpleLogging();
139c9b362f6SAndre Fischer
140*9f91b7e3SAndre Fischer    my $arguments = ProcessCommandline();
141*9f91b7e3SAndre Fischer    $arguments->{'package-format'} = 'msi';
142c9b362f6SAndre Fischer
143*9f91b7e3SAndre Fischer    $installer::logger::Info->print("preparing release build\n");
144*9f91b7e3SAndre Fischer    my ($variables, undef, undef)
145*9f91b7e3SAndre Fischer        = installer::ziplist::read_openoffice_lst_file(
146c9b362f6SAndre Fischer        $arguments->{'lst-file'},
147c9b362f6SAndre Fischer        $arguments->{'product-name'},
148c9b362f6SAndre Fischer        undef);
149*9f91b7e3SAndre Fischer    if ( ! defined $arguments->{'source-version'})
150*9f91b7e3SAndre Fischer    {
151*9f91b7e3SAndre Fischer        $arguments->{'source-version'} = $variables->{'PREVIOUS_VERSION'};
152*9f91b7e3SAndre Fischer        if ( ! defined $arguments->{'source-version'})
153*9f91b7e3SAndre Fischer        {
154*9f91b7e3SAndre Fischer            $arguments->{'source-version'} = installer::patch::ReleasesList::GetPreviousVersion(
155*9f91b7e3SAndre Fischer                $variables->{'PRODUCTVERSION'});
156*9f91b7e3SAndre Fischer            if ( ! defined $arguments->{'source-version'})
157*9f91b7e3SAndre Fischer            {
158*9f91b7e3SAndre Fischer                $installer::logger::Info->printf("ERROR: can not autodetect previous version\n");
159*9f91b7e3SAndre Fischer                $installer::logger::Info->printf("       please specify via 'PREVIOUS_VERSION' in %s\n",
160*9f91b7e3SAndre Fischer                    $arguments->{'lst-file'});
161*9f91b7e3SAndre Fischer                $installer::logger::Info->printf("       or the --source-version commandline option\n");
162*9f91b7e3SAndre Fischer                exit(1);
163*9f91b7e3SAndre Fischer            }
164*9f91b7e3SAndre Fischer        }
165*9f91b7e3SAndre Fischer    }
166*9f91b7e3SAndre Fischer    my $current_version = $variables->{'PRODUCTVERSION'};
167*9f91b7e3SAndre Fischer    $installer::logger::Info->printf("data from '%s'\n", $arguments->{'lst-file'});
168*9f91b7e3SAndre Fischer    $installer::logger::Info->printf("name is '%s'\n", $arguments->{'product-name'});
169*9f91b7e3SAndre Fischer    $installer::logger::Info->printf("path is '%s'\n", $arguments->{'output-path'});
170*9f91b7e3SAndre Fischer    $installer::logger::Info->printf("source version is '%s'\n", $arguments->{'source-version'});
171*9f91b7e3SAndre Fischer    $installer::logger::Info->printf("target version is '%s'\n", $current_version);
172*9f91b7e3SAndre Fischer
173*9f91b7e3SAndre Fischer    foreach my $language (@{$arguments->{'languages'}})
174*9f91b7e3SAndre Fischer    {
175*9f91b7e3SAndre Fischer        ProcessLanguage(
176*9f91b7e3SAndre Fischer            $arguments->{'source-version'},
177*9f91b7e3SAndre Fischer            $arguments->{'source-version'} eq $current_version,
178*9f91b7e3SAndre Fischer            $language,
179*9f91b7e3SAndre Fischer            $arguments->{'package-format'},
180*9f91b7e3SAndre Fischer            $arguments->{'product-name'});
181*9f91b7e3SAndre Fischer    }
182c9b362f6SAndre Fischer}
183c9b362f6SAndre Fischer
184*9f91b7e3SAndre Fischer
185*9f91b7e3SAndre Fischermain();
186