xref: /aoo42x/main/solenv/bin/release_prepare.pl (revision c667dd47)
1#!/usr/bin/env 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
35#use 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    if ( ! defined installer::patch::ReleasesList::Instance()
119        ->{$version}
120        ->{$package_format}
121        ->{$language})
122    {
123        $installer::logger::Info->printf(
124            "there is no recorded information about language '%s' in version '%s'\n",
125            $language,
126            $version);
127        $installer::logger::Info->printf("    skipping\n");
128    }
129    else
130    {
131        # For every language we need
132        # 1. have downloadable installation set available (download if missing)
133        # 2. unpack it to get access to .cab and .msi
134        # 3. unpack .cab so that msimsp.exe can be run
135
136        installer::patch::InstallationSet::ProvideUnpackedCab(
137            $version,
138            $is_current_version,
139            $language,
140            $package_format,
141            $product_name);
142    }
143
144    $installer::logger::Info->decrease_indentation();
145}
146
147
148
149
150sub main ()
151{
152    installer::logger::SetupSimpleLogging();
153
154    my $arguments = ProcessCommandline();
155    $arguments->{'package-format'} = 'msi';
156
157    $installer::logger::Info->print("preparing release build\n");
158    my ($variables, undef, undef)
159        = installer::ziplist::read_openoffice_lst_file(
160        $arguments->{'lst-file'},
161        $arguments->{'product-name'},
162        undef);
163    if ( ! defined $arguments->{'source-version'})
164    {
165        $arguments->{'source-version'} = $variables->{'PREVIOUS_VERSION'};
166        if ( ! defined $arguments->{'source-version'})
167        {
168            $arguments->{'source-version'} = installer::patch::ReleasesList::GetPreviousVersion(
169                $variables->{'PRODUCTVERSION'});
170            if ( ! defined $arguments->{'source-version'})
171            {
172                $installer::logger::Info->printf("ERROR: can not autodetect previous version\n");
173                $installer::logger::Info->printf("       please specify via 'PREVIOUS_VERSION' in %s\n",
174                    $arguments->{'lst-file'});
175                $installer::logger::Info->printf("       or the --source-version commandline option\n");
176                exit(1);
177            }
178        }
179    }
180    my $current_version = $variables->{'PRODUCTVERSION'};
181    $installer::logger::Info->printf("data from '%s'\n", $arguments->{'lst-file'});
182    $installer::logger::Info->printf("name is '%s'\n", $arguments->{'product-name'});
183    $installer::logger::Info->printf("path is '%s'\n", $arguments->{'output-path'});
184    $installer::logger::Info->printf("source version is '%s'\n", $arguments->{'source-version'});
185    $installer::logger::Info->printf("target version is '%s'\n", $current_version);
186
187    foreach my $language (@{$arguments->{'languages'}})
188    {
189        ProcessLanguage(
190            $arguments->{'source-version'},
191            $arguments->{'source-version'} eq $current_version,
192            $language,
193            $arguments->{'package-format'},
194            $arguments->{'product-name'});
195    }
196}
197
198
199main();
200