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 strict; 36 37=head1 NAME 38 39 release_prepare.pl - Several functions to prepare release builds 40 41=head1 SYNOPSIS 42 43 release_prepare.pl [options] <language1> <language2> ... 44 45 Options: 46 --lst-file <filename> 47 Path to the .lst file, eg ../util/openoffice.lst 48 --product-name <product-name> 49 The product name, eg Apache_OpenOffice 50 --output-path <path> 51 Path to the instsetoo_native platform output tree 52 --source-version <major>.<minor>.<micro> 53 Override version number of the source. If not given it is computed from the target version. 54 55=head1 DESCRIPTION 56 57 Prepare a release build: 58 59 - Provide installation sets of the previous version. 60 If they are not in ext_sources/ then they are downloaded. 61 62 - Unpack the installation sets. 63 64=cut 65 66 67sub ProcessCommandline () 68{ 69 my $arguments = { 70 'lst-file' => undef, 71 'product-name' => undef, 72 'output-path' => undef, 73 'source-version' => undef}; 74 75 if ( ! GetOptions( 76 "lst-file=s", \$arguments->{'lst-file'}, 77 "product-name=s", \$arguments->{'product-name'}, 78 "output-path=s", \$arguments->{'output-path'}, 79 "source-version:s" => \$arguments->{'source-version'} 80 )) 81 { 82 pod2usage(1); 83 } 84 85 if ( ! defined $arguments->{'lst-file'}) 86 { 87 print STDERR "lst-file missing, please provide --lst-file\n"; 88 pod2usage(2); 89 } 90 if ( ! defined $arguments->{'product-name'}) 91 { 92 print STDERR "product name missing, please provide --product-name\n"; 93 pod2usage(2); 94 } 95 if ( ! defined $arguments->{'output-path'}) 96 { 97 print STDERR "output path missing, please provide --output-path\n"; 98 pod2usage(2); 99 } 100 101 $arguments->{'languages'} = \@ARGV; 102 103 return $arguments; 104} 105 106 107 108 109sub ProcessLanguage ($$$$) 110{ 111 my ($source_version, $language, $package_format, $product_name) = @_; 112 113 $installer::logger::Info->printf("%s\n", $language); 114 $installer::logger::Info->increase_indentation(); 115 116 # For every language we need 117 # 1. have downloadable installation set available (download if missing) 118 # 2. unpack it to get access to .cab and .msi 119 # 3. unpack .cab so that msimsp.exe can be run 120 121 # Create paths to unpacked contents of .exe and .cab and determine if they exist. 122 # The existence of these paths is taken as flag whether the unpacking has already taken place. 123 my $unpacked_exe_path = installer::patch::InstallationSet::GetUnpackedMsiPath( 124 $source_version, 125 $language, 126 $package_format, 127 $product_name); 128 my $unpacked_cab_path = installer::patch::InstallationSet::GetUnpackedCabPath( 129 $source_version, 130 $language, 131 $package_format, 132 $product_name); 133 my $exe_is_unpacked = -d $unpacked_exe_path; 134 my $cab_is_unpacked = -d $unpacked_cab_path; 135 136 if ( ! $exe_is_unpacked) 137 { 138 # Interpret existence of path as proof that the installation 139 # set and the cab file have been successfully unpacked. 140 # Nothing to do. 141 my $filename = installer::patch::InstallationSet::ProvideDownloadSet( 142 $source_version, 143 $language, 144 $package_format); 145 if (defined $filename) 146 { 147 if ( ! -d $unpacked_exe_path) 148 { 149 installer::patch::InstallationSet::UnpackExe($filename, $unpacked_exe_path); 150 } 151 } 152 else 153 { 154 installer::logger::PrintError("could not provide .exe installation set at '%s'\n", $filename); 155 } 156 } 157 else 158 { 159 $installer::logger::Info->printf("downloadable installation set has already been unpacked to '%s'\n", 160 $unpacked_exe_path); 161 } 162 163 if ( ! $cab_is_unpacked) 164 { 165 my $cab_filename = File::Spec->catfile($unpacked_exe_path, "openoffice1.cab"); 166 if ( ! -f $cab_filename) 167 { 168 # Cab file does not exist. 169 installer::logger::PrintError( 170 "could not find .cab file at '%s'. Extraction of .exe seems to have failed.\n", 171 $cab_filename); 172 } 173 174 # Unpack the cab file. 175 my $msi = new installer::patch::Msi( 176 $source_version, 177 $language, 178 $product_name); 179 180 $installer::logger::Info->printf("unpacking cab file '%s' to '%s'\n", 181 $cab_filename, $unpacked_cab_path); 182 installer::patch::InstallationSet::UnpackCab( 183 $cab_filename, 184 $msi, 185 $unpacked_cab_path); 186 } 187 else 188 { 189 $installer::logger::Info->printf("cab has already been unpacked to\n"); 190 $installer::logger::Info->printf(" %s\n", $unpacked_cab_path); 191 } 192 193 $installer::logger::Info->decrease_indentation(); 194} 195 196 197 198 199installer::logger::SetupSimpleLogging("c:/tmp/log"); 200 201my $arguments = ProcessCommandline(); 202$arguments->{'package-format'} = 'msi'; 203 204print "preparing release build\n"; 205my ($variables, undef, undef) 206 = installer::ziplist::read_openoffice_lst_file( 207 $arguments->{'lst-file'}, 208 $arguments->{'product-name'}, 209 undef); 210if ( ! defined $arguments->{'source-version'}) 211{ 212 $arguments->{'source-version'} = $variables->{'PREVIOUS_VERSION'}; 213} 214$installer::logger::Info->printf(" reading data from '%s'\n", $arguments->{'lst-file'}); 215$installer::logger::Info->printf(" product name is '%s'\n", $arguments->{'product-name'}); 216$installer::logger::Info->printf(" output path is '%s'\n", $arguments->{'output-path'}); 217$installer::logger::Info->printf(" source version is '%s'\n", $arguments->{'source-version'}); 218 219foreach my $language (@{$arguments->{'languages'}}) 220{ 221 ProcessLanguage( 222 $arguments->{'source-version'}, 223 $language, 224 $arguments->{'package-format'}, 225 $arguments->{'product-name'}); 226} 227