From 7d49522cbbb7cae4b37956542f061a9f180f2a77 Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Wed, 8 Oct 2003 08:17:39 +0000 Subject: [PATCH] Next Generation Mozilla Applications Shared Installer generation scripts. --- .../mozapps/installer/windows/build_static.pl | 351 ++++++++++ toolkit/mozapps/installer/windows/makeall.pl | 598 ++++++++++++++++++ 2 files changed, 949 insertions(+) create mode 100644 toolkit/mozapps/installer/windows/build_static.pl create mode 100644 toolkit/mozapps/installer/windows/makeall.pl diff --git a/toolkit/mozapps/installer/windows/build_static.pl b/toolkit/mozapps/installer/windows/build_static.pl new file mode 100644 index 000000000000..cf51c3e3d581 --- /dev/null +++ b/toolkit/mozapps/installer/windows/build_static.pl @@ -0,0 +1,351 @@ +#!c:\perl\bin\perl +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1999 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): Sean Su +# + +# +# Purpose: +# To build the self-extracting installer and corresponding .xpi files +# for the next generation Mozilla products. +# +# Requirements: +# 1. ActivePerl (not cygwin perl) needs to be installed correctly on the +# build system because cwd.pm is used. +# 2. MOZ_SRC must be set to the directory above the root of the source +# tree. +# 3. mozilla\xpinstall\wizard\windows needs to be built. +# a. to build it, MFC must be installed with VC +# b. set MOZ_MFC=1 in the build environment +# c. run make from the above directory +# 4. The source tree must be built without an object directory. Yes it's +# lame but that's the way these scripts were set up. Don't shoot me, +# I'm only the messenger. +# +# - Ben (10/07/2003) +# +# Usage: +# perl build_static.pl -rurl -scripts +# +# remote_XPI_url Remote location where the XPIs for the stub installer +# will be stored. +# build_script_location Local directory containing scripts for the product +# to be built, e.g.: +# +# "C:/Builds/birds/thunderbird/mozilla/mail/installer/windows/" +# or +# "C:/Builds/birds/firebird/mozilla/browser/installer/windows/" +# +# This is where packager lists, XPI install scripts +# default config.ini files etc for the installer +# live. + +if($ENV{MOZ_SRC} eq "") +{ + print "Error: MOZ_SRC not set!"; + exit(1); +} + +$inXpiURL = ""; +$inRedirIniURL = ""; +$inConfigFiles = ""; + +ParseArgv(@ARGV); +if($inXpiURL eq "") +{ + # archive url not supplied, set it to default values + $inXpiURL = "ftp://not.supplied.invalid"; + print "Warning: Remote XPI URL not set. Using $inXpiURL instead!\n"; +} +if($inRedirIniURL eq "") +{ + # redirect url not supplied, set it to default value. + $inRedirIniURL = $inXpiURL; +} +if($inConfigFiles eq "") +{ + print "Error: Packager Manifests and Install Script Location not supplied! Use -config"; + exit(1); +} + +ParseInstallerCfg(); + +$DEPTH = "$ENV{MOZ_SRC}\\mozilla"; +$cwdBuilder = "$DEPTH\\toolkit\\mozapps\\installer\\windows"; +$cwdBuilder =~ s/\//\\/g; # convert slashes to backslashes for Dos commands to work +$cwdDist = GetCwd("dist", $DEPTH, $cwdBuilder); +$cwdDistWin = GetCwd("distwin", $DEPTH, $cwdBuilder); +$cwdInstall = GetCwd("install", $DEPTH, $cwdBuilder); +$cwdPackager = GetCwd("packager", $DEPTH, $cwdBuilder); +$verPartial = "5.0.0."; +$ver = $verPartial . GetVersion($DEPTH); + +if(-d "$DEPTH\\stage") +{ + system("perl $cwdPackager\\windows\\rdir.pl $DEPTH\\stage"); +} + +# The destination cannot be a sub directory of the source +# pkgcp.pl will get very unhappy + +mkdir("$DEPTH\\stage", 775); +system("perl $cwdPackager\\pkgcp.pl -s $cwdDistWin -d $DEPTH\\stage -f $inConfigFiles\\packages-static -o dos -v"); + +if(system("perl makeall.pl $ver -config $inConfigFiles -stagePath $DEPTH\\stage $cwdDistWin\\install -aurl $inXpiURL -rurl $inRedirIniURL")) +{ + print "\n Error: perl makeall.pl $ver -config $inConfigFiles -stagePath $DEPTH\\stage $cwdDistWin\\install $inXpiURL $inRedirIniURL\n"; + exit(1); +} + +chdir($cwdBuilder); + +# Copy the .xpi files to the same directory as setup.exe. +# This is so that setup.exe can find the .xpi files +# in the same directory and use them. +# +# Mozilla-win32-install.exe (a self extracting file) will use the .xpi +# files from its current directory as well, but it is not a requirement +# that they exist because it already contains the .xpi files within itself. +if(system("copy $cwdDistWin\\install\\xpi\\*.* $cwdDistWin\\install")) +{ + print "Error: copy $cwdDistWin\\install\\xpi\\*.* $cwdDistWin\\install\n"; + exit(1); +} + +print "\n"; +print "**\n"; +print "*\n"; +print "* A set of installers for $ENV{WIZ_nameProduct} has been built and delivered to:\n"; +print "*\n"; +print "* $cwdDistWin\\install\\\n"; +print "*\n"; +print "**\n"; +print "\n"; + +exit(0); + +sub PrintUsage +{ + die "usage: $0 [options] + + options available are: + + -h - this usage. + + -aurl - ftp or http url for where the archives (.xpi, exe, .zip, etx...) are. + ie: ftp://my.ftp.com/mysoftware/version1.0/xpi + + -rurl - ftp or http url for where the redirect.ini file is located at. + ie: ftp://my.ftp.com/mysoftware/version1.0 + + This url can be the same as the archive url. + If -rurl is not supplied, it will be assumed that the redirect.ini + file is at -arul. + \n"; +} + +sub ParseArgv +{ + my(@myArgv) = @_; + my($counter); + + for($counter = 0; $counter <= $#myArgv; $counter++) + { + if($myArgv[$counter] =~ /^[-,\/]h$/i) + { + PrintUsage(); + } + elsif($myArgv[$counter] =~ /^[-,\/]aurl$/i) + { + if($#myArgv >= ($counter + 1)) + { + ++$counter; + $inXpiURL = $myArgv[$counter]; + $inRedirIniURL = $inXpiURL; + } + } + elsif($myArgv[$counter] =~ /^[-,\/]rurl$/i) + { + if($#myArgv >= ($counter + 1)) + { + ++$counter; + $inRedirIniURL = $myArgv[$counter]; + } + } + elsif($myArgv[$counter] =~ /^[-,\/]config$/i) + { + if ($#myArgv >= ($counter + 1)) + { + ++$counter; + $inConfigFiles = $myArgv[$counter]; + } + } + } +} + +sub GetCwd +{ + my($whichPath, $depthPath, $returnCwd) = @_; + my($distCwd); + my($distWinPathName); + my($distPath); + + $distWinPathName = "dist"; + + if($whichPath eq "dist") + { + # verify the existance of path + if(!(-e "$depthPath\\dist")) + { + print "path not found: $depthPath\\dist\n"; + exit(1); + } + + $distPath = "$depthPath\\dist"; + } + elsif($whichPath eq "distwin") + { + # verify the existance of path + if(!(-e "$depthPath\\$distWinPathName")) + { + print "path not found: $depthPath\\$distWinPathName\n"; + exit(1); + } + + $distPath = "$depthPath\\$distWinPathName"; + } + elsif($whichPath eq "install") + { + # verify the existance of path + if(!(-e "$depthPath\\$distWinPathName\\install")) + { + print "path not found: $depthPath\\$distWinPathName\\install\n"; + exit(1); + } + + $distPath = "$depthPath\\$distWinPathName\\install"; + } + elsif($whichPath eq "packager") + { + # verify the existance of path + if(!(-e "$depthPath\\xpinstall\\packager")) + { + print "path not found: $depthPath\\xpinstall\\packager\n"; + exit(1); + } + + $distPath = "$depthPath\\xpinstall\\packager"; + } + + $distPath =~ s/\//\\/g; # convert slashes to backslashes for Dos commands to work + return($distPath); +} + +sub GetVersion +{ + my($depthPath) = @_; + my($fileMozilla); + my($fileMozillaVer); + my($distWinPathName); + my($monAdjusted); + my($yy); + my($mm); + my($dd); + my($hh); + + $distWinPathName = "dist"; + + $fileMozilla = "$depthPath\\$distWinPathName\\bin\\$ENV{WIZ_fileApplicationExe}"; + # verify the existance of file + if(!(-e "$fileMozilla")) + { + print "file not found: $fileMozilla\n"; + exit(1); + } + + ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $fileMozilla; + ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($mtime); + + # calculate year + # localtime() returns year 2000 as 100, we mod 100 to get at the last 2 digits + $yy = $year % 100; + $yy = "20" . sprintf("%.2d", $yy); + + # calculate month + $monAdjusted = $mon + 1; + $mm = sprintf("%.2d", $monAdjusted); + + # calculate month day + $dd = sprintf("%.2d", $mday); + + # calculate day hour + $hh = sprintf("%.2d", $hour); + + $fileMozillaVer = "$yy$mm$dd$hh"; + print "y2k compliant version string for $fileMozilla: $fileMozillaVer\n"; + return($fileMozillaVer); +} + + +# Initialize global installer environment variables. This information comes from +# the application's installer.cfg file which specifies such things as name and +# installer exe file names. +sub ParseInstallerCfg +{ + open(fpInstallCfg, "$inConfigFiles/installer.cfg") || die "\ncould not open $inConfigFiles/installer.cfg: $!\n"; + + while($line = ) + { + ($prop, $value) = ($line =~ m/(\w*)\s+=\s+(.*)\n/); + + if ($prop eq "VersionLanguage") { + $ENV{WIZ_versionLanguage} = $value; + } + elsif ($prop eq "NameCompany") { + $ENV{WIZ_nameCompany} = $value; + } + elsif ($prop eq "NameProduct") { + $ENV{WIZ_nameProduct} = $value; + } + elsif ($prop eq "NameProductInternal") { + $ENV{WIZ_nameProductInternal} = $value; + } + elsif ($prop eq "FileApplicationExe") { + $ENV{WIZ_fileApplicationExe} = $value; + } + elsif ($prop eq "FileUninstall") { + $ENV{WIZ_fileUninstall} = $value; + } + elsif ($prop eq "FileUninstallZIP") { + $ENV{WIZ_fileUninstallZip} = $value; + } + elsif ($prop eq "FileMainEXE") { + $ENV{WIZ_fileMainExe} = $value; + } + elsif ($prop eq "FileInstallerNETRoot") { + $ENV{WIZ_fileNetStubRootName} = $value; + } + elsif ($prop eq "ComponentList") { + $ENV{WIZ_componentList} = $value; + } + } + + close(fpInstallCfg); +} + diff --git a/toolkit/mozapps/installer/windows/makeall.pl b/toolkit/mozapps/installer/windows/makeall.pl new file mode 100644 index 000000000000..586adee38eaf --- /dev/null +++ b/toolkit/mozapps/installer/windows/makeall.pl @@ -0,0 +1,598 @@ +#!c:\perl\bin\perl +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is Mozilla Communicator client code, released +# March 31, 1998. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998-1999 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# Sean Su +# + +# +# This perl script builds the xpi, config.ini, and js files. +# + +use Cwd; +use File::Copy; +use File::Path; +use File::Basename; + +$DEPTH = "../../../.."; +$topsrcdir = GetTopSrcDir(); + +# ensure that Packager.pm is in @INC, since we might not be called from +# mozilla/xpinstall/packager +push(@INC, "$topsrcdir/xpinstall/packager"); +require StageUtils; +require "$topsrcdir/config/zipcfunc.pl"; + +ParseArgv(@ARGV); + +$topobjdir = "$topsrcdir" if !defined($topobjdir); +$inStagePath = "$topobjdir/stage" if !defined($inStagePath); +$inDistPath = "$topobjdir/dist" if !defined($inDistPath); +$inXpiURL = "ftp://not.supplied.invalid" if !defined($inXpiURL); +$inRedirIniURL = $inXpiURL if !defined($inRedirIniURL); + +if ($inConfigFiles eq "") +{ + print "Error: Packager Manifests and Install Script Location not supplied! Use -config"; + exit(1); +} + +print "**** GAOT = $ENV{WIZ_nameProduct}\n"; + +# Initialize state from environment (which is established in the calling script +# after reading the installer.cfg file. +$versionLanguage = $ENV{WIZ_versionLanugage}; +@gComponentList = split(/,/, $ENV{WIZ_componentList}); +$seiFileNameGeneric = "nsinstall.exe"; +$seiFileNameSpecific = $ENV{WIZ_fileMainExe}; +$seiStubRootName = $ENV{WIZ_fileNetStubRootName}; +$seiFileNameSpecificStub = "$seiStubRootName.exe"; +$seuFileNameSpecific = $ENV{WIZ_fileUninstall}; +$seuzFileNameSpecific = $ENV{WIZ_fileUninstallZip}; + +if(defined($ENV{DEBUG_INSTALLER_BUILD})) +{ + print " windows/makeall.pl\n"; + print " topobjdir : $topobjdir\n"; + print " topsrcdir : $topsrcdir\n"; + print " inStagePath: $inStagePath\n"; + print " inDistPath : $inDistPath\n"; +} + +$gDefaultProductVersion = StageUtils::GetProductY2KVersion($topobjdir, $topsrcdir, $topsrcdir); + +print "\n"; +print " Building $ENV{WIZ_nameProduct} installer\n"; +print " Raw version id : $gDefaultProductVersion\n"; + +# $gDefaultProductVersion has the form maj.min.release.bld where maj, min, release +# and bld are numerics representing version information. +# Other variables need to use parts of the version info also so we'll +# split out the dot separated values into the array @versionParts +# such that: +# +# $versionParts[0] = maj +# $versionParts[1] = min +# $versionParts[2] = release +# $versionParts[3] = bld +@versionParts = split /\./, $gDefaultProductVersion; + +# We allow non-numeric characters to be included as the last +# characters in fields of $gDefaultProductVersion for display purposes (mostly to +# show that we have moved past a certain version by adding a '+' +# character). Non-numerics must be stripped out of $gDefaultProductVersion, +# however, since this variable is used to identify the the product +# for comparison with other installations, so the values in each field +# must be numeric only: +$gDefaultProductVersion =~ s/[^0-9.][^.]*//g; + +# set environment vars for use by other .pl scripts called from this script. +if($versionParts[2] eq "0") +{ + $versionMain = "$versionParts[0].$versionParts[1]"; +} +else +{ + $versionMain = "$versionParts[0].$versionParts[1].$versionParts[2]"; +} + +print " Display version : $versionMain\n"; +print " Xpinstall version: $gDefaultProductVersion\n"; +print "\n"; + +$gDirPackager = "$topsrcdir/xpinstall/packager"; +$gDirStageProduct = $inStagePath; +$gDirDistInstall = "$inDistPath/install"; + +# The following variables are for displaying version info in the +# the installer. +$ENV{WIZ_userAgent} = "$versionMain ($versionLanguage)"; +$ENV{WIZ_userAgentShort} = "$versionMain"; +$ENV{WIZ_xpinstallVersion} = "$gDefaultProductVersion"; +$ENV{WIZ_distInstallPath} = "$gDirDistInstall"; + +print "\n"; +print " Building $ENV{WIZ_nameProduct} $ENV{WIZ_userAgent}...\n"; +print "\n"; + +# Check for existence of staging path +if(!(-d "$gDirStageProduct")) +{ + die "\n Invalid path: $gDirStageProduct\n"; +} + +if(VerifyComponents()) # return value of 0 means no errors encountered +{ + exit(1); +} + +# Make sure gDirDistInstall exists +if(!(-d "$gDirDistInstall")) +{ + mkdir ("$gDirDistInstall",0775); +} + +if(-d "$gDirDistInstall/xpi") +{ + unlink <$gDirDistInstall/xpi/*>; +} +else +{ + mkdir ("$gDirDistInstall/xpi",0775); +} + +if(-d "$gDirDistInstall/uninstall") +{ + unlink <$gDirDistInstall/uninstall/*>; +} +else +{ + mkdir ("$gDirDistInstall/uninstall",0775); +} + +if(-d "$gDirDistInstall/setup") +{ + unlink <$gDirDistInstall/setup/*>; +} +else +{ + mkdir ("$gDirDistInstall/setup",0775); +} + +if(MakeXpiFile()) +{ + exit(1); +} +if(MakeUninstall()) +{ + exit(1); +} +if(MakeConfigFile()) +{ + exit(1); +} + +# Copy the setup files to the dist setup directory. +copy("install.ini", "$gDirDistInstall") || + die "copy install.ini $gDirDistInstall: $!\n"; +copy("install.ini", "$gDirDistInstall/setup") || + die "copy install.ini $gDirDistInstall/setup: $!\n"; +copy("config.ini", "$gDirDistInstall") || + die "copy config.ini $gDirDistInstall: $!\n"; +copy("config.ini", "$gDirDistInstall/setup") || + die "copy config.ini $gDirDistInstall/setup: $!\n"; +copy("$gDirDistInstall/setup.exe", "$gDirDistInstall/setup") || + die "copy $gDirDistInstall/setup.exe $gDirDistInstall/setup: $!\n"; +copy("$gDirDistInstall/setuprsc.dll", "$gDirDistInstall/setup") || + die "copy $gDirDistInstall/setuprsc.dll $gDirDistInstall/setup: $!\n"; + +# copy license file for the installer +copy("$topsrcdir/LICENSE", "$gDirDistInstall/license.txt") || + die "copy $topsrcdir/LICENSE $gDirDistInstall/license.txt: $!\n"; +copy("$topsrcdir/LICENSE", "$gDirDistInstall/setup/license.txt") || + die "copy $topsrcdir/LICENSE $gDirDistInstall/setup/license.txt: $!\n"; + + +# copy the lean installer to stub\ dir +print "\n****************************\n"; +print "* *\n"; +print "* creating Stub files... *\n"; +print "* *\n"; +print "****************************\n"; +print "\n $gDirDistInstall/stub/$seiFileNameSpecificStub\n"; + +# build the self-extracting .exe (installer) file. +copy("$gDirDistInstall/$seiFileNameGeneric", "$gDirDistInstall/$seiFileNameSpecificStub") || + die "copy $gDirDistInstall/$seiFileNameGeneric $gDirDistInstall/$seiFileNameSpecificStub: $!\n"; + +if (system("$gDirDistInstall/nsztool.exe $gDirDistInstall/$seiFileNameSpecificStub $gDirDistInstall/setup/*.*")) +{ + die "\n Error: $gDirDistInstall/nsztool.exe $gDirDistInstall/$seiFileNameSpecificStub $gDirDistInstall/setup/*.*\n"; +} + +if(-d "$gDirDistInstall/stub") +{ + unlink <$gDirDistInstall/stub/*>; +} +else +{ + mkdir ("$gDirDistInstall/stub",0775); +} +copy("$gDirDistInstall/$seiFileNameSpecificStub", "$gDirDistInstall/stub") || + die "copy $gDirDistInstall/$seiFileNameSpecificStub $gDirDistInstall/stub: $!\n"; + +# create the xpi for launching the stub installer +print "\n************************************\n"; +print "* *\n"; +print "* creating stub installer xpi... *\n"; +print "* *\n"; +print "************************************\n"; +print "\n $gDirDistInstall/$seiStubRootName.xpi\n\n"; + +if(-d "$gDirStageProduct/$seiStubRootName") +{ + unlink <$gDirStageProduct/$seiStubRootName/*>; +} +else +{ + mkdir ("$gDirStageProduct/$seiStubRootName",0775); +} +copy("$gDirDistInstall/stub/$seiFileNameSpecificStub", "$gDirStageProduct/$seiStubRootName") || + die "copy $gDirDistInstall/stub/$seiFileNameSpecificStub $gDirStageProduct/$seiStubRootName: $!\n"; + +# Make .js files +if(MakeJsFile($seiStubRootName)) +{ + return(1); +} + +# Make .xpi file +if(system("perl $gDirPackager/windows/makexpi.pl $seiStubRootName $gDirStageProduct $gDirDistInstall")) +{ + print "\n Error: perl $gDirPackager/windows/makexpi.pl $seiStubRootName $gDirStageProduct $gDirDistInstall\n"; + return(1); +} + +# group files for CD +print "\n************************************\n"; +print "* *\n"; +print "* creating Compact Disk files... *\n"; +print "* *\n"; +print "************************************\n"; +print "\n $gDirDistInstall/cd\n"; + +if(-d "$gDirDistInstall/cd") +{ + unlink <$gDirDistInstall/cd/*>; +} +else +{ + mkdir ("$gDirDistInstall/cd",0775); +} + +copy("$gDirDistInstall/$seiFileNameSpecificStub", "$gDirDistInstall/cd") || + die "copy $gDirDistInstall/$seiFileNameSpecificStub $gDirDistInstall/cd: $!\n"; + +StageUtils::CopyFiles("$gDirDistInstall/xpi", "$gDirDistInstall/cd"); + +# create the big self extracting .exe installer +print "\n**************************************************************\n"; +print "* *\n"; +print "* creating Self Extracting Executable Full Install file... *\n"; +print "* *\n"; +print "**************************************************************\n"; +print "\n $gDirDistInstall/$seiFileNameSpecific\n"; + +if(-d "$gDirDistInstall/sea") +{ + unlink <$gDirDistInstall/sea/*>; +} +else +{ + mkdir ("$gDirDistInstall/sea",0775); +} +copy("$gDirDistInstall/$seiFileNameGeneric", "$gDirDistInstall/$seiFileNameSpecific") || + die "copy $gDirDistInstall/$seiFileNameGeneric $gDirDistInstall/$seiFileNameSpecific: $!\n"; + +if(system("$gDirDistInstall/nsztool.exe $gDirDistInstall/$seiFileNameSpecific $gDirDistInstall/setup/*.* $gDirDistInstall/xpi/*.*")) +{ + die "\n Error: $gDirDistInstall/nsztool.exe $gDirDistInstall/$seiFileNameSpecific $gDirDistInstall/setup/*.* $gDirDistInstall/xpi/*.*\n"; +} +copy("$gDirDistInstall/$seiFileNameSpecific", "$gDirDistInstall/sea") || + die "copy $gDirDistInstall/$seiFileNameSpecific $gDirDistInstall/sea: $!\n"; + +unlink <$gDirDistInstall/$seiFileNameSpecificStub>; + +print " done!\n\n"; + +if((!(-e "$topsrcdir/../redist/microsoft/system/msvcrt.dll")) || + (!(-e "$topsrcdir/../redist/microsoft/system/msvcirt.dll"))) +{ + print "***\n"; + print "**\n"; + print "** The following required Microsoft redistributable system files were not found\n"; + print "** in $topsrcdir/../redist/microsoft/system:\n"; + print "**\n"; + if(!(-e "$topsrcdir/../redist/microsoft/system/msvcrt.dll")) + { + print "** msvcrt.dll\n"; + } + if(!(-e "$topsrcdir/../redist/microsoft/system/msvcirt.dll")) + { + print "** msvcirt.dll\n"; + } + print "**\n"; + print "** The above files are required by the installer and the browser. If you attempt\n"; + print "** to run the installer, you may encounter the following bug:\n"; + print "**\n"; + print "** http://bugzilla.mozilla.org/show_bug.cgi?id=27601\n"; + print "**\n"; + print "***\n\n"; +} + +# end of script +exit(0); + +sub MakeExeZip +{ + my($aSrcDir, $aExeFile, $aZipFile) = @_; + my($saveCwdir); + + $saveCwdir = cwd(); + chdir($aSrcDir); + if(system("zip $gDirDistInstall/xpi/$aZipFile $aExeFile")) + { + chdir($saveCwdir); + die "\n Error: zip $gDirDistInstall/xpi/$aZipFile $aExeFile"; + } + chdir($saveCwdir); +} + +sub PrintUsage +{ + die "usage: $0 [options] + + options include: + + -config : path to where configuration and component script + files are located. + + -objDir : path to the objdir. default is topsrcdir + + -stagePath : full path to where the mozilla components are staged at + Default stage path, if this is not set, is: + [mozilla]/stage + + -distPath : full path to where the mozilla dist dir is at. + Default stage path, if this is not set, is: + [mozilla]/dist + + -aurl : either ftp:// or http:// url to where the + archives (.xpi, .exe, .zip, etc...) reside + + -rurl : either ftp:// or http:// url to where the + redirec.ini resides. If not supplied, it + will be assumed to be the same as archive + url. + \n"; +} + +sub ParseArgv +{ + my(@myArgv) = @_; + my($counter); + + for($counter = 0; $counter <= $#myArgv; $counter++) + { + if($myArgv[$counter] =~ /^[-,\/]h$/i) + { + PrintUsage(); + } + elsif($myArgv[$counter] =~ /^[-,\/]objDir$/i) + { + if($#myArgv >= ($counter + 1)) + { + ++$counter; + $topobjdir = $myArgv[$counter]; + $topobjdir =~ s/\\/\//g; + } + } + elsif($myArgv[$counter] =~ /^[-,\/]stagePath$/i) + { + if($#myArgv >= ($counter + 1)) + { + ++$counter; + $inStagePath = $myArgv[$counter]; + $inStagePath =~ s/\\/\//g; + } + } + elsif($myArgv[$counter] =~ /^[-,\/]distPath$/i) + { + if($#myArgv >= ($counter + 1)) + { + ++$counter; + $inDistPath = $myArgv[$counter]; + $inDistPath =~ s/\\/\//g; + } + } + elsif($myArgv[$counter] =~ /^[-,\/]aurl$/i) + { + if($#myArgv >= ($counter + 1)) + { + ++$counter; + $inXpiURL = $myArgv[$counter]; + $inRedirIniURL = $inXpiURL; + } + } + elsif($myArgv[$counter] =~ /^[-,\/]rurl$/i) + { + if($#myArgv >= ($counter + 1)) + { + ++$counter; + $inRedirIniURL = $myArgv[$counter]; + } + } + elsif($myArgv[$counter] =~ /^[-,\/]config$/i) + { + if ($#myArgv >= ($counter + 1)) + { + ++$counter; + $inConfigFiles = $myArgv[$counter]; + } + } + } +} + +sub MakeConfigFile +{ + chdir($inConfigFiles); + # Make config.ini file + if(system("perl $gDirPackager/windows/makecfgini.pl config.it $gDefaultProductVersion $gDirStageProduct $gDirDistInstall/xpi $inRedirIniURL $inXpiURL")) + { + print "\n Error: perl $gDirPackager/windows/makecfgini.pl config.it $gDefaultProductVersion $gDirStageProduct $gDirDistInstall/xpi $inRedirIniURL $inXpiURL\n"; + return(1); + } + + # Make install.ini file + if(system("perl $gDirPackager/windows/makecfgini.pl install.it $gDefaultProductVersion $gDirStageProduct $gDirDistInstall/xpi $inRedirIniURL $inXpiURL")) + { + print "\n Error: perl $gDirPackager/windows/makecfgini.pl install.it $gDefaultProductVersion $gDirStageProduct $gDirDistInstall/xpi $inRedirIniURL $inXpiURL\n"; + return(1); + } + return(0); +} + +sub MakeUninstall +{ + chdir($inConfigFiles); + if(MakeUninstallIniFile()) + { + return(1); + } + + # Copy the uninstall files to the dist uninstall directory. + copy("uninstall.ini", "$gDirDistInstall") || + die "copy uninstall.ini $gDirDistInstall: $!\n"; + copy("uninstall.ini", "$gDirDistInstall/uninstall") || + die "copy uninstall.ini $gDirDistInstall/uninstall: $!\n"; + copy("$gDirDistInstall/uninstall.exe", "$gDirDistInstall/uninstall") || + die "copy $gDirDistInstall/uninstall.exe $gDirDistInstall/uninstall: $!\n"; + + # build the self-extracting .exe (uninstaller) file. + print "\nbuilding self-extracting uninstaller ($seuFileNameSpecific)...\n"; + copy("$gDirDistInstall/$seiFileNameGeneric", "$gDirDistInstall/$seuFileNameSpecific") || + die "copy $gDirDistInstall/$seiFileNameGeneric $gDirDistInstall/$seuFileNameSpecific: $!\n"; + if(system("$gDirDistInstall/nsztool.exe $gDirDistInstall/$seuFileNameSpecific $gDirDistInstall/uninstall/*.*")) + { + print "\n Error: $gDirDistInstall/nsztool.exe $gDirDistInstall/$seuFileNameSpecific $gDirDistInstall/uninstall/*.*\n"; + return(1); + } + + MakeExeZip($gDirDistInstall, $seuFileNameSpecific, $seuzFileNameSpecific); + unlink <$gDirDistInstall/$seuFileNameSpecific>; + return(0); +} + +sub MakeUninstallIniFile +{ + # Make config.ini file + chdir($inConfigFiles); + if(system("perl $gDirPackager/windows/makeuninstallini.pl uninstall.it $gDefaultProductVersion")) + { + print "\n Error: perl $gDirPackager/windows/makeuninstallini.pl uninstall.it $gDefaultProductVersion\n"; + return(1); + } + return(0); +} + +sub MakeJsFile +{ + my($mComponent) = @_; + + # Make .js file + chdir($inConfigFiles); + if(system("perl $gDirPackager/windows/makejs.pl $mComponent.jst $gDefaultProductVersion $gDirStageProduct/$mComponent")) + { + print "\n Error: perl $gDirPackager/windows/makejs.pl $mComponent.jst $gDefaultProductVersion $gDirStageProduct/$mComponent\n"; + return(1); + } + return(0); +} + +sub MakeXpiFile +{ + my($mComponent); + + chdir($inConfigFiles); + foreach $mComponent (@gComponentList) + { + # Make .js files + if(MakeJsFile($mComponent)) + { + return(1); + } + + # Make .xpi file + if(system("perl $gDirPackager/windows/makexpi.pl $mComponent $gDirStageProduct $gDirDistInstall/xpi")) + { + print "\n Error: perl $gDirPackager/windows/makexpi.pl $mComponent $gDirStageProduct $gDirDistInstall/xpi\n"; + return(1); + } + } + return(0); +} + +sub VerifyComponents() +{ + my($mComponent); + my($mError) = 0; + + print "\n Verifying existence of required components...\n"; + foreach $mComponent (@gComponentList) + { + if($mComponent =~ /talkback/i) + { + print " place holder: $gDirStageProduct/$mComponent\n"; + mkdir("$gDirStageProduct/$mComponent", 775); + } + elsif(-d "$gDirStageProduct/$mComponent") + { + print " ok: $gDirStageProduct/$mComponent\n"; + } + else + { + print " Error: $gDirStageProduct/$mComponent does not exist!\n"; + $mError = 1; + } + } + print "\n"; + return($mError); +} + +sub GetTopSrcDir +{ + my($rootDir) = dirname($0) . "/$DEPTH"; + my($savedCwdDir) = cwd(); + + chdir($rootDir); + $rootDir = cwd(); + chdir($savedCwdDir); + return($rootDir); +}