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