xref: /aoo41x/main/solenv/bin/release_prepare.pl (revision ba69edf5)
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
35677600b0SAndre Fischer#use Carp::Always;
369f91b7e3SAndre 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
1119f91b7e3SAndre Fischersub ProcessLanguage ($$$$$)
112c9b362f6SAndre Fischer{
1139f91b7e3SAndre 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
118*ba69edf5SAndre Fischer    if ( ! defined installer::patch::ReleasesList::Instance()
119*ba69edf5SAndre Fischer        ->{$version}
120*ba69edf5SAndre Fischer        ->{$package_format}
121*ba69edf5SAndre Fischer        ->{$language})
122*ba69edf5SAndre Fischer    {
123*ba69edf5SAndre Fischer        $installer::logger::Info->printf(
124*ba69edf5SAndre Fischer            "there is no recorded information about language '%s' in version '%s'\n",
125*ba69edf5SAndre Fischer            $language,
126*ba69edf5SAndre Fischer            $version);
127*ba69edf5SAndre Fischer        $installer::logger::Info->printf("    skipping\n");
128*ba69edf5SAndre Fischer    }
129*ba69edf5SAndre Fischer    else
130*ba69edf5SAndre Fischer    {
131*ba69edf5SAndre Fischer        # For every language we need
132*ba69edf5SAndre Fischer        # 1. have downloadable installation set available (download if missing)
133*ba69edf5SAndre Fischer        # 2. unpack it to get access to .cab and .msi
134*ba69edf5SAndre Fischer        # 3. unpack .cab so that msimsp.exe can be run
135*ba69edf5SAndre Fischer
136*ba69edf5SAndre Fischer        installer::patch::InstallationSet::ProvideUnpackedCab(
137*ba69edf5SAndre Fischer            $version,
138*ba69edf5SAndre Fischer            $is_current_version,
139*ba69edf5SAndre Fischer            $language,
140*ba69edf5SAndre Fischer            $package_format,
141*ba69edf5SAndre Fischer            $product_name);
142*ba69edf5SAndre Fischer    }
143c9b362f6SAndre Fischer
144c9b362f6SAndre Fischer    $installer::logger::Info->decrease_indentation();
145c9b362f6SAndre Fischer}
146c9b362f6SAndre Fischer
147c9b362f6SAndre Fischer
148c9b362f6SAndre Fischer
149c9b362f6SAndre Fischer
1509f91b7e3SAndre Fischersub main ()
1519f91b7e3SAndre Fischer{
1529f91b7e3SAndre Fischer    installer::logger::SetupSimpleLogging();
153c9b362f6SAndre Fischer
1549f91b7e3SAndre Fischer    my $arguments = ProcessCommandline();
1559f91b7e3SAndre Fischer    $arguments->{'package-format'} = 'msi';
156c9b362f6SAndre Fischer
1579f91b7e3SAndre Fischer    $installer::logger::Info->print("preparing release build\n");
1589f91b7e3SAndre Fischer    my ($variables, undef, undef)
1599f91b7e3SAndre Fischer        = installer::ziplist::read_openoffice_lst_file(
160c9b362f6SAndre Fischer        $arguments->{'lst-file'},
161c9b362f6SAndre Fischer        $arguments->{'product-name'},
162c9b362f6SAndre Fischer        undef);
1639f91b7e3SAndre Fischer    if ( ! defined $arguments->{'source-version'})
1649f91b7e3SAndre Fischer    {
1659f91b7e3SAndre Fischer        $arguments->{'source-version'} = $variables->{'PREVIOUS_VERSION'};
1669f91b7e3SAndre Fischer        if ( ! defined $arguments->{'source-version'})
1679f91b7e3SAndre Fischer        {
1689f91b7e3SAndre Fischer            $arguments->{'source-version'} = installer::patch::ReleasesList::GetPreviousVersion(
1699f91b7e3SAndre Fischer                $variables->{'PRODUCTVERSION'});
1709f91b7e3SAndre Fischer            if ( ! defined $arguments->{'source-version'})
1719f91b7e3SAndre Fischer            {
1729f91b7e3SAndre Fischer                $installer::logger::Info->printf("ERROR: can not autodetect previous version\n");
1739f91b7e3SAndre Fischer                $installer::logger::Info->printf("       please specify via 'PREVIOUS_VERSION' in %s\n",
1749f91b7e3SAndre Fischer                    $arguments->{'lst-file'});
1759f91b7e3SAndre Fischer                $installer::logger::Info->printf("       or the --source-version commandline option\n");
1769f91b7e3SAndre Fischer                exit(1);
1779f91b7e3SAndre Fischer            }
1789f91b7e3SAndre Fischer        }
1799f91b7e3SAndre Fischer    }
1809f91b7e3SAndre Fischer    my $current_version = $variables->{'PRODUCTVERSION'};
1819f91b7e3SAndre Fischer    $installer::logger::Info->printf("data from '%s'\n", $arguments->{'lst-file'});
1829f91b7e3SAndre Fischer    $installer::logger::Info->printf("name is '%s'\n", $arguments->{'product-name'});
1839f91b7e3SAndre Fischer    $installer::logger::Info->printf("path is '%s'\n", $arguments->{'output-path'});
1849f91b7e3SAndre Fischer    $installer::logger::Info->printf("source version is '%s'\n", $arguments->{'source-version'});
1859f91b7e3SAndre Fischer    $installer::logger::Info->printf("target version is '%s'\n", $current_version);
1869f91b7e3SAndre Fischer
1879f91b7e3SAndre Fischer    foreach my $language (@{$arguments->{'languages'}})
1889f91b7e3SAndre Fischer    {
1899f91b7e3SAndre Fischer        ProcessLanguage(
1909f91b7e3SAndre Fischer            $arguments->{'source-version'},
1919f91b7e3SAndre Fischer            $arguments->{'source-version'} eq $current_version,
1929f91b7e3SAndre Fischer            $language,
1939f91b7e3SAndre Fischer            $arguments->{'package-format'},
1949f91b7e3SAndre Fischer            $arguments->{'product-name'});
1959f91b7e3SAndre Fischer    }
196c9b362f6SAndre Fischer}
197c9b362f6SAndre Fischer
1989f91b7e3SAndre Fischer
1999f91b7e3SAndre Fischermain();
200