1*c9b362f6SAndre Fischer#!/usr/bin/perl -w 2*c9b362f6SAndre Fischer 3*c9b362f6SAndre Fischer#************************************************************** 4*c9b362f6SAndre Fischer# 5*c9b362f6SAndre Fischer# Licensed to the Apache Software Foundation (ASF) under one 6*c9b362f6SAndre Fischer# or more contributor license agreements. See the NOTICE file 7*c9b362f6SAndre Fischer# distributed with this work for additional information 8*c9b362f6SAndre Fischer# regarding copyright ownership. The ASF licenses this file 9*c9b362f6SAndre Fischer# to you under the Apache License, Version 2.0 (the 10*c9b362f6SAndre Fischer# "License"); you may not use this file except in compliance 11*c9b362f6SAndre Fischer# with the License. You may obtain a copy of the License at 12*c9b362f6SAndre Fischer# 13*c9b362f6SAndre Fischer# http://www.apache.org/licenses/LICENSE-2.0 14*c9b362f6SAndre Fischer# 15*c9b362f6SAndre Fischer# Unless required by applicable law or agreed to in writing, 16*c9b362f6SAndre Fischer# software distributed under the License is distributed on an 17*c9b362f6SAndre Fischer# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18*c9b362f6SAndre Fischer# KIND, either express or implied. See the License for the 19*c9b362f6SAndre Fischer# specific language governing permissions and limitations 20*c9b362f6SAndre Fischer# under the License. 21*c9b362f6SAndre Fischer# 22*c9b362f6SAndre Fischer#************************************************************** 23*c9b362f6SAndre Fischer 24*c9b362f6SAndre Fischeruse lib ("$ENV{SOLARENV}/bin/modules"); 25*c9b362f6SAndre Fischeruse installer::patch::InstallationSet; 26*c9b362f6SAndre Fischeruse installer::patch::Msi; 27*c9b362f6SAndre Fischeruse installer::patch::ReleasesList; 28*c9b362f6SAndre Fischeruse installer::ziplist; 29*c9b362f6SAndre Fischeruse installer::logger; 30*c9b362f6SAndre Fischer 31*c9b362f6SAndre Fischeruse Getopt::Long; 32*c9b362f6SAndre Fischeruse Pod::Usage; 33*c9b362f6SAndre Fischeruse Digest; 34*c9b362f6SAndre Fischer 35*c9b362f6SAndre Fischeruse strict; 36*c9b362f6SAndre Fischer 37*c9b362f6SAndre Fischer=head1 NAME 38*c9b362f6SAndre Fischer 39*c9b362f6SAndre Fischer release_prepare.pl - Several functions to prepare release builds 40*c9b362f6SAndre Fischer 41*c9b362f6SAndre Fischer=head1 SYNOPSIS 42*c9b362f6SAndre Fischer 43*c9b362f6SAndre Fischer release_prepare.pl [options] <language1> <language2> ... 44*c9b362f6SAndre Fischer 45*c9b362f6SAndre Fischer Options: 46*c9b362f6SAndre Fischer --lst-file <filename> 47*c9b362f6SAndre Fischer Path to the .lst file, eg ../util/openoffice.lst 48*c9b362f6SAndre Fischer --product-name <product-name> 49*c9b362f6SAndre Fischer The product name, eg Apache_OpenOffice 50*c9b362f6SAndre Fischer --output-path <path> 51*c9b362f6SAndre Fischer Path to the instsetoo_native platform output tree 52*c9b362f6SAndre Fischer --source-version <major>.<minor>.<micro> 53*c9b362f6SAndre Fischer Override version number of the source. If not given it is computed from the target version. 54*c9b362f6SAndre Fischer 55*c9b362f6SAndre Fischer=head1 DESCRIPTION 56*c9b362f6SAndre Fischer 57*c9b362f6SAndre Fischer Prepare a release build: 58*c9b362f6SAndre Fischer 59*c9b362f6SAndre Fischer - Provide installation sets of the previous version. 60*c9b362f6SAndre Fischer If they are not in ext_sources/ then they are downloaded. 61*c9b362f6SAndre Fischer 62*c9b362f6SAndre Fischer - Unpack the installation sets. 63*c9b362f6SAndre Fischer 64*c9b362f6SAndre Fischer=cut 65*c9b362f6SAndre Fischer 66*c9b362f6SAndre Fischer 67*c9b362f6SAndre Fischersub ProcessCommandline () 68*c9b362f6SAndre Fischer{ 69*c9b362f6SAndre Fischer my $arguments = { 70*c9b362f6SAndre Fischer 'lst-file' => undef, 71*c9b362f6SAndre Fischer 'product-name' => undef, 72*c9b362f6SAndre Fischer 'output-path' => undef, 73*c9b362f6SAndre Fischer 'source-version' => undef}; 74*c9b362f6SAndre Fischer 75*c9b362f6SAndre Fischer if ( ! GetOptions( 76*c9b362f6SAndre Fischer "lst-file=s", \$arguments->{'lst-file'}, 77*c9b362f6SAndre Fischer "product-name=s", \$arguments->{'product-name'}, 78*c9b362f6SAndre Fischer "output-path=s", \$arguments->{'output-path'}, 79*c9b362f6SAndre Fischer "source-version:s" => \$arguments->{'source-version'} 80*c9b362f6SAndre Fischer )) 81*c9b362f6SAndre Fischer { 82*c9b362f6SAndre Fischer pod2usage(1); 83*c9b362f6SAndre Fischer } 84*c9b362f6SAndre Fischer 85*c9b362f6SAndre Fischer if ( ! defined $arguments->{'lst-file'}) 86*c9b362f6SAndre Fischer { 87*c9b362f6SAndre Fischer print STDERR "lst-file missing, please provide --lst-file\n"; 88*c9b362f6SAndre Fischer pod2usage(2); 89*c9b362f6SAndre Fischer } 90*c9b362f6SAndre Fischer if ( ! defined $arguments->{'product-name'}) 91*c9b362f6SAndre Fischer { 92*c9b362f6SAndre Fischer print STDERR "product name missing, please provide --product-name\n"; 93*c9b362f6SAndre Fischer pod2usage(2); 94*c9b362f6SAndre Fischer } 95*c9b362f6SAndre Fischer if ( ! defined $arguments->{'output-path'}) 96*c9b362f6SAndre Fischer { 97*c9b362f6SAndre Fischer print STDERR "output path missing, please provide --output-path\n"; 98*c9b362f6SAndre Fischer pod2usage(2); 99*c9b362f6SAndre Fischer } 100*c9b362f6SAndre Fischer 101*c9b362f6SAndre Fischer $arguments->{'languages'} = \@ARGV; 102*c9b362f6SAndre Fischer 103*c9b362f6SAndre Fischer return $arguments; 104*c9b362f6SAndre Fischer} 105*c9b362f6SAndre Fischer 106*c9b362f6SAndre Fischer 107*c9b362f6SAndre Fischer 108*c9b362f6SAndre Fischer 109*c9b362f6SAndre Fischersub ProcessLanguage ($$$$) 110*c9b362f6SAndre Fischer{ 111*c9b362f6SAndre Fischer my ($source_version, $language, $package_format, $product_name) = @_; 112*c9b362f6SAndre Fischer 113*c9b362f6SAndre Fischer $installer::logger::Info->printf("%s\n", $language); 114*c9b362f6SAndre Fischer $installer::logger::Info->increase_indentation(); 115*c9b362f6SAndre Fischer 116*c9b362f6SAndre Fischer # For every language we need 117*c9b362f6SAndre Fischer # 1. have downloadable installation set available (download if missing) 118*c9b362f6SAndre Fischer # 2. unpack it to get access to .cab and .msi 119*c9b362f6SAndre Fischer # 3. unpack .cab so that msimsp.exe can be run 120*c9b362f6SAndre Fischer 121*c9b362f6SAndre Fischer # Create paths to unpacked contents of .exe and .cab and determine if they exist. 122*c9b362f6SAndre Fischer # The existence of these paths is taken as flag whether the unpacking has already taken place. 123*c9b362f6SAndre Fischer my $unpacked_exe_path = installer::patch::InstallationSet::GetUnpackedMsiPath( 124*c9b362f6SAndre Fischer $source_version, 125*c9b362f6SAndre Fischer $language, 126*c9b362f6SAndre Fischer $package_format, 127*c9b362f6SAndre Fischer $product_name); 128*c9b362f6SAndre Fischer my $unpacked_cab_path = installer::patch::InstallationSet::GetUnpackedCabPath( 129*c9b362f6SAndre Fischer $source_version, 130*c9b362f6SAndre Fischer $language, 131*c9b362f6SAndre Fischer $package_format, 132*c9b362f6SAndre Fischer $product_name); 133*c9b362f6SAndre Fischer my $exe_is_unpacked = -d $unpacked_exe_path; 134*c9b362f6SAndre Fischer my $cab_is_unpacked = -d $unpacked_cab_path; 135*c9b362f6SAndre Fischer 136*c9b362f6SAndre Fischer if ( ! $exe_is_unpacked) 137*c9b362f6SAndre Fischer { 138*c9b362f6SAndre Fischer # Interpret existence of path as proof that the installation 139*c9b362f6SAndre Fischer # set and the cab file have been successfully unpacked. 140*c9b362f6SAndre Fischer # Nothing to do. 141*c9b362f6SAndre Fischer my $filename = installer::patch::InstallationSet::ProvideDownloadSet( 142*c9b362f6SAndre Fischer $source_version, 143*c9b362f6SAndre Fischer $language, 144*c9b362f6SAndre Fischer $package_format); 145*c9b362f6SAndre Fischer if (defined $filename) 146*c9b362f6SAndre Fischer { 147*c9b362f6SAndre Fischer if ( ! -d $unpacked_exe_path) 148*c9b362f6SAndre Fischer { 149*c9b362f6SAndre Fischer installer::patch::InstallationSet::UnpackExe($filename, $unpacked_exe_path); 150*c9b362f6SAndre Fischer } 151*c9b362f6SAndre Fischer } 152*c9b362f6SAndre Fischer else 153*c9b362f6SAndre Fischer { 154*c9b362f6SAndre Fischer installer::logger::PrintError("could not provide .exe installation set at '%s'\n", $filename); 155*c9b362f6SAndre Fischer } 156*c9b362f6SAndre Fischer } 157*c9b362f6SAndre Fischer else 158*c9b362f6SAndre Fischer { 159*c9b362f6SAndre Fischer $installer::logger::Info->printf("downloadable installation set has already been unpacked to '%s'\n", 160*c9b362f6SAndre Fischer $unpacked_exe_path); 161*c9b362f6SAndre Fischer } 162*c9b362f6SAndre Fischer 163*c9b362f6SAndre Fischer if ( ! $cab_is_unpacked) 164*c9b362f6SAndre Fischer { 165*c9b362f6SAndre Fischer my $cab_filename = File::Spec->catfile($unpacked_exe_path, "openoffice1.cab"); 166*c9b362f6SAndre Fischer if ( ! -f $cab_filename) 167*c9b362f6SAndre Fischer { 168*c9b362f6SAndre Fischer # Cab file does not exist. 169*c9b362f6SAndre Fischer installer::logger::PrintError( 170*c9b362f6SAndre Fischer "could not find .cab file at '%s'. Extraction of .exe seems to have failed.\n", 171*c9b362f6SAndre Fischer $cab_filename); 172*c9b362f6SAndre Fischer } 173*c9b362f6SAndre Fischer 174*c9b362f6SAndre Fischer # Unpack the cab file. 175*c9b362f6SAndre Fischer my $msi = new installer::patch::Msi( 176*c9b362f6SAndre Fischer $source_version, 177*c9b362f6SAndre Fischer $language, 178*c9b362f6SAndre Fischer $product_name); 179*c9b362f6SAndre Fischer 180*c9b362f6SAndre Fischer $installer::logger::Info->printf("unpacking cab file '%s' to '%s'\n", 181*c9b362f6SAndre Fischer $cab_filename, $unpacked_cab_path); 182*c9b362f6SAndre Fischer installer::patch::InstallationSet::UnpackCab( 183*c9b362f6SAndre Fischer $cab_filename, 184*c9b362f6SAndre Fischer $msi, 185*c9b362f6SAndre Fischer $unpacked_cab_path); 186*c9b362f6SAndre Fischer } 187*c9b362f6SAndre Fischer else 188*c9b362f6SAndre Fischer { 189*c9b362f6SAndre Fischer $installer::logger::Info->printf("cab has already been unpacked to\n"); 190*c9b362f6SAndre Fischer $installer::logger::Info->printf(" %s\n", $unpacked_cab_path); 191*c9b362f6SAndre Fischer } 192*c9b362f6SAndre Fischer 193*c9b362f6SAndre Fischer $installer::logger::Info->decrease_indentation(); 194*c9b362f6SAndre Fischer} 195*c9b362f6SAndre Fischer 196*c9b362f6SAndre Fischer 197*c9b362f6SAndre Fischer 198*c9b362f6SAndre Fischer 199*c9b362f6SAndre Fischerinstaller::logger::SetupSimpleLogging("c:/tmp/log"); 200*c9b362f6SAndre Fischer 201*c9b362f6SAndre Fischermy $arguments = ProcessCommandline(); 202*c9b362f6SAndre Fischer$arguments->{'package-format'} = 'msi'; 203*c9b362f6SAndre Fischer 204*c9b362f6SAndre Fischerprint "preparing release build\n"; 205*c9b362f6SAndre Fischermy ($variables, undef, undef) 206*c9b362f6SAndre Fischer = installer::ziplist::read_openoffice_lst_file( 207*c9b362f6SAndre Fischer $arguments->{'lst-file'}, 208*c9b362f6SAndre Fischer $arguments->{'product-name'}, 209*c9b362f6SAndre Fischer undef); 210*c9b362f6SAndre Fischerif ( ! defined $arguments->{'source-version'}) 211*c9b362f6SAndre Fischer{ 212*c9b362f6SAndre Fischer $arguments->{'source-version'} = $variables->{'PREVIOUS_VERSION'}; 213*c9b362f6SAndre Fischer} 214*c9b362f6SAndre Fischer$installer::logger::Info->printf(" reading data from '%s'\n", $arguments->{'lst-file'}); 215*c9b362f6SAndre Fischer$installer::logger::Info->printf(" product name is '%s'\n", $arguments->{'product-name'}); 216*c9b362f6SAndre Fischer$installer::logger::Info->printf(" output path is '%s'\n", $arguments->{'output-path'}); 217*c9b362f6SAndre Fischer$installer::logger::Info->printf(" source version is '%s'\n", $arguments->{'source-version'}); 218*c9b362f6SAndre Fischer 219*c9b362f6SAndre Fischerforeach my $language (@{$arguments->{'languages'}}) 220*c9b362f6SAndre Fischer{ 221*c9b362f6SAndre Fischer ProcessLanguage( 222*c9b362f6SAndre Fischer $arguments->{'source-version'}, 223*c9b362f6SAndre Fischer $language, 224*c9b362f6SAndre Fischer $arguments->{'package-format'}, 225*c9b362f6SAndre Fischer $arguments->{'product-name'}); 226*c9b362f6SAndre Fischer} 227