diff options
Diffstat (limited to 'setup_native/scripts')
23 files changed, 4226 insertions, 0 deletions
diff --git a/setup_native/scripts/admin.pl b/setup_native/scripts/admin.pl new file mode 100644 index 000000000000..1aed8214cb30 --- /dev/null +++ b/setup_native/scripts/admin.pl @@ -0,0 +1,1443 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use Cwd; +use File::Copy; + +################################################################################# +# Global settings +################################################################################# + +BEGIN +{ + $prog = "msi installer"; + $targetdir = ""; + $databasepath = ""; + $starttime = ""; + $globaltempdirname = "ooopackaging"; + $savetemppath = ""; + $msiinfo_available = 0; + $path_displayed = 0; + $localmsidbpath = ""; + + $plat = $^O; + + if ( $plat =~ /cygwin/i ) + { + $separator = "/"; + $pathseparator = "\:"; + } + else + { + $separator = "\\"; + $pathseparator = "\;"; + } +} + +################################################################################# +# Program information +################################################################################# + +sub usage +{ + print <<Ende; +---------------------------------------------------------------------- +This program installs a Windows Installer installation set +without using msiexec.exe. The installation is comparable +with an administrative installation using the Windows Installer +service. +Required parameter: +-d Path to installation set or msi database +-t Target directory +--------------------------------------------------------------------- +Ende + exit(-1); +} + +################################################################################# +# Collecting parameter +################################################################################# + +sub getparameter +{ + if (( $#ARGV < 3 ) || ( $#ARGV > 3 )) { usage(); } + + while ( $#ARGV >= 0 ) + { + my $param = shift(@ARGV); + + if ($param eq "-t") { $targetdir = shift(@ARGV); } + elsif ($param eq "-d") { $databasepath = shift(@ARGV); } + else + { + print "\n**********************************************\n"; + print "Error: Unknows parameter: $param"; + print "\n**********************************************\n"; + usage(); + exit(-1); + } + } +} + +################################################################################# +# Checking content of parameter +################################################################################# + +sub controlparameter +{ + if ( $targetdir eq "" ) + { + print "\n******************************************************\n"; + print "Error: Target directory not defined (parameter -t)!"; + print "\n******************************************************\n"; + usage(); + exit(-1); + } + + if ( $databasepath eq "" ) + { + print "\n******************************************************\n"; + print "Error: Path to msi database not defined (parameter -d)!"; + print "\n******************************************************\n"; + usage(); + exit(-1); + } + + if ( -d $databasepath ) + { + $databasepath =~ s/\\\s*$//; + $databasepath =~ s/\/\s*$//; + + my $msifiles = find_file_with_file_extension("msi", $databasepath); + + if ( $#{$msifiles} < 0 ) { exit_program("ERROR: Did not find msi database in directory $installationdir"); } + if ( $#{$msifiles} > 0 ) { exit_program("ERROR: Did find more than one msi database in directory $installationdir"); } + + $databasepath = $databasepath . $separator . ${$msifiles}[0]; + } + + if ( ! -f $databasepath ) { exit_program("ERROR: Did not find msi database in directory $databasepath."); } + + if ( ! -d $targetdir ) { create_directories($targetdir); } +} + +############################################################################# +# The program msidb.exe can be located next to the Perl program. Then it is +# not neccessary to find it in the PATH variable. +############################################################################# + +sub check_local_msidb +{ + my $msidbname = "msidb.exe"; + my $perlprogramm = $0; + my $path = $perlprogramm; + + get_path_from_fullqualifiedname(\$path); + + $path =~ s/\\\s*$//; + $path =~ s/\/\s*$//; + + my $msidbpath = ""; + if ( $path =~ /^\s*$/ ) { $msidbpath = $msidbname; } + else { $msidbpath = $path . $separator . $msidbname; } + + if ( -f $msidbpath ) + { + $localmsidbpath = $msidbpath; + print "Using $msidbpath (next to \"admin.pl\")\n"; + } +} + +############################################################################# +# Converting a string list with separator $listseparator +# into an array +############################################################################# + +sub convert_stringlist_into_array +{ + my ( $includestringref, $listseparator ) = @_; + + my @newarray = (); + my $first; + my $last = ${$includestringref}; + + while ( $last =~ /^\s*(.+?)\Q$listseparator\E(.+)\s*$/) # "$" for minimal matching + { + $first = $1; + $last = $2; + # Problem with two directly following listseparators. For example a path with two ";;" directly behind each other + $first =~ s/^$listseparator//; + push(@newarray, "$first\n"); + } + + push(@newarray, "$last\n"); + + return \@newarray; +} + +######################################################### +# Checking the local system +# Checking existence of needed files in include path +######################################################### + +sub check_system_path +{ + my $onefile; + my $error = 0; + my $pathvariable = $ENV{'PATH'}; + my $local_pathseparator = $pathseparator; + + if( $^O =~ /cygwin/i ) + { # When using cygwin's perl the PATH variable is POSIX style and ... + $pathvariable = qx{cygpath -mp "$pathvariable"} ; + # has to be converted to DOS style for further use. + $local_pathseparator = ';'; + } + my $patharrayref = convert_stringlist_into_array(\$pathvariable, $local_pathseparator); + + my @needed_files_in_path = ("expand.exe"); + if ( $localmsidbpath eq "" ) { push(@needed_files_in_path, "msidb.exe"); } # not found locally -> search in path + my @optional_files_in_path = ("msiinfo.exe"); + + print("\nChecking required files:\n"); + + foreach $onefile ( @needed_files_in_path ) + { + print("...... searching $onefile ..."); + + my $fileref = get_sourcepath_from_filename_and_includepath(\$onefile, $patharrayref); + + if ( $$fileref eq "" ) + { + $error = 1; + print( "$onefile not found\n" ); + } + else + { + print( "\tFound: $$fileref\n" ); + } + } + + if ( $error ) { exit_program("ERROR: Could not find all needed files in path (using setsolar should help)!"); } + + print("\nChecking optional files:\n"); + + foreach $onefile ( @optional_files_in_path ) + { + print("...... searching $onefile ..."); + + my $fileref = get_sourcepath_from_filename_and_includepath(\$onefile, $patharrayref); + + if ( $$fileref eq "" ) + { + print( "$onefile not found\n" ); + if ( $onefile eq "msiinfo.exe" ) { $msiinfo_available = 0; } + } + else + { + print( "\tFound: $$fileref\n" ); + if ( $onefile eq "msiinfo.exe" ) { $msiinfo_available = 1; } + } + } + +} + +########################################################################## +# Searching a file in a list of pathes +########################################################################## + +sub get_sourcepath_from_filename_and_includepath +{ + my ($searchfilenameref, $includepatharrayref) = @_; + + my $onefile = ""; + my $foundsourcefile = 0; + + for ( my $j = 0; $j <= $#{$includepatharrayref}; $j++ ) + { + my $includepath = ${$includepatharrayref}[$j]; + $includepath =~ s/^\s*//; + $includepath =~ s/\s*$//; + + $onefile = $includepath . $separator . $$searchfilenameref; + + if ( -f $onefile ) + { + $foundsourcefile = 1; + last; + } + } + + if (!($foundsourcefile)) { $onefile = ""; } + + return \$onefile; +} + +############################################################## +# Removing all empty directories below a specified directory +############################################################## + +sub remove_empty_dirs_in_folder +{ + my ( $dir, $firstrun ) = @_; + + if ( $firstrun ) + { + print "Removing superfluous directories\n"; + } + + my @content = (); + + $dir =~ s/\Q$separator\E\s*$//; + + if ( -d $dir ) + { + opendir(DIR, $dir); + @content = readdir(DIR); + closedir(DIR); + + my $oneitem; + + foreach $oneitem (@content) + { + if ((!($oneitem eq ".")) && (!($oneitem eq ".."))) + { + my $item = $dir . $separator . $oneitem; + + if ( -d $item ) # recursive + { + remove_empty_dirs_in_folder($item, 0); + } + } + } + + # try to remove empty directory + my $returnvalue = rmdir $dir; + + # if ( $returnvalue ) { print "Successfully removed empty dir $dir\n"; } + } +} + +#################################################### +# Detecting the directory with extensions +#################################################### + +sub get_extensions_dir +{ + my ( $unopkgfile ) = @_; + + my $localbranddir = $unopkgfile; + get_path_from_fullqualifiedname(\$localbranddir); # "program" dir in brand layer + get_path_from_fullqualifiedname(\$localbranddir); # root dir in brand layer + $localbranddir =~ s/\Q$separator\E\s*$//; + my $extensiondir = $localbranddir . $separator . "share" . $separator . "extensions"; + my $preregdir = $localbranddir . $separator . "share" . $separator . "prereg" . $separator . "bundled"; + + return ($extensiondir, $preregdir); +} + +######################################################## +# Finding all files with a specified file extension +# in a specified directory. +######################################################## + +sub find_file_with_file_extension +{ + my ($extension, $dir) = @_; + + my @allfiles = (); + my @sourcefiles = (); + + $dir =~ s/\Q$separator\E\s*$//; + + opendir(DIR, $dir); + @sourcefiles = readdir(DIR); + closedir(DIR); + + my $onefile; + + foreach $onefile (@sourcefiles) + { + if ((!($onefile eq ".")) && (!($onefile eq ".."))) + { + if ( $onefile =~ /^\s*(\S.*?)\.$extension\s*$/ ) + { + push(@allfiles, $onefile) + } + } + } + + return \@allfiles; +} + +############################################################## +# Creating a directory with all parent directories +############################################################## + +sub create_directories +{ + my ($directory) = @_; + + if ( ! try_to_create_directory($directory) ) + { + my $parentdir = $directory; + get_path_from_fullqualifiedname(\$parentdir); + create_directories($parentdir); # recursive + } + + create_directory($directory); # now it has to succeed +} + +############################################################## +# Creating one directory +############################################################## + +sub create_directory +{ + my ($directory) = @_; + + if ( ! -d $directory ) { mkdir($directory, 0775); } +} + +############################################################## +# Trying to create a directory, no error if this fails +############################################################## + +sub try_to_create_directory +{ + my ($directory) = @_; + + my $returnvalue = 1; + my $created_directory = 0; + + if (!(-d $directory)) + { + $returnvalue = mkdir($directory, 0775); + + if ($returnvalue) + { + $created_directory = 1; + + my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1"; + system($localcall); + } + else + { + $created_directory = 0; + } + } + else + { + $created_directory = 1; + } + + return $created_directory; +} + +########################################### +# Getting path from full file name +########################################### + +sub get_path_from_fullqualifiedname +{ + my ($longfilenameref) = @_; + + if ( $$longfilenameref =~ /\Q$separator\E/ ) # Is there a separator in the path? Otherwise the path is empty. + { + if ( $$longfilenameref =~ /^\s*(\S.*\Q$separator\E)(\S.+\S?)/ ) + { + $$longfilenameref = $1; + } + } + else + { + $$longfilenameref = ""; # there is no path + } +} + +############################################################## +# Getting file name from full file name +############################################################## + +sub make_absolute_filename_to_relative_filename +{ + my ($longfilenameref) = @_; + + # Either '/' or '\'. + if ( $$longfilenameref =~ /^.*[\/\\](\S.+\S?)/ ) + { + $$longfilenameref = $1; + } +} + +############################################ +# Exiting the program with an error +# This function is used instead of "die" +############################################ + +sub exit_program +{ + my ($message) = @_; + + print "\n***************************************************************\n"; + print "$message\n"; + print "***************************************************************\n"; + remove_complete_directory($savetemppath, 1); + print "\n" . get_time_string(); + exit(-1); +} + +################################################################################# +# Unpacking cabinet files with expand +################################################################################# + +sub unpack_cabinet_file +{ + my ($cabfilename, $unpackdir) = @_; + + my $expandfile = "expand.exe"; # has to be in the PATH + + # expand.exe has to be located in the system directory. + # Cygwin has another tool expand.exe, that converts tabs to spaces. This cannot be used of course. + # But this wrong expand.exe is typically in the PATH before this expand.exe, to unpack + # cabinet files. + + if ( $^O =~ /cygwin/i ) + { + $expandfile = $ENV{'SYSTEMROOT'} . "/system32/expand.exe"; # Has to be located in the systemdirectory + $expandfile =~ s/\\/\//; + if ( ! -f $expandfile ) { exit_program("ERROR: Did not find file $expandfile in the Windows system folder!"); } + } + + my $expandlogfile = $unpackdir . $separator . "expand.log"; + + # exclude cabinet file + # my $systemcall = $cabarc . " -o X " . $mergemodulehash->{'cabinetfile'}; + + my $systemcall = ""; + if ( $^O =~ /cygwin/i ) { + my $localunpackdir = qx{cygpath -w "$unpackdir"}; + $localunpackdir =~ s/\\/\\\\/g; + + my $localcabfilename = qx{cygpath -w "$cabfilename"}; + $localcabfilename =~ s/\\/\\\\/g; + $localcabfilename =~ s/\s*$//g; + + $systemcall = $expandfile . " " . $localcabfilename . " -F:\* " . $localunpackdir . " \>\/dev\/null 2\>\&1"; + } + else + { + $systemcall = $expandfile . " " . $cabfilename . " -F:\* " . $unpackdir . " \> " . $expandlogfile; + } + + my $returnvalue = system($systemcall); + + if ($returnvalue) { exit_program("ERROR: Could not execute $systemcall !"); } +} + +################################################################################# +# Extracting tables from msi database +################################################################################# + +sub extract_tables_from_database +{ + my ($fullmsidatabasepath, $workdir, $tablelist) = @_; + + my $msidb = "msidb.exe"; # Has to be in the path + if ( $localmsidbpath ) { $msidb = $localmsidbpath; } + my $infoline = ""; + my $systemcall = ""; + my $returnvalue = ""; + + if ( $^O =~ /cygwin/i ) { + chomp( $fullmsidatabasepath = qx{cygpath -w "$fullmsidatabasepath"} ); + # msidb.exe really wants backslashes. (And double escaping because system() expands the string.) + $fullmsidatabasepath =~ s/\\/\\\\/g; + $workdir =~ s/\\/\\\\/g; + # and if there are still slashes, they also need to be double backslash + $fullmsidatabasepath =~ s/\//\\\\/g; + $workdir =~ s/\//\\\\/g; + } + + # Export of all tables by using "*" + + $systemcall = $msidb . " -d " . $fullmsidatabasepath . " -f " . $workdir . " -e $tablelist"; + print "\nAnalyzing msi database\n"; + $returnvalue = system($systemcall); + + if ($returnvalue) + { + $infoline = "ERROR: Could not execute $systemcall !\n"; + exit_program($infoline); + } +} + +######################################################## +# Check, if this installation set contains +# internal cabinet files included into the msi +# database. +######################################################## + +sub check_for_internal_cabfiles +{ + my ($cabfilehash) = @_; + + my $contains_internal_cabfiles = 0; + my %allcabfileshash = (); + + foreach my $filename ( keys %{$cabfilehash} ) + { + if ( $filename =~ /^\s*\#/ ) # starting with a hash + { + $contains_internal_cabfiles = 1; + # setting real filename without hash as key and name with hash as value + my $realfilename = $filename; + $realfilename =~ s/^\s*\#//; + $allcabfileshash{$realfilename} = $filename; + } + } + + return ( $contains_internal_cabfiles, \%allcabfileshash ); +} + +################################################################# +# Exclude all cab files from the msi database. +################################################################# + +sub extract_cabs_from_database +{ + my ($msidatabase, $allcabfiles) = @_; + + my $infoline = ""; + my $fullsuccess = 1; + my $msidb = "msidb.exe"; # Has to be in the path + if ( $localmsidbpath ) { $msidb = $localmsidbpath; } + + my @all_excluded_cabfiles = (); + + if( $^O =~ /cygwin/i ) + { + $msidatabase = qx{cygpath -w "$msidatabase"}; + $msidatabase =~ s/\\/\\\\/g; + $msidatabase =~ s/\s*$//g; + } + else + { + # msidb.exe really wants backslashes. (And double escaping because system() expands the string.) + $msidatabase =~ s/\//\\\\/g; + } + + foreach my $onefile ( keys %{$allcabfiles} ) + { + my $systemcall = $msidb . " -d " . $msidatabase . " -x " . $onefile; + system($systemcall); + push(@all_excluded_cabfiles, $onefile); + } + + \@all_excluded_cabfiles; +} + +################################################################################ +# Collect all DiskIds to the corresponding cabinet files from Media.idt. +################################################################################ + +sub analyze_media_file +{ + my ($filecontent) = @_; + + my %diskidhash = (); + + for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) + { + if ( $i < 3 ) { next; } + + if ( ${$filecontent}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ ) + { + my $diskid = $1; + my $cabfile = $4; + + $diskidhash{$cabfile} = $diskid; + } + } + + return \%diskidhash; +} + +sub analyze_customaction_file +{ + my ($filecontent) = @_; + + my $register_extensions_exists = 0; + + my %table = (); + + for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) + { + if ( ${$filecontent}[$i] =~ /^\s*RegisterExtensions\s+/ ) + { + $register_extensions_exists = 1; + last; + } + } + + return $register_extensions_exists; +} + +################################################################################ +# Analyzing the content of Directory.idt +################################################################################# + +sub analyze_directory_file +{ + my ($filecontent) = @_; + + my %table = (); + + for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) + { + if (( $i == 0 ) || ( $i == 1 ) || ( $i == 2 )) { next; } + + if ( ${$filecontent}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\s*$/ ) + { + my $dir = $1; + my $parent = $2; + my $name = $3; + + if ( $name =~ /^\s*(.*?)\s*\:\s*(.*?)\s*$/ ) { $name = $2; } + if ( $name =~ /^\s*(.*?)\s*\|\s*(.*?)\s*$/ ) { $name = $2; } + + my %helphash = (); + $helphash{'Directory_Parent'} = $parent; + $helphash{'DefaultDir'} = $name; + $table{$dir} = \%helphash; + } + } + + return \%table; +} + +################################################################################# +# Analyzing the content of Component.idt +################################################################################# + +sub analyze_component_file +{ + my ($filecontent) = @_; + + my %table = (); + + for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) + { + if (( $i == 0 ) || ( $i == 1 ) || ( $i == 2 )) { next; } + + if ( ${$filecontent}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ ) + { + my $component = $1; + my $dir = $3; + + $table{$component} = $dir; + } + } + + return \%table; +} + +################################################################################# +# Analyzing the content of File.idt +################################################################################# + +sub analyze_file_file +{ + my ($filecontent) = @_; + + my %table = (); + my %fileorder = (); + my $maxsequence = 0; + + for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) + { + if (( $i == 0 ) || ( $i == 1 ) || ( $i == 2 )) { next; } + + if ( ${$filecontent}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ ) + { + my $file = $1; + my $comp = $2; + my $filename = $3; + my $sequence = $8; + + if ( $filename =~ /^\s*(.*?)\s*\|\s*(.*?)\s*$/ ) { $filename = $2; } + + my %helphash = (); + $helphash{'Component'} = $comp; + $helphash{'FileName'} = $filename; + $helphash{'Sequence'} = $sequence; + + $table{$file} = \%helphash; + + $fileorder{$sequence} = $file; + + if ( $sequence > $maxsequence ) { $maxsequence = $sequence; } + } + } + + return (\%table, \%fileorder, $maxsequence); +} + +#################################################################################### +# Recursively creating the directory tree +#################################################################################### + +sub create_directory_tree +{ + my ($parent, $pathcollector, $fulldir, $dirhash) = @_; + + foreach my $dir ( keys %{$dirhash} ) + { + if (( $dirhash->{$dir}->{'Directory_Parent'} eq $parent ) && ( $dirhash->{$dir}->{'DefaultDir'} ne "." )) + { + my $dirname = $dirhash->{$dir}->{'DefaultDir'}; + # Create the directory + my $newdir = $fulldir . $separator . $dirname; + if ( ! -f $newdir ) { mkdir $newdir; } + # Saving in collector + $pathcollector->{$dir} = $newdir; + # Iteration + create_directory_tree($dir, $pathcollector, $newdir, $dirhash); + } + } +} + +#################################################################################### +# Creating the directory tree +#################################################################################### + +sub create_directory_structure +{ + my ($dirhash, $targetdir) = @_; + + print "Creating directories\n"; + + my %fullpathhash = (); + + my @startparents = ("TARGETDIR", "INSTALLLOCATION"); + + foreach $dir (@startparents) { create_directory_tree($dir, \%fullpathhash, $targetdir, $dirhash); } + + # Also adding the pathes of the startparents + foreach $dir (@startparents) + { + if ( ! exists($fullpathhash{$dir}) ) { $fullpathhash{$dir} = $targetdir; } + } + + return \%fullpathhash; +} + +#################################################################################### +# Cygwin: Setting privileges for files +#################################################################################### + +sub change_privileges +{ + my ($destfile, $privileges) = @_; + + my $localcall = "chmod $privileges " . "\"" . $destfile . "\""; + system($localcall); +} + +#################################################################################### +# Cygwin: Setting privileges for files recursively +#################################################################################### + +sub change_privileges_full +{ + my ($target) = @_; + + print "Changing privileges\n"; + + my $localcall = "chmod -R 755 " . "\"" . $target . "\""; + system($localcall); +} + +###################################################### +# Creating a new directory with defined privileges +###################################################### + +sub create_directory_with_privileges +{ + my ($directory, $privileges) = @_; + + my $returnvalue = 1; + my $infoline = ""; + + if (!(-d $directory)) + { + my $localprivileges = oct("0".$privileges); # changes "777" to 0777 + $returnvalue = mkdir($directory, $localprivileges); + + if ($returnvalue) + { + my $localcall = "chmod $privileges $directory \>\/dev\/null 2\>\&1"; + system($localcall); + } + } + else + { + my $localcall = "chmod $privileges $directory \>\/dev\/null 2\>\&1"; + system($localcall); + } +} + +###################################################### +# Creating a unique directory with pid extension +###################################################### + +sub create_pid_directory +{ + my ($directory) = @_; + + $directory =~ s/\Q$separator\E\s*$//; + my $pid = $$; # process id + my $time = time(); # time + + $directory = $directory . "_" . $pid . $time; + + if ( ! -d $directory ) { create_directory($directory); } + else { exit_program("ERROR: Directory $directory already exists!"); } + + return $directory; +} + +#################################################################################### +# Copying files into installation set +#################################################################################### + +sub copy_files_into_directory_structure +{ + my ($fileorder, $filehash, $componenthash, $fullpathhash, $maxsequence, $unpackdir, $installdir, $dirhash) = @_; + + print "Copying files\n"; + + my $unopkgfile = ""; + + for ( my $i = 1; $i <= $maxsequence; $i++ ) + { + if ( exists($fileorder->{$i}) ) + { + my $file = $fileorder->{$i}; + if ( ! exists($filehash->{$file}->{'Component'}) ) { exit_program("ERROR: Did not find component for file: \"$file\"."); } + my $component = $filehash->{$file}->{'Component'}; + if ( ! exists($componenthash->{$component}) ) { exit_program("ERROR: Did not find directory for component: \"$component\"."); } + my $dirname = $componenthash->{$component}; + if ( ! exists($fullpathhash->{$dirname}) ) { exit_program("ERROR: Did not find full directory path for dir: \"$dirname\"."); } + my $destdir = $fullpathhash->{$dirname}; + if ( ! exists($filehash->{$file}->{'FileName'}) ) { exit_program("ERROR: Did not find \"FileName\" for file: \"$file\"."); } + my $destfile = $filehash->{$file}->{'FileName'}; + + $destfile = $destdir . $separator . $destfile; + my $sourcefile = $unpackdir . $separator . $file; + + if ( ! -f $sourcefile ) + { + # It is possible, that this was an unpacked file + # Looking in the dirhash, to find the subdirectory in the installation set (the id is $dirname) + # subdir is not recursively analyzed, only one directory. + + my $oldsourcefile = $sourcefile; + my $subdir = ""; + if ( exists($dirhash->{$dirname}->{'DefaultDir'}) ) { $subdir = $dirhash->{$dirname}->{'DefaultDir'} . $separator; } + my $realfilename = $filehash->{$file}->{'FileName'}; + my $localinstalldir = $installdir; + + $localinstalldir =~ s/\\\s*$//; + $localinstalldir =~ s/\/\s*$//; + + $sourcefile = $localinstalldir . $separator . $subdir . $realfilename; + + if ( ! -f $sourcefile ) { exit_program("ERROR: File not found: \"$oldsourcefile\" (or \"$sourcefile\")."); } + } + + my $copyreturn = copy($sourcefile, $destfile); + + if ( ! $copyreturn) { exit_program("ERROR: Could not copy $source to $dest\n"); } + + # Searching unopkg.exe + if ( $destfile =~ /unopkg\.exe\s*$/ ) { $unopkgfile = $destfile; } + # if (( $^O =~ /cygwin/i ) && ( $destfile =~ /\.exe\s*$/ )) { change_privileges($destfile, "775"); } + } + # else # allowing missing sequence numbers ? + # { + # exit_program("ERROR: No file assigned to sequence $i"); + # } + } + + return ($unopkgfile); +} + +###################################################### +# Removing a complete directory with subdirectories +###################################################### + +sub remove_complete_directory +{ + my ($directory, $start) = @_; + + my @content = (); + my $infoline = ""; + + $directory =~ s/\Q$separator\E\s*$//; + + if ( -d $directory ) + { + if ( $start ) { print "Removing directory $directory\n"; } + + opendir(DIR, $directory); + @content = readdir(DIR); + closedir(DIR); + + my $oneitem; + + foreach $oneitem (@content) + { + if ((!($oneitem eq ".")) && (!($oneitem eq ".."))) + { + my $item = $directory . $separator . $oneitem; + + if ( -f $item || -l $item ) # deleting files or links + { + unlink($item); + } + + if ( -d $item ) # recursive + { + remove_complete_directory($item, 0); + } + } + } + + # try to remove empty directory + my $returnvalue = rmdir $directory; + if ( ! $returnvalue ) { print "Warning: Problem with removing empty dir $directory\n"; } + } +} + +#################################################################################### +# Defining a temporary path +#################################################################################### + +sub get_temppath +{ + my $temppath = ""; + + if (( $ENV{'TMP'} ) || ( $ENV{'TEMP'} )) + { + if ( $ENV{'TMP'} ) { $temppath = $ENV{'TMP'}; } + elsif ( $ENV{'TEMP'} ) { $temppath = $ENV{'TEMP'}; } + + $temppath =~ s/\Q$separator\E\s*$//; # removing ending slashes and backslashes + $temppath = $temppath . $separator . $globaltempdirname; + create_directory_with_privileges($temppath, "777"); + + my $dirsave = $temppath; + + $temppath = $temppath . $separator . "a"; + $temppath = create_pid_directory($temppath); + + if ( ! -d $temppath ) { exit_program("ERROR: Failed to create directory $temppath ! Possible reason: Wrong privileges in directory $dirsave."); } + + if ( $^O =~ /cygwin/i ) + { + $temppath =~ s/\\/\\\\/g; + chomp( $temppath = qx{cygpath -w "$temppath"} ); + } + + $savetemppath = $temppath; + } + else + { + exit_program("ERROR: Could not set temporary directory (TMP and TEMP not set!)."); + } + + return $temppath; +} + +#################################################################################### +# Registering extensions +#################################################################################### + +sub register_extensions_sync +{ + my ($unopkgfile, $localtemppath, $preregdir) = @_; + + if ( $preregdir eq "" ) + { + my $logtext = "ERROR: Failed to determine \"prereg\" folder for extension registration! Please check your installation set."; + print $logtext . "\n"; + exit_program($logtext); + } + + my $from = cwd(); + + my $path = $unopkgfile; + get_path_from_fullqualifiedname(\$path); + $path =~ s/\\\s*$//; + $path =~ s/\/\s*$//; + + my $executable = $unopkgfile; + make_absolute_filename_to_relative_filename(\$executable); + + chdir($path); + + if ( ! $path_displayed ) + { + print "... current dir: $path ...\n"; + $path_displayed = 1; + } + + $localtemppath =~ s/\\/\//g; + + if ( $^O =~ /cygwin/i ) { + $executable = "./" . $executable; + $preregdir = qx{cygpath -m "$preregdir"}; + chomp($preregdir); + } + + $preregdir =~ s/\/\s*$//g; + + my $systemcall = $executable . " sync --verbose 2\>\&1 |"; + + print "... $systemcall\n"; + + my @unopkgoutput = (); + + open (UNOPKG, $systemcall); + while (<UNOPKG>) {push(@unopkgoutput, $_); } + close (UNOPKG); + + my $returnvalue = $?; # $? contains the return value of the systemcall + + if ($returnvalue) + { + print "ERROR: Could not execute \"$systemcall\"!\nExitcode: '$returnvalue'\n"; + for ( my $j = 0; $j <= $#unopkgoutput; $j++ ) { print "$unopkgoutput[$j]"; } + exit_program("ERROR: $systemcall failed!"); + } + + chdir($from); +} + +#################################################################################### +# Registering all extensions located in /share/extension/install +#################################################################################### + +sub register_extensions +{ + my ($unopkgfile, $temppath, $preregdir) = @_; + + print "Registering extensions:\n"; + + if (( ! -f $unopkgfile ) || ( $unopkgfile eq "" )) + { + print("WARNING: Could not find unopkg.exe (Language Pack?)!\n"); + } + else + { + register_extensions_sync($unopkgfile, $temppath, $preregdir); + remove_complete_directory($temppath, 1); + } + +} + +#################################################################################### +# Reading one file +#################################################################################### + +sub read_file +{ + my ($localfile) = @_; + + my @localfile = (); + + open( IN, "<$localfile" ) || exit_program("ERROR: Cannot open file $localfile for reading"); + + # Don't use "my @localfile = <IN>" here, because + # perl has a problem with the internal "large_and_huge_malloc" function + # when calling perl using MacOS 10.5 with a perl built with MacOS 10.4 + while ( $line = <IN> ) { + push @localfile, $line; + } + + close( IN ); + + return \@localfile; +} + +############################################################### +# Setting the time string for the +# Summary Information stream in the +# msi database of the admin installations. +############################################################### + +sub get_sis_time_string +{ + # Syntax: <yyyy/mm/dd hh:mm:ss> + my $second = (localtime())[0]; + my $minute = (localtime())[1]; + my $hour = (localtime())[2]; + my $day = (localtime())[3]; + my $month = (localtime())[4]; + my $year = 1900 + (localtime())[5]; + $month++; + + if ( $second < 10 ) { $second = "0" . $second; } + if ( $minute < 10 ) { $minute = "0" . $minute; } + if ( $hour < 10 ) { $hour = "0" . $hour; } + if ( $day < 10 ) { $day = "0" . $day; } + if ( $month < 10 ) { $month = "0" . $month; } + + my $timestring = $year . "/" . $month . "/" . $day . " " . $hour . ":" . $minute . ":" . $second; + + return $timestring; +} + +############################################################### +# Writing content of administrative installations into +# Summary Information Stream of msi database. +# This is required for example for following +# patch processes using Windows Installer service. +############################################################### + +sub write_sis_info +{ + my ($msidatabase) = @_; + + print "Setting SIS in msi database\n"; + + if ( ! -f $msidatabase ) { exit_program("ERROR: Cannot find file $msidatabase"); } + + my $msiinfo = "msiinfo.exe"; # Has to be in the path + my $infoline = ""; + my $systemcall = ""; + my $returnvalue = ""; + + # Required setting for administrative installations: + # -w 4 (source files are unpacked), wordcount + # -s <date of admin installation>, LastPrinted, Syntax: <yyyy/mm/dd hh:mm:ss> + # -l <person_making_admin_installation>, LastSavedBy + + my $wordcount = 4; # Unpacked files + my $lastprinted = get_sis_time_string(); + my $lastsavedby = "Installer"; + + my $localmsidatabase = $msidatabase; + + if( $^O =~ /cygwin/i ) + { + $localmsidatabase = qx{cygpath -w "$localmsidatabase"}; + $localmsidatabase =~ s/\\/\\\\/g; + $localmsidatabase =~ s/\s*$//g; + } + + $systemcall = $msiinfo . " " . "\"" . $localmsidatabase . "\"" . " -w " . $wordcount . " -s " . "\"" . $lastprinted . "\"" . " -l $lastsavedby"; + + $returnvalue = system($systemcall); + + if ($returnvalue) + { + $infoline = "ERROR: Could not execute $systemcall !\n"; + exit_program($infoline); + } +} + +############################################################### +# Convert time string +############################################################### + +sub convert_timestring +{ + my ($secondstring) = @_; + + my $timestring = ""; + + if ( $secondstring < 60 ) # less than a minute + { + if ( $secondstring < 10 ) { $secondstring = "0" . $secondstring; } + $timestring = "00\:$secondstring min\."; + } + elsif ( $secondstring < 3600 ) + { + my $minutes = $secondstring / 60; + my $seconds = $secondstring % 60; + if ( $minutes =~ /(\d*)\.\d*/ ) { $minutes = $1; } + if ( $minutes < 10 ) { $minutes = "0" . $minutes; } + if ( $seconds < 10 ) { $seconds = "0" . $seconds; } + $timestring = "$minutes\:$seconds min\."; + } + else # more than one hour + { + my $hours = $secondstring / 3600; + my $secondstring = $secondstring % 3600; + my $minutes = $secondstring / 60; + my $seconds = $secondstring % 60; + if ( $hours =~ /(\d*)\.\d*/ ) { $hours = $1; } + if ( $minutes =~ /(\d*)\.\d*/ ) { $minutes = $1; } + if ( $hours < 10 ) { $hours = "0" . $hours; } + if ( $minutes < 10 ) { $minutes = "0" . $minutes; } + if ( $seconds < 10 ) { $seconds = "0" . $seconds; } + $timestring = "$hours\:$minutes\:$seconds hours"; + } + + return $timestring; +} + +############################################################### +# Returning time string for logging +############################################################### + +sub get_time_string +{ + my $currenttime = time(); + $currenttime = $currenttime - $starttime; + $currenttime = convert_timestring($currenttime); + $currenttime = localtime() . " \(" . $currenttime . "\)\n"; + return $currenttime; +} + +#################################################################################### +# Simulating an administrative installation +#################################################################################### + +$starttime = time(); + +getparameter(); +controlparameter(); +check_local_msidb(); +check_system_path(); +my $temppath = get_temppath(); + +print("\nmsi database: $databasepath\n"); +print("Destination directory: $targetdir\n" ); + +my $helperdir = $temppath . $separator . "installhelper"; +create_directory($helperdir); + +# Get File.idt, Component.idt and Directory.idt from database + +my $tablelist = "File Directory Component Media CustomAction"; +extract_tables_from_database($databasepath, $helperdir, $tablelist); + +# Set unpackdir +my $unpackdir = $helperdir . $separator . "unpack"; +create_directory($unpackdir); + +# Reading media table to check for internal cabinet files +my $filename = $helperdir . $separator . "Media.idt"; +if ( ! -f $filename ) { exit_program("ERROR: Could not find required file: $filename !"); } +my $filecontent = read_file($filename); +my $cabfilehash = analyze_media_file($filecontent); + +# Check, if there are internal cab files +my ( $contains_internal_cabfiles, $all_internal_cab_files) = check_for_internal_cabfiles($cabfilehash); + +if ( $contains_internal_cabfiles ) +{ + # Set unpackdir + my $cabdir = $helperdir . $separator . "internal_cabs"; + create_directory($cabdir); + my $from = cwd(); + chdir($cabdir); + # Exclude all cabinet files from database + my $all_excluded_cabs = extract_cabs_from_database($databasepath, $all_internal_cab_files); + print "Unpacking files from internal cabinet file(s)\n"; + foreach my $cabfile ( @{$all_excluded_cabs} ) { unpack_cabinet_file($cabfile, $unpackdir); } + chdir($from); +} + +# Unpack all cab files into $helperdir, cab files must be located next to msi database +my $installdir = $databasepath; + +get_path_from_fullqualifiedname(\$installdir); + +my $databasefilename = $databasepath; +make_absolute_filename_to_relative_filename(\$databasefilename); + +my $cabfiles = find_file_with_file_extension("cab", $installdir); + +if (( $#{$cabfiles} < 0 ) && ( ! $contains_internal_cabfiles )) { exit_program("ERROR: Did not find any cab file in directory $installdir"); } + +print "Unpacking files from cabinet file(s)\n"; +for ( my $i = 0; $i <= $#{$cabfiles}; $i++ ) +{ + my $cabfile = $installdir . $separator . ${$cabfiles}[$i]; + unpack_cabinet_file($cabfile, $unpackdir); +} + +# Reading tables +$filename = $helperdir . $separator . "Directory.idt"; +$filecontent = read_file($filename); +my $dirhash = analyze_directory_file($filecontent); + +$filename = $helperdir . $separator . "Component.idt"; +$filecontent = read_file($filename); +my $componenthash = analyze_component_file($filecontent); + +$filename = $helperdir . $separator . "File.idt"; +$filecontent = read_file($filename); +my ( $filehash, $fileorder, $maxsequence ) = analyze_file_file($filecontent); + +# Creating the directory structure +my $fullpathhash = create_directory_structure($dirhash, $targetdir); + +# Copying files +my ($unopkgfile) = copy_files_into_directory_structure($fileorder, $filehash, $componenthash, $fullpathhash, $maxsequence, $unpackdir, $installdir, $dirhash); +if ( $^O =~ /cygwin/i ) { change_privileges_full($targetdir); } + +my $msidatabase = $targetdir . $separator . $databasefilename; +my $copyreturn = copy($databasepath, $msidatabase); +if ( ! $copyreturn) { exit_program("ERROR: Could not copy $source to $dest\n"); } + +# Reading tables +$filename = $helperdir . $separator . "CustomAction.idt"; +$filecontent = read_file($filename); +my $register_extensions_exists = analyze_customaction_file($filecontent); + +# Removing empty dirs in extension folder +my ( $extensionfolder, $preregdir ) = get_extensions_dir($unopkgfile); +if ( -d $extensionfolder ) { remove_empty_dirs_in_folder($extensionfolder, 1); } + +if ( $register_extensions_exists ) +{ + # Registering extensions + register_extensions($unopkgfile, $temppath, $preregdir); +} + +# Saving info in Summary Information Stream of msi database (required for following patches) +if ( $msiinfo_available ) { write_sis_info($msidatabase); } + +# Removing the helper directory +remove_complete_directory($temppath, 1); + +print "\nSuccessful installation: " . get_time_string(); diff --git a/setup_native/scripts/deregister_extensions b/setup_native/scripts/deregister_extensions new file mode 100644 index 000000000000..4a8f91de41f0 --- /dev/null +++ b/setup_native/scripts/deregister_extensions @@ -0,0 +1,78 @@ +#!/bin/bash + +USAGE="Usage: $0" + +SCRIPTNAME=`basename "$0"` +PROGRAMDIR=`dirname "$0"` +OFFICEDIR="$PROGRAMDIR/.." +EXTENSIONDIR=$OFFICEDIR/share/extension/install +UNOPKG=$PROGRAMDIR/unopkg + +help() +{ + echo + echo "Uninstallation script for office extensions located in <office>/share/extension/install" + echo + echo "This uninstallation script can be executed after successful installation of packages." + echo "Please execute this script, before uninstallation of packages." + echo "Usage: $0" + echo "No parameter required." + echo +} + +# +# This script is only for root installations +# (How about installations done with user privileges?) +# + +# if [ $UID -ne 0 ] +# then +# printf "\nThis script is for installation only wiht administrative rights only\n" +# help +# exit 2 +# fi + +# +# Checking existence of unopkg in program directory +# + +if [ ! -f "$UNOPKG" ]; then + echo "Error: File $UNOPKG does not exist" + exit 1 +fi + +if [ ! -x "$UNOPKG" ]; then + echo "Error: File $UNOPKG is not an executable file" + exit 1 +fi + +# +# Collecting all files located in share/install/extensions +# + +FILELIST=`find $EXTENSIONDIR -type f -name "*.oxt" -print` + +if [ -z "$FILELIST" ] +then + printf "\n$0: No extensions found in $EXTENSIONDIR\n" + exit 2 +fi + +echo +echo "Uninstalling:" +for i in $FILELIST; do + echo `basename $i` +done +echo + +for i in $FILELIST; do + COMMAND="$UNOPKG remove --shared `basename $i`" + echo $COMMAND + $COMMAND +done + +echo +echo "Uninstallation done ..." +echo + +exit 0 diff --git a/setup_native/scripts/downloadscript.sh b/setup_native/scripts/downloadscript.sh new file mode 100644 index 000000000000..e138ae057dd0 --- /dev/null +++ b/setup_native/scripts/downloadscript.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +linenum=LINENUMBERPLACEHOLDER + +UNPACKDIR=/var/tmp/unpack_PRODUCTNAMEPLACEHOLDER +diskSpaceRequired=DISCSPACEPLACEHOLDER +checksum=CHECKSUMPLACEHOLDER + +EXTRACTONLY="no" +if [ "$1" = "-x" ] +then + EXTRACTONLY=yes +fi + +# Determining current platform + +platform=`uname -s` + +case $platform in +SunOS) + tail_prog="tail" + ;; +Linux) + tail_prog="tail -n" + ;; +*) + tail_prog="tail" + ;; +esac + +# Asking for the unpack directory + +echo +echo "Select the directory in which to save the unpacked files. [$UNPACKDIR] " +read reply leftover +if [ "x$reply" != "x" ] +then + UNPACKDIR="$reply" +fi + +if [ -d $UNPACKDIR ]; then + printf "Directory $UNPACKDIR already exists.\n" + printf "Please select a new directory name.\n" + exit 1 +fi + +# Unpacking + +mkdir -m 700 $UNPACKDIR + +diskSpace=`df -k $UNPACKDIR | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'` +if [ $diskSpace -lt $diskSpaceRequired ]; then + printf "The selected drive does not have enough disk space available.\n" + printf "PRODUCTNAMEPLACEHOLDER requires at least %s kByte.\n" $diskSpaceRequired + exit 1 +fi + +trap 'rm -rf $UNPACKDIR; exit 1' HUP INT QUIT TERM + +if [ -x /usr/bin/sum ] ; then + echo "File is being checked for errors ..." + + sum=`$tail_prog +$linenum $0 | /usr/bin/sum` + sum=`echo $sum | awk '{ print $1 }'` + + if [ $sum != $checksum ]; then + echo "The download file appears to be corrupted. Please download PRODUCTNAMEPLACEHOLDER again." + exit 1 + fi +fi + +echo "Unpacking ..." + +$tail_prog +$linenum $0 | (cd $UNPACKDIR; tar xf -) + +echo "All files have been successfully unpacked." + +if [ "$EXTRACTONLY" != "yes" ] +then + if [ -f $UNPACKDIR/setup ] + then + chmod 775 $UNPACKDIR/setup + $UNPACKDIR/setup + fi +fi + +exit 0 diff --git a/setup_native/scripts/fake-db.spec b/setup_native/scripts/fake-db.spec new file mode 100644 index 000000000000..e6275048efe3 --- /dev/null +++ b/setup_native/scripts/fake-db.spec @@ -0,0 +1,38 @@ +Name: fake-db +Version: 1.0 +Release: 0 +Summary: This is a dummy package +Group: dummy +License: LGPL +BuildArch: noarch +AutoReqProv: no +%define _tmppath /tmp +#BuildRoot: %{_tmppath}/%{name}-root +Provides: libgnomevfs-2.so.0 +Provides: libgconf-2.so.4 +Provides: libfreetype.so.6 +Provides: /bin/sh +Provides: /bin/basename +Provides: /bin/cat +Provides: /bin/cp +Provides: /bin/gawk +Provides: /bin/grep +Provides: /bin/ln +Provides: /bin/ls +Provides: /bin/mkdir +Provides: /bin/mv +Provides: /bin/pwd +Provides: /bin/rm +Provides: /bin/sed +Provides: /bin/sort +Provides: /bin/touch +Provides: /usr/bin/cut +Provides: /usr/bin/dirname +Provides: /usr/bin/expr +Provides: /usr/bin/find +Provides: /usr/bin/tail +Provides: /usr/bin/tr +Provides: /usr/bin/wc +%description +a dummy package +%files diff --git a/setup_native/scripts/install_create.pl b/setup_native/scripts/install_create.pl new file mode 100755 index 000000000000..c49f22ddbc70 --- /dev/null +++ b/setup_native/scripts/install_create.pl @@ -0,0 +1,44 @@ +: # -*- perl -*- +eval 'exec perl -wS $0 ${1+"$@"}' + if 0; +# create setup self extracting script + +if( $#ARGV < 2 ) + { + print <<ENDHELP; +USAGE: $0 <inputshellscript> <libraryfile> <outputshellscript> + <inputshellscript>: the start shell script, located next to this perl script + <libraryfile>: the library file, that is included into the shell script + <outfile>: the target shellscript + +ENDHELP + exit; + } + +$infile = $ARGV[0]; +$library = $ARGV[1]; +$outfile = $ARGV[2]; +$infile =~ tr/[A-Z]/[a-z]/; + +# read script header +open( SCRIPT, "<$infile" ) || die "cannot open $infile"; +open( OUTFILE, ">$outfile$$.tmp" ) || die "cannot open $outfile"; +@scriptlines = <SCRIPT>; +$linenum = $#scriptlines+2; +foreach (@scriptlines) +{ + # lineend conversion (be on the safe side) + chomp; + $_ =~ tr/\r//; + s/^\s*linenum=.*$/linenum=$linenum/; + print OUTFILE "$_\n"; +} +close( SCRIPT ); +close( OUTFILE ); + +system( "cat $library >>$outfile$$.tmp" ); +rename "$outfile$$.tmp", "$outfile"; + +chmod 0775, $outfile; + +exit; diff --git a/setup_native/scripts/install_linux.sh b/setup_native/scripts/install_linux.sh new file mode 100644 index 000000000000..c33fe989554f --- /dev/null +++ b/setup_native/scripts/install_linux.sh @@ -0,0 +1,301 @@ +#!/bin/bash + +ADD="no" +LINK="no" +UPDATE="ask" +UNPACKDIR="" +USAGE="Usage: $0 [-a,--add] [-l,--link] [-U,--update] [-h,--help] <rpm-source-dir> <office-installation-dir>" + +help() +{ + echo + echo "User Mode Installation script for developer and knowledgeable early access tester" + echo + echo "This installation method is not intended for use in a production environment!" + echo "Using this script is unsupported and completely at your own risk" + echo + echo "Usage:" $0 [-lU] "<rpm-source-dir> <office-installation-dir>" + echo " <rpm-source-dir>: directory *only* containing the Linux rpm packages to be installed" + echo " or language pack shell script containing the rpm packages" + echo " <office-installation-dir>: directory to where the office will get installed into" + echo + echo "Optional Parameter:" + echo " -a,--add: add to an existing <office-installation-dir>" + echo " -l,--link: create a link \"soffice\" in $HOME" + echo " -U,--update: update without asking" + echo " -h,--help: output this help" + echo +} + +try_to_unpack_languagepack_file() +{ + FILENAME=$PACKAGE_PATH + + # Checking, if $FILENAME is a language pack. + # String "language package" has to exist in the shell script file. + # If this is no language pack, the installation is not supported + + SEARCHSTRING=`head --lines=10 $FILENAME | grep "language package"` + + if [ ! -z "$SEARCHSTRING" ] + then + echo "First parameter $FILENAME is a language pack"; + else + printf "\nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n" + echo $USAGE + exit 2 + fi + + echo "Unpacking shell script $FILENAME" + TAILLINE=`head --lines=20 $FILENAME | sed --quiet 's/linenum=//p'` + + UNPACKDIR=/var/tmp/install_$$ + mkdir $UNPACKDIR + # UNPACKDIR=`mktemp -d` + tail -n +$TAILLINE $FILENAME | gunzip | (cd $UNPACKDIR; tar xvf -) + + # Setting the new package path, in which the packages exist + PACKAGE_PATH=$UNPACKDIR + + # Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed + UPDATE="yes" +} + +# +# this script is for userland not for root +# + +if [ $UID -eq 0 ] +then + printf "\nThis script is for installation without administrative rights only\nPlease use rpm to install as root\n" + help + exit 2 +fi + +set -- `getopt -u -o 'alhU' -l 'add,link,help,update' -- $*` + +if [ $? != 0 ] +then + echo $USAGE + exit 2 +fi + +for i in $* +do + case $i in + -a|--add) ADD="yes"; shift;; + -h|--help) help; exit 0;; + -l|--link) LINK="yes"; shift;; + -U|--update) UPDATE="yes"; shift;; + --) shift; break;; + esac +done + +if [ $# != 2 ] +then + echo $USAGE + exit 2 +fi + +PACKAGE_PATH=$1 + +# +# If the first parameter is a shell script (download installation set), the packages have to +# be unpacked into temp directory +# + +if [ -f "$PACKAGE_PATH" ] +then + try_to_unpack_languagepack_file +fi + +# +# Check and get the list of packages to install +# + +RPMLIST=`find $PACKAGE_PATH -maxdepth 2 -type f -name "*.rpm" ! -name "*-menus-*" ! -name "*-desktop-integration-*" ! -name "jre*" ! -name "*-userland-*" -print` + +if [ -z "$RPMLIST" ] +then + printf "\n$0: No packages found in $PACKAGE_PATH\n" + exit 2 +fi + +# #163256# check if we are on a debian system... +if rpm --help | grep debian >/dev/null; +then + DEBIAN_FLAGS="--force-debian --nodeps" +else + DEBIAN_FLAGS= +fi + +# +# Determine whether this should be an update or a fresh install +# + +INSTALLDIR=$2 +RPM_DB_PATH=${INSTALLDIR}/var/lib/rpm + +# Check for versionrc +if [ -f ${INSTALLDIR}/program/versionrc ]; then VERSIONRC=versionrc; fi + +if [ "$UPDATE" = "ask" ] +then + PRODUCT=`sed --silent -e " +/^buildid=/ { +s/buildid=\(.*\)/ [\1]/ +h +} +/^ProductKey=/ { +s/ProductKey=// +G +p +}" ${INSTALLDIR}/program/${VERSIONRC:-bootstraprc} 2>/dev/null | tr -d "\012"` + + if [ ! -z "$PRODUCT" ] + then + echo + echo "Found an installation of $PRODUCT in $INSTALLDIR" + echo + while [ "$UPDATE" != "yes" ] + do + read -a UPDATE -p "Do you want to update this installation (yes/no)? " + if [ "$UPDATE" = "no" ] + then + exit 2 + fi + done + elif [ -d $RPM_DB_PATH -a "$ADD" = "no" ] + then + echo + echo "The following packages are already installed in $INSTALLDIR" + echo + rpm --dbpath `cd $RPM_DB_PATH; pwd` --query --all + echo + while [ "$UPDATE" != "yes" ] + do + read -a UPDATE -p "Do you want to continue with this installation (yes/no)? " + if [ "$UPDATE" = "no" ] + then + exit 2 + fi + done + else + UPDATE="no" + fi +fi + +# +# Check/Create installation directory +# + +if [ "$UPDATE" = "yes" ] +then + # restore original bootstraprc + mv -f ${INSTALLDIR}/program/bootstraprc.orig ${INSTALLDIR}/program/bootstraprc 2>/dev/null + + # the RPM_DB_PATH must be absolute + if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then + RPM_DB_PATH=`cd ${RPM_DB_PATH}; pwd` + fi + + # we should use --freshen for updates to not add languages with patches, but this will break + # language packs, so leave it for now .. +# RPMCMD="--freshen" + RPMCMD="--upgrade" +else + rmdir ${INSTALLDIR} 2>/dev/null + + if [ -d ${INSTALLDIR} -a "$ADD" = "no" ] + then + printf "\n$0: ${INSTALLDIR} exists and is not empty.\n" + exit 2 + fi + + mkdir -p $RPM_DB_PATH || exit 2 + # XXX why ? XXX + chmod 700 $RPM_DB_PATH + + # the RPM_DB_PATH must be absolute + if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then + RPM_DB_PATH=`cd ${RPM_DB_PATH}; pwd` + fi + + # Creating RPM database and initializing + if [ "$ADD" = "no" ]; then + rpm --initdb --dbpath $RPM_DB_PATH + fi + + # Default install command + RPMCMD="--install" +fi + +# populate the private rpm database with the dependencies needed +FAKEDBRPM=/tmp/fake-db-1.0-$$.noarch.rpm +linenum=??? +tail -n +$linenum $0 > $FAKEDBRPM + +rpm ${DEBIAN_FLAGS} --upgrade --ignoresize --dbpath $RPM_DB_PATH $FAKEDBRPM + +rm -f $FAKEDBRPM + +echo "Packages found:" +for i in $RPMLIST ; do + echo `basename $i` +done + +# +# Perform the installation +# + +echo +echo "####################################################################" +echo "# Installation of the found packages #" +echo "####################################################################" +echo +echo "Path to the database: " $RPM_DB_PATH +echo "Path to the packages: " $PACKAGE_PATH +echo "Path to the installation: " $INSTALLDIR +echo +echo "Installing the RPMs" + +ABSROOT=`cd ${INSTALLDIR}; pwd` +RELOCATIONS=`rpm -qp --qf "--relocate %{PREFIXES}=${ABSROOT}%{PREFIXES} \n" $RPMLIST | sort -u | tr -d "\012"` +UserInstallation=\$BRAND_BASE_DIR/../UserInstallation rpm ${DEBIAN_FLAGS} $RPMCMD --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST + +# +# Create a link into the users home directory +# + +if [ "$LINK" = "yes" ] +then + find `cd "$INSTALLDIR" && pwd` -name soffice -type f -perm /u+x -exec /bin/bash -ce 'ln -sf "$0" "$HOME/soffice" && echo "Creating link from $0 to $HOME/soffice"' {} \; +fi + +if [ "$UPDATE" = "yes" -a ! -f $INSTALLDIR/program/bootstraprc ] +then + echo + echo "Update failed due to a bug in RPM, uninstalling .." + rpm ${DEBIAN_FLAGS} --erase -v --nodeps --dbpath $RPM_DB_PATH `rpm --query --queryformat "%{NAME} " --package $RPMLIST --dbpath $RPM_DB_PATH` + echo + echo "Now re-installing new packages .." + echo + rpm ${DEBIAN_FLAGS} --install --nodeps --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST + echo +fi + +# patch the "bootstraprc" to create a self-containing installation +find "$INSTALLDIR" -type f -name bootstraprc -exec /bin/bash -ce 'test ! -e "$0".orig && mv "$0" "$0".orig && sed '\''s,^UserInstallation=$SYSUSERCONFIG.*,UserInstallation=$BRAND_BASE_DIR/../UserInstallation,'\'' "$0".orig > "$0"' {} \; + +# if an unpack directory exists, it can be removed now +if [ ! -z "$UNPACKDIR" ] +then + rm $UNPACKDIR/*.rpm + rmdir $UNPACKDIR + echo "Removed temporary directory $UNPACKDIR" +fi + +echo +echo "Installation done ..." + +exit 0 diff --git a/setup_native/scripts/install_solaris.sh b/setup_native/scripts/install_solaris.sh new file mode 100644 index 000000000000..bb792bcf2618 --- /dev/null +++ b/setup_native/scripts/install_solaris.sh @@ -0,0 +1,364 @@ +#!/bin/bash + +ADD="no" +LINK="no" +UPDATE="no" +USAGE="Usage: $0 [-a] [-l] [-h] <pkg-source-dir> <office-installation-dir>" + +help() +{ + echo + echo "User Mode Installation script for developer and knowledgeable early access tester" + echo + echo "This installation method is not intended for use in a production environment!" + echo "Using this script is unsupported and completely at your own risk" + echo + echo "Usage:" $0 "<pkg-source-dir> <office-installation-dir> [-l]" + echo " <pkg-source-dir>: directory *only* containing the Solaris pkg packages to be installed" + echo " or language pack shell script containing the Solaris pkg packages" + echo " <office-installation-dir>: directory to where the office and the pkg database will get installed into" + echo + echo "Optional Parameter:" + echo " -a : add to an existing <office-installation-dir>" + echo " -l : create a link \"soffice\" in $HOME" + echo " -h : output this help" +} + +try_to_unpack_languagepack_file() +{ + FILENAME=$PACKAGE_PATH + + # Checking, if $FILENAME is a language pack. + # String "language package" has to exist in the shell script file. + # If this is no language pack, the installation is not supported + + SEARCHSTRING=`head -n 10 $FILENAME | grep "language package"` + + if [ ! -z "$SEARCHSTRING" ] + then + echo "First parameter $FILENAME is a language pack"; + else + printf "\nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n" + echo $USAGE + exit 2 + fi + + echo "Unpacking shell script $FILENAME" + # TAILLINE=`head -n 20 $FILENAME | sed --quiet 's/linenum=//p'` + TAILLINE=`head -n 20 $FILENAME | sed -n 's/linenum=//p'` + + if [ -x "/usr/bin/mktemp" ] # available in Solaris 10 + then + UNPACKDIR=`mktemp -d` + else + UNPACKDIR=/var/tmp/install_$$ + mkdir $UNPACKDIR + fi + + echo $UNPACKDIR + tail +$TAILLINE $FILENAME | gunzip | (cd $UNPACKDIR; tar xvf -) + + # Setting the new package path, in which the packages exist + PACKAGE_PATH=$UNPACKDIR + + # Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed + UPDATE="yes" +} + +pkg_error() +{ + # pkg command failed, check for admin log and report help + if [ -f /tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e ] + then + echo "####################################################################" + echo "# Installation failed due to stale administrative lock #" + echo "####################################################################" + printf "\nERROR: please remove the following file first:\n" + ls -l /tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e + fi + rm -f $GETUID_SO + exit 1 +} + +get_pkg_list() +{ + cd $1; ls -1 +} + +# +# this script is for userland not for root +# + +if [ $UID -eq 0 ] +then + printf "\nThis script is for installation without administrative rights only\nPlease use pkgadd/patchadd to install as root\n" + help + exit 2 +fi + +while getopts "alh" VALUE +do + echo $VALUE + case $VALUE in + a) ADD="yes"; break;; + h) help; exit 0;; + l) LINK="yes"; break;; + ?) echo $USAGE; exit 2;; + esac +done +shift `expr $OPTIND - 1` + +if [ $# != 2 ] +then + echo $USAGE + exit 2 +fi + +# Determine whether this is a patch or a regular install set .. +/bin/bash -c "ls $1/*/patchinfo >/dev/null 2>&1" +if [ "$?" = 0 ] +then + UPDATE="yes" + PATCH_PATH="$1" + PATCH_INFO_LIST=`/bin/bash -c "cd $1; ls */patchinfo"` + PATCH_LIST=`for i in ${PATCH_INFO_LIST}; do dirname $i; done` +elif [ -f "$1/patchinfo" ] +then + UPDATE="yes" + PATCH_PATH=`dirname "$1"` + PATCH_LIST=`basename "$1"` +else + if [ -d "$1/packages" ] + then + PACKAGE_PATH="$1/packages" + else + PACKAGE_PATH=$1 + fi + + # + # If the first parameter is a shell script (download installation set), the packages have to + # be unpacked into temp directory + # + if [ -f "$PACKAGE_PATH" ] + then + try_to_unpack_languagepack_file + fi + + # + # Create sed filter script for unwanted packages + # + + cat > /tmp/userinstall_filer.$$ << EOF +/SUNWadabas/d +/^SUNWj[0-9]/d +/-desktop-int/d +/-shared-mime-info/d +/-cde/d +EOF + + # Do not install gnome-integration package on systems without GNOME + pkginfo -q SUNWgnome-vfs + if [ $? -ne 0 ] + then + + echo '/-gnome/d' >> /tmp/userinstall_filer.$$ + fi + + # pkgdep sorts the packages based on their dependencies + PKGDEP="`dirname $0`/pkgdep" + if [ ! -x $PKGDEP ]; then + PKGDEP="get_pkg_list" + fi + + # + # Get the list of packages to install + # + + PKG_LIST=`$PKGDEP $PACKAGE_PATH | sed -f /tmp/userinstall_filer.$$` + rm -f /tmp/userinstall_filer.$$ + + if [ -z "$PKG_LIST" ] + then + printf "\n$0: No packages found in $PACKAGE_PATH\n" + exit 2 + fi + + echo "Packages found:" + for i in $PKG_LIST ; do + echo $i + done +fi + +INSTALL_ROOT=$2 +if [ "$UPDATE" = "yes" ] +then + if [ ! -d ${INSTALL_ROOT}/var/sadm/install/admin ] + then + printf "\n$0: No package database in ${INSTALL_ROOT}.\n" + exit 2 + fi +else + if [ "$ADD" = "no" ] + then + rmdir ${INSTALL_ROOT} 2>/dev/null + if [ -d ${INSTALL_ROOT} ] + then + printf "\n$0: ${INSTALL_ROOT} exists and is not empty.\n" + exit 2 + fi + fi + mkdir -p ${INSTALL_ROOT}/var/sadm/install/admin +fi + +# Previous versions of this script did not write this file +if [ ! -f ${INSTALL_ROOT}/var/sadm/install/admin/default ] +then + cat > ${INSTALL_ROOT}/var/sadm/install/admin/default << EOF +action=nocheck +conflict=nocheck +setuid=nocheck +idepend=nocheck +mail= +EOF +fi + +if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then + INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd` +fi + +# This script must exist to make extension registration work +# always overwrite to get the latest version. +mkdir -p ${INSTALL_ROOT}/usr/lib +cat > ${INSTALL_ROOT}/usr/lib/postrun << \EOF +#!/bin/sh +set -e + +# Override UserInstallation in bootstraprc for unopkg .. +UserInstallation='$BRAND_BASE_DIR/../UserInstallation' +export UserInstallation + +if [ -x /usr/bin/mktemp ] +then + CMD=`/usr/bin/mktemp /tmp/userinstall.XXXXXX` +else + CMD=/tmp/userinstall.$$; echo "" > $CMD +fi + +sed -e 's|/opt/|${PKG_INSTALL_ROOT}/opt/|g' > $CMD +/bin/sh -e $CMD +rm -f $CMD +EOF +chmod +x ${INSTALL_ROOT}/usr/lib/postrun 2>/dev/null + +# create local tmp directory to install on S10 +LOCAL_TMP= +if [ -x /usr/bin/mktemp ] +then + LOCAL_TMP=`mktemp -d` + rmdir ${INSTALL_ROOT}/tmp 2>/dev/null + ln -s ${LOCAL_TMP} ${INSTALL_ROOT}/tmp +fi + +# +# the tail of the script contains a shared object for overloading the getuid() +# and a few other calls +# + +GETUID_SO=/tmp/getuid.so.$$ +linenum=??? +tail +$linenum $0 > $GETUID_SO + +# +# Perform the installation +# +if [ "$UPDATE" = "yes" ] +then + # restore original "bootstraprc" prior to patching + for i in ${PKG_LIST}; do + my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR` + find "$my_dir" -type f -name bootstraprc.orig -exec sh -ce 'mv "$0" `dirname "$0"`/bootstraprc' {} \; + done + + # copy INST_RELEASE file + if [ ! -f ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE ] + then + mkdir -p ${INSTALL_ROOT}/var/sadm/system/admin 2>/dev/null + cp -f /var/sadm/system/admin/INST_RELEASE ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE + fi + + # The case UPDATE="yes" is valid for patch installation and for language packs. + # For patches the variable PKG_LIST is empty, for language packs it is not empty. + # Patches have to be installed with patchadd, language packs with pkgadd + + if [ -z "${PKG_LIST}" ] + then + LD_PRELOAD_32=$GETUID_SO /usr/sbin/patchadd -R ${INSTALL_ROOT} -M ${PATCH_PATH} ${PATCH_LIST} 2>&1 | grep -v '/var/sadm/patch' || pkg_error + else + LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error + fi + +else + + # Create BASEDIR directories to avoid manual user interaction + for i in ${PKG_LIST}; do + mkdir -m 0755 -p ${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} $i BASEDIR` 2>/dev/null + done + + if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then + INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd` + fi + + echo "####################################################################" + echo "# Installation of the found packages #" + echo "####################################################################" + echo + echo "Path to the packages : " $PACKAGE_PATH + echo "Path to the installation : " $INSTALL_ROOT + + LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error +fi + +rm -f $GETUID_SO +rm -f /tmp/.ai.pkg.zone.lock* + +# remove local tmp directory +if [ ! -z ${LOCAL_TMP} ] +then + rm -f ${LOCAL_TMP}/.ai.pkg.zone.lock* + rmdir ${LOCAL_TMP} + rm -f ${INSTALL_ROOT}/tmp + mkdir ${INSTALL_ROOT}/tmp +fi + +# +# Create a link into the users home directory +# + +if [ "$LINK" = "yes" ] +then + rm -f $HOME/soffice 2>/dev/null + find `cd "$INSTALL_ROOT" && pwd` -name soffice -type f -perm -u+x -exec /bin/sh -ce 'ln -sf "$0" "$HOME/soffice" && echo "Creating link from $0 to $HOME/soffice"' {} \; +fi + +# patch the "bootstraprc" to create a self-containing installation +for i in ${PKG_LIST}; do + my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR` + find "$my_dir" -type f -name bootstraprc -exec sh -ce 'test ! -f "$0".orig && mv "$0" "$0".orig && sed '\''s,^UserInstallation=$SYSUSERCONFIG.*,UserInstallation=$BRAND_BASE_DIR/../UserInstallation,'\'' "$0".orig > "$0"' {} \; +done + +# if an unpack directory exists, it can be removed now +if [ ! -z "$UNPACKDIR" ] +then + # for i in ${PKG_LIST}; do + # cd $UNPACKDIR; rm -rf $i + # done + # rmdir $UNPACKDIR + + rm -rf $UNPACKDIR + echo "Removed temporary directory $UNPACKDIR" +fi + +echo +echo "Installation done ..." +exit 0 + diff --git a/setup_native/scripts/javaloader.sh b/setup_native/scripts/javaloader.sh new file mode 100644 index 000000000000..e23505f586b0 --- /dev/null +++ b/setup_native/scripts/javaloader.sh @@ -0,0 +1,498 @@ +#!/bin/sh + +jarfilename="JavaSetup.jar" +tempdir=/var/tmp/install_$$ +java_runtime="java" +java_runtime_set="no" +java_runtime_found="no" +java_runtime_sufficient="no" +java_versions_supported="1.4 1.5 1.6" +rpm2cpio_found="no" +rpm_found="no" +sunjavahotspot="HotSpot" +errortext="" +errorcode="" + +start_java() +{ + umask 022 + + echo "Using $java_runtime" + echo `$java_runtime -version` + echo "Running installer" + + # looking for environment variables + + home="" + if [ "x" != "x$HOME" ]; then + home=-DHOME=$HOME + fi + + log_module_states="" + if [ "x" != "x$LOG_MODULE_STATES" ]; then + log_module_states=-DLOG_MODULE_STATES=$LOG_MODULE_STATES + fi + + getuid_path="" + if [ "x" != "x$GETUID_PATH" ]; then + getuid_path=-DGETUID_PATH=$GETUID_PATH + fi + + if [ "x" != "x$jrefile" ]; then + jrecopy=-DJRE_FILE=$jrefile + fi + + # run the installer class file + echo $java_runtime $home $log_module_states $getuid_path $jrecopy -jar $jarfilename + $java_runtime $home $log_module_states $getuid_path $jrecopy -jar $jarfilename +} + +cleanup() +{ + if [ "x$tempdir" != "x" -a -d "$tempdir" ]; then + rm -rf $tempdir + fi +} + +do_exit() +{ + exitstring=$errortext + if [ "x" != "x$errorcode" ]; then + exitstring="$exitstring (exit code $errorcode)" + fi + + # simply echo the exitstring or open a xterm + # -> dependent from tty + + if tty ; then + echo $exitstring + else + mkdir $tempdir + + # creating error file + errorfile=$tempdir/error + + cat > $errorfile << EOF +echo "$exitstring" +echo "Press return to continue ..." +read a +EOF + + chmod 755 $errorfile + + # searching for xterm in path + xtermname="xterm" + xtermfound="no"; + for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do + if [ -x "$i/$xtermname" -a ! -d "$i/$xtermname" ]; then + xtermname="$i/$xtermname" + xtermfound="yes" + break + fi + done + + if [ $xtermfound = "no" -a "`uname -s`" = "SunOS" ]; then + if [ -x /usr/openwin/bin/xterm ]; then + xtermname=/usr/openwin/bin/xterm + xtermfound="yes" + fi + fi + + if [ $xtermfound = "yes" ]; then + $xtermname -e $errorfile + fi + fi + + cleanup + + exit $errorcode +} + +set_jre_for_uninstall() +{ + # if "uninstalldata" exists, this is not required + if [ ! -d "uninstalldata" ]; then + packagepath="RPMS" + jrefile=`find $packagepath -type f -name "jre*.rpm" -print` + jrefile=`basename $jrefile` + if [ -z "$jrefile" ]; then + jrefile="notfound" + fi + + # check existence of jre rpm + if [ ! -f $packagepath/$jrefile ]; then + errortext="Error: Java Runtime Environment (JRE) not found in directory: $packagepath" + errorcode="4" + do_exit + fi + fi +} + +install_linux_rpm() +{ + # Linux requires usage of rpm2cpio to install JRE with user privileges + # 1. --relocate /usr/java=/var/tmp does not work, because not all files are + # relocatable. Some are always installed into /etc + # 2. --root only works with root privileges. With user privileges only the + # database is shifted, but not the files. + + # On Linux currently rpm2cpio is required (and rpm anyhow) + + find_rpm2cpio() + + if [ ! "$rpm2cpio_found" = "yes" ]; then + errortext="Error: Did not find rpm2cpio. rpm2cpio is currently required for installations on Linux." + errorcode="11" + do_exit + fi + + find_rpm() + + if [ ! "$rpm_found" = "yes" ]; then + errortext="Error: Did not find rpm. rpm is currently required for installations on Linux." + errorcode="12" + do_exit + fi + + # jrefile=jre-6-linux-i586.rpm + # javahome=usr/java/jre1.6.0 + + packagepath="RPMS" + + # using "uninstalldata" for uninstallation + if [ -d "uninstalldata" ]; then + packagepath="uninstalldata/jre" + fi + + jrefile=`find $packagepath -type f -name "jre*.rpm" -print` + jrefile=`basename $jrefile` + if [ -z "$jrefile" ]; then + jrefile="notfound" + fi + + # check existence of jre rpm + if [ ! -f $packagepath/$jrefile ]; then + errortext="Error: Java Runtime Environment (JRE) not found in directory: $packagepath" + errorcode="4" + do_exit + fi + + PACKED_JARS="lib/rt.jar lib/jsse.jar lib/charsets.jar lib/ext/localedata.jar lib/plugin.jar lib/javaws.jar lib/deploy.jar" + + mkdir $tempdir + + trap 'rm -rf $tempdir; exit 1' HUP INT QUIT TERM + + tempjrefile=$tempdir/$jrefile + cp $packagepath/$jrefile $tempjrefile + + if [ ! -f "$tempjrefile" ]; then + errortext="Error: Failed to copy Java Runtime Environment (JRE) temporarily." + errorcode="5" + do_exit + fi + + # check if copy was successful + if [ -x /usr/bin/sum ]; then + + echo "Checksumming..." + + sumA=`/usr/bin/sum $packagepath/$jrefile` + index=1 + for s in $sumA; do + case $index in + 1) + sumA1=$s; + index=2; + ;; + 2) + sumA2=$s; + index=3; + ;; + esac + done + + sumB=`/usr/bin/sum $tempjrefile` + index=1 + for s in $sumB; do + case $index in + 1) + sumB1=$s; + index=2; + ;; + 2) + sumB2=$s; + index=3; + ;; + esac + done + + # echo "Checksum 1: A1: $sumA1 B1: $sumB1" + # echo "Checksum 2: A2: $sumA2 B2: $sumB2" + + if [ $sumA1 -ne $sumB1 ] || [ $sumA2 -ne $sumB2 ]; then + errortext="Error: Failed to install Java Runtime Environment (JRE) temporarily." + errorcode="6" + do_exit + fi + else + echo "Can't find /usr/bin/sum to do checksum. Continuing anyway." + fi + + # start to install jre + echo "Extracting ..." + olddir=`pwd` + cd "$tempdir" + rpm2cpio $tempjrefile | cpio -i --make-directories + rm -f $tempjrefile # we do not need it anymore, so conserve discspace + + javahomeparent=usr/java + javahomedir=`find $javahomeparent -maxdepth 1 -type d -name "jre*" -print` + javahomedir=`basename $javahomedir` + if [ -z "$javahomedir" ]; then + javahomedir="notfound" + fi + + javahome=$javahomeparent/$javahomedir + + if [ ! -d ${javahome} ]; then + errortext="Error: Failed to extract the Java Runtime Environment (JRE) files." + errorcode="7" + do_exit + fi + + UNPACK_EXE=$javahome/bin/unpack200 + if [ -f $UNPACK_EXE ]; then + chmod +x $UNPACK_EXE + packerror="" + for i in $PACKED_JARS; do + if [ -f $javahome/`dirname $i`/`basename $i .jar`.pack ]; then + # printf "Creating %s\n" $javahome/$i + $UNPACK_EXE $javahome/`dirname $i`/`basename $i .jar`.pack $javahome/$i + if [ $? -ne 0 ] || [ ! -f $javahome/$i ]; then + printf "ERROR: Failed to unpack JAR file:\n\n\t%s\n\n" $i + printf "Installation failed. Please refer to the Troubleshooting Section of\n" + printf "the Installation Instructions on the download page.\n" + packerror="1" + break + fi + + # remove the old pack file + rm -f $javahome/`dirname $i`/`basename $i .jar`.pack + fi + done + if [ "$packerror" = "1" ]; then + if [ -d $javahome ]; then + /bin/rm -rf $javahome + fi + + errortext="Error: Failed to extract the Java Runtime Environment (JRE) files." + errorcode="8" + do_exit + fi + fi + + PREFS_LOCATION="`echo \"${javahome}\" | sed -e 's/^jdk.*/&\/jre/'`/.systemPrefs" + + if [ ! -d "${PREFS_LOCATION}" ]; then + mkdir -m 755 "${PREFS_LOCATION}" + fi + if [ ! -f "${PREFS_LOCATION}/.system.lock" ]; then + touch "${PREFS_LOCATION}/.system.lock" + chmod 644 "${PREFS_LOCATION}/.system.lock" + fi + if [ ! -f "${PREFS_LOCATION}/.systemRootModFile" ]; then + touch "${PREFS_LOCATION}/.systemRootModFile" + chmod 644 "${PREFS_LOCATION}/.systemRootModFile" + fi + + if [ x$ARCH = "x32" ] && [ -f "$javahome/bin/java" ]; then + "$javahome/bin/java" -client -Xshare:dump > /dev/null 2>&1 + fi + + java_runtime=$tempdir/$javahome/bin/java + + # Make symbolic links to all TrueType font files installed in the system + # to avoid garbles for Japanese, Korean or Chinese + language=`printenv LANG | cut -c 1-3` + if [ x$language = "xja_" -o x$language = "xko_" -o x$language = "xzh_" ]; then + font_fallback_dir=$javahome/lib/fonts/fallback + echo "Making symbolic links to TrueType font files into $font_fallback_dir." + mkdir -p $font_fallback_dir + ttf_files=`locate "*.ttf" | xargs` + if [ x$ttf_files = "x" ]; then + ttf_files=`find /usr/share/fonts/ -name "*ttf"` + if [ x$ttf_files = "x" ]; then + ttf_files=`find /usr/X11R6/lib/ -name "*ttf"` + fi + fi + ln -s $ttf_files $font_fallback_dir + fi + + echo "Done." + cd "$olddir" +} + +find_rpm2cpio() +{ + # searching for rpm2cpio in path + for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do + if [ -x "$i/rpm2cpio" -a ! -d "$i/$rpm2cpio" ]; then + rpm2cpio_found="yes" + break + fi + done +} + +find_rpm() +{ + # searching for rpm in path + for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do + if [ -x "$i/rpm" -a ! -d "$i/$rpm" ]; then + rpm_found="yes" + break + fi + done +} + +check_architecture() +{ + # Check, if system and installation set fit together (x86 and sparc). + # If not, throw a warning. + # Architecture of the installation set is saved in file "installdata/xpd/setup.xpd" + # <architecture>sparc</architecture> or <architecture>i386</architecture> + # Architecture of system is determined with "uname -p" + + setupxpdfile="installdata/xpd/setup.xpd" + + if [ -f $setupxpdfile ]; then + platform=`uname -p` # valid values are "sparc" or "i386" + searchstring="<architecture>$platform</architecture>" + match=`cat $setupxpdfile | grep $searchstring` + + if [ -z "$match" ]; then + # architecture does not fit, warning required + if [ "$platform" = "sparc" ]; then + echo "Warning: This is an attempt to install Solaris x86 packages on Solaris Sparc." + else + echo "Warning: This is an attempt to install Solaris Sparc packages on Solaris x86." + fi + fi + fi +} + +find_solaris_jre() +{ + # searching for java runtime in path + for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do + if [ -x "$i/$java_runtime" -a ! -d "$i/$java_runtime" ]; then + java_runtime="$i/$java_runtime" + java_runtime_found="yes" + break + fi + done +} + +check_jre_version() +{ + # check version of an installed JRE + javaoutput=`$java_runtime -version 2>&1 | tail ${tail_args} -1` + hotspot=`echo $javaoutput | grep $sunjavahotspot` + if [ ! -z "$hotspot" ]; then + for i in $java_versions_supported; do + versionmatch=`echo $javaoutput | grep $i` + if [ ! -z "$versionmatch" ]; then + java_runtime_sufficient="yes" + break + fi + done + + # check new version format, where version number is not part of line 3 (1.6) + if [ ! "$java_runtime_sufficient" = "yes" ]; then + javaoutput=`$java_runtime -version 2>&1 | head ${tail_args} -3` + for i in $java_versions_supported; do + versionmatch=`echo $javaoutput | grep $i` + if [ ! -z "$versionmatch" ]; then + java_runtime_sufficient="yes" + break + fi + done + fi + fi +} + +# the user might want to specify java runtime on the commandline +USAGE="Usage: $0 [ -j <java_runtime> ]" +while getopts hj: opt; do + echo "Parameter: $opt" + case $opt in + j) java_runtime_set="yes"; + java_runtime="${OPTARG}" + if [ ! -f "$java_runtime" ]; then + errortext="Error: Invalid java runtime $java_runtime, file does not exist." + errorcode="2" + do_exit + fi + if [ ! -x "$java_runtime" ]; then + errortext="Error: Invalid java runtime $java_runtime, not an executable file." + errorcode="3" + do_exit + fi + java_runtime_found="yes"; + ;; + h) echo ${USAGE} + errortext="" + errorcode="" + do_exit + ;; + \?) echo ${USAGE} + errortext="" + errorcode="" + do_exit + ;; + esac +done + +# changing into setup directory +cd "`dirname "$0"`" + +# prepare jre, if not set on command line +if [ "$java_runtime_set" != "yes" ]; then + platform=`uname -s` + if [ "`uname -s`" = "Linux" ]; then + install_linux_rpm + elif [ "`uname -s`" = "SunOS" ]; then + check_architecture + find_solaris_jre + if [ "$java_runtime_found" = "yes" ]; then + check_jre_version + if [ ! "$java_runtime_sufficient" = "yes" ]; then + errortext="Error: Did not find a valid Java Runtime Environment (JRE). Required JRE versions: $java_versions_supported" + errorcode="9" + do_exit + fi + else + errortext="Error: Did not find an installed Java Runtime Environment (JRE)." + errorcode="10" + do_exit + fi + else + errortext="Error: Platform $platform not supported for Java Runtime Environment (JRE) installation." + errorcode="1" + do_exit + fi +fi + +# jre for Linux is also required, if java runtime is set (for uninstallation mode) +if [ "$java_runtime_set" = "yes" ]; then + platform=`uname -s` + if [ "`uname -s`" = "Linux" ]; then + set_jre_for_uninstall + fi +fi + +start_java + +cleanup + +exit 0 diff --git a/setup_native/scripts/langpackscript.sh b/setup_native/scripts/langpackscript.sh new file mode 100644 index 000000000000..bf221909ebf4 --- /dev/null +++ b/setup_native/scripts/langpackscript.sh @@ -0,0 +1,153 @@ +#!/bin/sh + +MYUID=`id | sed "s/(.*//g" | sed "s/.*=//"` + +if [ $MYUID -ne 0 ] +then + echo You need to have super-user rights to install this language package + exit 1 +fi + +linenum=LINENUMBERPLACEHOLDER + +# Determining current platform + +platform=`uname -s` + +case $platform in +SunOS) + tail_prog="tail" + ;; +Linux) + tail_prog="tail -n" + ;; +*) + tail_prog="tail" + ;; +esac + +more << "EOF" +LICENSEFILEPLACEHOLDER +EOF + +agreed= +while [ x$agreed = x ]; do + echo + echo "Do you agree to the above license terms? [yes or no] " + read reply leftover + case $reply in + y* | Y*) + agreed=1;; + n* | N*) + echo "If you don't agree to the license you can't install this software"; + exit 1;; + esac +done + +case $platform in +SunOS) + SEARCHPACKAGENAME="BASISPACKAGEPREFIXPLACEHOLDEROOOBASEVERSIONPLACEHOLDER-core01" + echo + echo "Searching for the FULLPRODUCTNAMELONGPLACEHOLDER installation ..." + PACKAGENAME=`pkginfo -x | grep $SEARCHPACKAGENAME | sed "s/ .*//"` + if [ "x$PACKAGENAME" != "x" ] + then + PRODUCTINSTALLLOCATION="`pkginfo -r $PACKAGENAME`" + else + echo "FULLPRODUCTNAMELONGPLACEHOLDER not installed (no package $SEARCHPACKAGENAME installed)" + exit 1 + fi + ;; +Linux) + SEARCHPACKAGENAME="BASISPACKAGEPREFIXPLACEHOLDEROOOBASEVERSIONPLACEHOLDER-core01" + FIXPATH="/openoffice.org" + echo + echo "Searching for the FULLPRODUCTNAMELONGPLACEHOLDER installation ..." + RPMNAME=`rpm -qa | grep $SEARCHPACKAGENAME` + if [ "x$RPMNAME" != "x" ] + then + PRODUCTINSTALLLOCATION="`rpm -ql $RPMNAME | head -n 1`" + else + echo "FULLPRODUCTNAMELONGPLACEHOLDER not installed (no package $SEARCHPACKAGENAME installed)" + exit 1 + fi + PRODUCTINSTALLLOCATION=`echo $PRODUCTINSTALLLOCATION | sed "s#${FIXPATH}##"` + ;; +*) + echo "Unsupported platform" + exit 1 + ;; +esac + +# Asking for the installation directory + +# echo +# echo "Where do you want to install the language pack ? [$PRODUCTINSTALLLOCATION] " +# read reply leftover +# if [ "x$reply" != "x" ] +# then +# PRODUCTINSTALLLOCATION="$reply" +# fi + +# Unpacking + +outdir=/var/tmp/install_$$ +mkdir $outdir + +#diskSpace=`df -k $outdir | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'` +#if [ $diskSpace -lt $diskSpaceRequired ]; then +# printf "You will need atleast %s kBytes of Disk Free\n" $diskSpaceRequired +# printf "Please free up the required Disk Space and try again\n" +# exit 3 +#fi + +trap 'rm -rf $outdir; exit 1' HUP INT QUIT TERM +echo "Unpacking and installing..." + +#if [ -x /usr/bin/sum ] ; then +# echo "Checksumming..." +# +# sum=`/usr/bin/sum $outdir/$outname` +# index=1 +# for s in $sum +# do +# case $index in +# 1) sum1=$s; +# index=2; +# ;; +# 2) sum2=$s; +# index=3; +# ;; +# esac +# done +# if expr $sum1 != <sum1replace> || expr $sum2 != <sum2replace> ; then +# echo "The download file appears to be corrupted. Please refer" +# echo "to the Troubleshooting section of the Installation" +# exit 1 +# fi +#else +# echo "Can't find /usr/bin/sum to do checksum. Continuing anyway." +#fi + +case $platform in +SunOS) + $tail_prog +$linenum $0 | gunzip | (cd $outdir; tar xvf -) + adminfile=$outdir/admin.$$ + echo "basedir=$PRODUCTINSTALLLOCATION" > $adminfile +INSTALLLINES + ;; +Linux) + $tail_prog +$linenum $0 | gunzip | (cd $outdir; tar xvf -) +INSTALLLINES + ;; +*) + echo "Unsupported platform" + exit 1 + ;; +esac + +rm -rf $outdir + +echo "Done..." + +exit 0 diff --git a/setup_native/scripts/linuxpatchscript.sh b/setup_native/scripts/linuxpatchscript.sh new file mode 100644 index 000000000000..33a0d4127301 --- /dev/null +++ b/setup_native/scripts/linuxpatchscript.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +MYUID=`id | sed "s/(.*//g" | sed "s/.*=//"` + +if [ $MYUID -ne 0 ] +then + echo You need to have super-user permissions to run this patch script + exit 1 +fi + +echo +echo "Searching for the PRODUCTNAMEPLACEHOLDER installation ..." + +RPMNAME=`rpm -qa | grep SEARCHPACKAGENAMEPLACEHOLDER` + +if [ "x$RPMNAME" != "x" ] +then + PRODUCTINSTALLLOCATION="`rpm --query --queryformat "%{INSTALLPREFIX}" $RPMNAME`" + FULLPRODUCTINSTALLLOCATION="${PRODUCTINSTALLLOCATION}/PRODUCTDIRECTORYNAME" +else + echo "PRODUCTNAMEPLACEHOLDER is not installed" + exit 1 +fi + +# Last chance to exit .. +echo +read -p "Patching the installation in ${FULLPRODUCTINSTALLLOCATION}. Continue (y/n) ? " -n 1 reply leftover +echo +[ "$reply" == "y" ] || exit 1 + +echo +echo "About to update the following packages ..." + +BASEDIR=`dirname $0` + +RPMLIST="" +for i in `ls $BASEDIR/RPMS/*.rpm` +do + rpm --query `rpm --query --queryformat "%{NAME}\n" --package $i` && RPMLIST="$RPMLIST $i" +done + +# Save UserInstallation value +BOOTSTRAPRC="${FULLPRODUCTINSTALLLOCATION}/program/bootstraprc" +USERINST=`grep UserInstallation ${BOOTSTRAPRC}` + +# Check, if kde-integration rpm is available +KDERPM=`ls $BASEDIR/RPMS/*.rpm | grep kde-integration` + +if [ "x$KDERPM" != "x" ]; then + # Check, that $RPMLIST does not contain kde integration rpm (then it is already installed) + KDERPMINSTALLED=`grep kde-integration ${RPMLIST}` + + if [ "x$KDERPMINSTALLED" == "x" ]; then + # Install the kde integration rpm + RPMLIST="$RPMLIST $KDERPM" + fi +fi + +echo +rpm --upgrade -v --hash --prefix $PRODUCTINSTALLLOCATION --notriggers $RPMLIST +echo + +# Some RPM versions have problems with -U and --prefix +if [ ! -f ${BOOTSTRAPRC} ]; then + echo Update failed due to a bug in RPM, uninstalling .. + rpm --erase -v --nodeps --notriggers `rpm --query --queryformat "%{NAME} " --package $RPMLIST` + echo + echo Now re-installing new packages .. + echo + rpm --install -v --hash --prefix $PRODUCTINSTALLLOCATION --notriggers $RPMLIST + echo +fi + +# Restore the UserInstallation key if necessary +DEFUSERINST=`grep UserInstallation ${BOOTSTRAPRC}` +if [ "${USERINST}" != "${DEFUSERINST}" ]; then + mv -f ${BOOTSTRAPRC} ${BOOTSTRAPRC}.$$ + sed "s|UserInstallation.*|${USERINST}|" ${BOOTSTRAPRC}.$$ > ${BOOTSTRAPRC} + rm -f ${BOOTSTRAPRC}.$$ +fi + +echo "Done." + +exit 0 diff --git a/setup_native/scripts/mac_install.script b/setup_native/scripts/mac_install.script new file mode 100644 index 000000000000..2b34da1b04ed --- /dev/null +++ b/setup_native/scripts/mac_install.script @@ -0,0 +1,10 @@ +#!/bin/bash + +# shell script as a workaraound since it is hard to impossible to store compiled +# applescript in CVS and running osacompile would require a GUI session while +# building (or root privileges) +# using osascript only works when the shell script is camouflaged as application + +MY_DIR=$(dirname "$0") + +osascript "$MY_DIR/osx_install.applescript" diff --git a/setup_native/scripts/makefile.mk b/setup_native/scripts/makefile.mk new file mode 100644 index 000000000000..de91bd011efe --- /dev/null +++ b/setup_native/scripts/makefile.mk @@ -0,0 +1,103 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=.. + +PRJNAME=setup_native +TARGET=install + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" +# --- Files -------------------------------------------------------- + +UNIXTEXT= \ + $(BIN)$/langpackscript.sh \ + $(BIN)$/linuxpatchscript.sh \ + $(BIN)$/javaloader.sh \ + $(BIN)$/register_extensions \ + $(BIN)$/deregister_extensions \ + $(BIN)$/unpack_update.sh \ + $(BIN)$/update.sh \ + $(BIN)$/downloadscript.sh + +.IF "$(OS)" == "SOLARIS" || "$(OS)" == "LINUX" +UNIXTEXT+= $(BIN)$/stclient_wrapper.sh +.ENDIF + +NOARCH=$(BIN)$/noarch +FAKEDB=$(NOARCH)/fake-db-1.0-0.noarch.rpm +FAKEDBROOT=$(COMMONMISC)/$(TARGET)/fake-db-root + +# --- Targets ------------------------------------------------------ + +.ENDIF # L10N_framework +.INCLUDE : target.mk +.IF "$(L10N_framework)"=="" +.IF "$(OS)" == "SOLARIS" || ( "$(OS)" == "LINUX" && "$(PKGFORMAT)"!="$(PKGFORMAT:s/rpm//)" ) + +ALLTAR: $(BIN)$/install $(BIN)$/uninstall + +$(BIN)$/install: install_$(OS:l).sh + $(PERL) install_create.pl $& $@ + -chmod 775 $@ + +.ENDIF + +.IF "$(OS)" == "LINUX" +.IF "$(PKGFORMAT)"!="$(PKGFORMAT:s/rpm//)" + +$(FAKEDB) : fake-db.spec + $(MKDIRHIER) $(FAKEDBROOT) + $(RPM) --define "_builddir $(shell @cd $(FAKEDBROOT) && pwd)" --define "_rpmdir $(shell @cd $(BIN) && pwd)" -bb $< + chmod g+w $(NOARCH) + +$(BIN)$/install: $(FAKEDB) +.ENDIF # "$(PKGFORMAT)"!="$(PKGFORMAT:s/rpm//)" + +$(BIN)$/uninstall: uninstall_linux.sh + $(TYPE) $< | tr -d "\015" > $@ + -chmod 775 $@ + +.ENDIF # "$(OS)" == "LINUX" + +.IF "$(OS)" == "SOLARIS" + +$(BIN)$/install: $(LB)$/getuid.so.stripped + +$(BIN)$/uninstall: uninstall_solaris.sh $(LB)$/getuid.so.stripped + $(PERL) install_create.pl $< $@ + -chmod 775 $@ + +$(LB)$/getuid.so.stripped: $(LB)$/getuid.so + @$(COPY) $< $@ + @/usr/ccs/bin/strip $@ + +.ENDIF + +.ENDIF # L10N_framework diff --git a/setup_native/scripts/osx_install_languagepack.applescript b/setup_native/scripts/osx_install_languagepack.applescript new file mode 100644 index 000000000000..68c31b709412 --- /dev/null +++ b/setup_native/scripts/osx_install_languagepack.applescript @@ -0,0 +1,141 @@ +(* +This script is meant to + 1) Identify installed instances of the product + 2) check whether the user has write-access (and if not + ask for authentification) + 3) install the shipped tarball +*) + +-- strings for localisations - to be meant to be replaced +-- by a makefile or similar +set OKLabel to "[OKLabel]" +set InstallLabel to "[InstallLabel]" +set AbortLabel to "[AbortLabel]" +set intro to "[IntroText1] + +[IntroText2] + +[IntroText3]" +set chooseMyOwn to "[ChooseMyOwnText]" +set listPrompt to "[ListPromptText]" +set chooseManual to "[ChooseManualText]" +set listOKLabel to "[ListOKLabelText]" +set listCancelLabel to "[ListCancelLabel]" +set appInvalid to "[AppInvalidText1] + +[AppInvalidText2]" -- string will begin with the chosen application's name +set startInstall to "[StartInstallText1] + +[StartInstallText2]" +set IdentifyQ to "[IdentifyQText] + +[IdentifyQText2]" +set IdentifyYES to "[IdentifyYES]" +set IdentifyNO to "[IdentifyNO]" +set installFailed to "[InstallFailedText]" +set installComplete to "[InstallCompleteText] + +[InstallCompleteText2]" + +set sourcedir to (do shell script "dirname " & quoted form of POSIX path of (path to of me)) + +display dialog intro buttons {AbortLabel, InstallLabel} default button 2 + +if (button returned of result) is AbortLabel then + return 2 +end if + +set the found_ooos_all to (do shell script "mdfind \"kMDItemContentType == 'com.apple.application-bundle' && kMDItemDisplayName == '[PRODUCTNAME]*' && kMDItemDisplayName != '[FULLAPPPRODUCTNAME].app'\"") & " +" & chooseMyOwn + +set found_ooos_all_paragraphs to paragraphs in found_ooos_all + +set found_ooos to {} +repeat with currentApp in found_ooos_all_paragraphs + if currentApp does not start with "/Volumes" then + copy currentApp to the end of found_ooos + end if +end repeat + +-- repeat with oneApp in found_ooos +-- display dialog oneApp +-- end repeat + +-- the choice returned is of type "list" +-- Show selection dialog only if more than one or no product was found +-- The first item is an empty string, if no app was found and no app started with "/Volumes" +-- The first item is chooseMyOwn, if no app was found and at least one app started with "/Volumes" +if (get first item of found_ooos as string) is "" then + set the choice to (choose from list found_ooos default items (get second item of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel) + if choice is false then + -- do nothing, the user cancelled the installation + return 2 --aborted by user + else if (choice as string) is chooseMyOwn then + -- yeah, one needs to use "choose file", otherwise + -- the user would not be able to select the .app + set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) + end if +else if (get first item of found_ooos as string) is chooseMyOwn then + set the choice to (choose from list found_ooos default items (get first item of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel) + if choice is false then + -- do nothing, the user cancelled the installation + return 2 --aborted by user + else if (choice as string) is chooseMyOwn then + -- yeah, one needs to use "choose file", otherwise + -- the user would not be able to select the .app + set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) + end if +else if (get second item of found_ooos as string) is chooseMyOwn then + -- set choice to found installation + -- set the choice to (get first paragraph of found_ooos) + set the choice to (get first item of found_ooos) +else + set the choice to (choose from list found_ooos default items (get first item of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel) + if choice is false then + -- do nothing, the user cancelled the installation + return 2 --aborted by user + else if (choice as string) is chooseMyOwn then + -- yeah, one needs to use "choose file", otherwise + -- the user would not be able to select the .app + set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) + end if +end if + +-- now only check whether the path is really from [PRODUCTNAME] +try + do shell script "grep '<string>[PRODUCTNAME] [PRODUCTVERSION]' " & quoted form of (choice as string) & "/Contents/Info.plist" +on error + display dialog (choice as string) & appInvalid buttons {InstallLabel} default button 1 with icon 0 + return 3 --wrong target-directory +end try + +(* +display dialog startInstall buttons {AbortLabel, InstallLabel} default button 2 + +if (button returned of result) is AbortLabel then + return 2 +end if +*) + +set tarCommand to "/usr/bin/tar -C " & quoted form of (choice as string) & " -xjf " & quoted form of sourcedir & "/tarball.tar.bz2" +try + do shell script tarCommand + +on error errMSG number errNUM + display dialog IdentifyQ buttons {IdentifyYES, IdentifyNO} with icon 2 + if (button returned of result) is IdentifyYES then + try + do shell script tarCommand with administrator privileges + on error errMSG number errNUM + display dialog installFailed buttons {OKLabel} default button 1 with icon 0 + -- -60005 username/password wrong + -- -128 aborted by user + -- 2 error from tar - tarball not found (easy to test) + return errNUM + end try + else + return 2 -- aborted by user + end if +end try + +display dialog installComplete buttons {OKLabel} default button 1 diff --git a/setup_native/scripts/osx_install_patch.applescript b/setup_native/scripts/osx_install_patch.applescript new file mode 100644 index 000000000000..fc12f20108a6 --- /dev/null +++ b/setup_native/scripts/osx_install_patch.applescript @@ -0,0 +1,139 @@ +(* +This script is meant to + 1) Identify installed instances of the product + 2) check whether the user has write-access (and if not + ask for authentification) + 3) install the shipped tarball +*) + +-- strings for localisations - to be meant to be replaced +-- by a makefile or similar +set OKLabel to "[OKLabel]" +set InstallLabel to "[InstallLabel]" +set AbortLabel to "[AbortLabel]" +set intro to "[IntroText1] + +[IntroText2] + +[IntroText3]" +set chooseMyOwn to "[ChooseMyOwnText]" +set listPrompt to "[ListPromptText]" +set chooseManual to "[ChooseManualText]" +set listOKLabel to "[ListOKLabelText]" +set listCancelLabel to "[ListCancelLabel]" +set appInvalid to "[AppInvalidText1] + +[AppInvalidText2]" -- string will begin with the chosen application's name +set startInstall to "[StartInstallText1] + +[StartInstallText2]" +set IdentifyQ to "[IdentifyQText] + +[IdentifyQText2]" +set IdentifyYES to "[IdentifyYES]" +set IdentifyNO to "[IdentifyNO]" +set installFailed to "[InstallFailedText]" +set installComplete to "[InstallCompleteTextPatch]" + +set sourcedir to (do shell script "dirname " & quoted form of POSIX path of (path to of me)) + +display dialog intro buttons {AbortLabel, InstallLabel} default button 2 + +if (button returned of result) is AbortLabel then + return 2 +end if + +set the found_ooos_all to (do shell script "mdfind \"kMDItemContentType == 'com.apple.application-bundle' && kMDItemDisplayName == '[PRODUCTNAME]*' && kMDItemDisplayName != '[FULLAPPPRODUCTNAME].app'\"") & " +" & chooseMyOwn + +set found_ooos_all_paragraphs to paragraphs in found_ooos_all + +set found_ooos to {} +repeat with currentApp in found_ooos_all_paragraphs + if currentApp does not start with "/Volumes" then + copy currentApp to the end of found_ooos + end if +end repeat + +-- repeat with oneApp in found_ooos +-- display dialog oneApp +-- end repeat + +-- the choice returned is of type "list" +-- Show selection dialog only if more than one or no product was found +-- The first item is an empty string, if no app was found and no app started with "/Volumes" +-- The first item is chooseMyOwn, if no app was found and at least one app started with "/Volumes" +if (get first item of found_ooos as string) is "" then + set the choice to (choose from list found_ooos default items (get second item of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel) + if choice is false then + -- do nothing, the user cancelled the installation + return 2 --aborted by user + else if (choice as string) is chooseMyOwn then + -- yeah, one needs to use "choose file", otherwise + -- the user would not be able to select the .app + set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) + end if +else if (get first item of found_ooos as string) is chooseMyOwn then + set the choice to (choose from list found_ooos default items (get first item of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel) + if choice is false then + -- do nothing, the user cancelled the installation + return 2 --aborted by user + else if (choice as string) is chooseMyOwn then + -- yeah, one needs to use "choose file", otherwise + -- the user would not be able to select the .app + set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) + end if +else if (get second item of found_ooos as string) is chooseMyOwn then + -- set choice to found installation + -- set the choice to (get first paragraph of found_ooos) + set the choice to (get first item of found_ooos) +else + set the choice to (choose from list found_ooos default items (get first item of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel) + if choice is false then + -- do nothing, the user cancelled the installation + return 2 --aborted by user + else if (choice as string) is chooseMyOwn then + -- yeah, one needs to use "choose file", otherwise + -- the user would not be able to select the .app + set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) + end if +end if + +-- now only check whether the path is really from [PRODUCTNAME] +try + do shell script "grep '<string>[PRODUCTNAME] [PRODUCTVERSION]' " & quoted form of (choice as string) & "/Contents/Info.plist" +on error + display dialog (choice as string) & appInvalid buttons {InstallLabel} default button 1 with icon 0 + return 3 --wrong target-directory +end try + +(* +display dialog startInstall buttons {AbortLabel, InstallLabel} default button 2 + +if (button returned of result) is AbortLabel then + return 2 +end if +*) + +set tarCommand to "/usr/bin/tar -C " & quoted form of (choice as string) & " -xjf " & quoted form of sourcedir & "/tarball.tar.bz2" +try + do shell script tarCommand + +on error errMSG number errNUM + display dialog IdentifyQ buttons {IdentifyYES, IdentifyNO} with icon 2 + if (button returned of result) is IdentifyYES then + try + do shell script tarCommand with administrator privileges + on error errMSG number errNUM + display dialog installFailed buttons {OKLabel} default button 1 with icon 0 + -- -60005 username/password wrong + -- -128 aborted by user + -- 2 error from tar - tarball not found (easy to test) + return errNUM + end try + else + return 2 -- aborted by user + end if +end try + +display dialog installComplete buttons {OKLabel} default button 1 diff --git a/setup_native/scripts/register_extensions b/setup_native/scripts/register_extensions new file mode 100644 index 000000000000..034642175c29 --- /dev/null +++ b/setup_native/scripts/register_extensions @@ -0,0 +1,84 @@ +#!/bin/bash + +USAGE="Usage: $0" + +SCRIPTNAME=`basename "$0"` +PROGRAMDIR=`dirname "$0"` +OFFICEDIR="$PROGRAMDIR/.." +EXTENSIONDIR=$OFFICEDIR/share/extension/install +REGISTERFILE=$PROGRAMDIR/register.dat +UNOPKG=$PROGRAMDIR/unopkg + +help() +{ + echo + echo "Installation script for office extensions located in <office>/share/extension/install" + echo + echo "This installation script can be executed after successful installation of packages." + echo "Before uninstallation please execute the script \"deregister_extensions\" located next" + echo "to this script." + echo "Usage: $0" + echo "No parameter required." + echo +} + +# +# This script is only for root installations +# (How about installations done with user privileges?) +# + +# if [ $UID -ne 0 ] +# then +# printf "\nThis script is for installation only wiht administrative rights only\n" +# help +# exit 2 +# fi + +# +# Checking existence of unopkg in program directory +# + +if [ ! -f "$UNOPKG" ]; then + echo "Error: File $UNOPKG does not exist" + exit 1 +fi + +if [ ! -x "$UNOPKG" ]; then + echo "Error: File $UNOPKG is not an executable file" + exit 1 +fi + +# +# Collecting all files located in share/install/extensions +# + +FILELIST=`find $EXTENSIONDIR -type f -name "*.oxt" -print` + +if [ -z "$FILELIST" ] +then + printf "\n$0: No extensions found in $EXTENSIONDIR\n" + exit 2 +fi + +echo +echo "Installing:" +for i in $FILELIST; do + echo `basename $i` +done +echo + +for i in $FILELIST; do + COMMAND="$UNOPKG add --shared --suppress-license $i" + echo $COMMAND + $COMMAND +done + +if [ -f $REGISTERFILE ]; then + rm $REGISTERFILE +fi + +echo +echo "Installation done ..." +echo + +exit 0 diff --git a/setup_native/scripts/source/getuid.c b/setup_native/scripts/source/getuid.c new file mode 100644 index 000000000000..9af63f4f079d --- /dev/null +++ b/setup_native/scripts/source/getuid.c @@ -0,0 +1,135 @@ +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <dlfcn.h> + +#ifdef _cplusplus +extern "C" { +#endif + +#ifdef SOLARIS + +#include <sys/systeminfo.h> +#include <strings.h> + +int chown (const char *path, uid_t owner, gid_t group) {return 0;} +int lchown (const char *path, uid_t owner, gid_t group) {return 0;} +int fchown (int fildes, uid_t owner, gid_t group) {return 0;} + +uid_t getuid (void) {return 0;} +int stat(const char *path, struct stat *buf); +#ifdef __notdef__ +uid_t geteuid (void) {return 0;} +gid_t getgid (void) {return 0;} +gid_t getegid (void) {return 0;} +#endif + +int setuid (uid_t p) {return 0;} +int setgid (gid_t p) {return 0;} + +/* This is to fool cpio and pkgmk */ +int fstat(int fildes, struct stat *buf) +{ + int ret = 0; + static int (*p_fstat) (int fildes, struct stat *buf) = NULL; + if (p_fstat == NULL) + p_fstat = (int (*)(int fildes, struct stat *buf)) + dlsym (RTLD_NEXT, "fstat"); + ret = (*p_fstat)(fildes, buf); + if (buf != NULL) + { + buf->st_uid = 0; /* root */ + buf->st_gid = 2; /* bin */ + } + + return ret; +} + +/* this is to fool mkdir, don't allow to remove owner execute right from directories */ +int chmod(const char *path, mode_t mode) +{ + int ret = 0; + static int (*p_chmod) (const char *path, mode_t mode) = NULL; + if (p_chmod == NULL) + p_chmod = (int (*)(const char *path, mode_t mode)) + dlsym (RTLD_NEXT, "chmod"); + + if ((mode & S_IXUSR) == 0) + { + struct stat statbuf; + if (stat(path, &statbuf) == 0) + { + if ((statbuf.st_mode & S_IFDIR) != 0) + mode = (mode | S_IXUSR); + } + } + + ret = (*p_chmod)(path, mode); + return ret; +} + + + +/* This is to fool tar */ +int fstatat64(int fildes, const char *path, struct stat64 *buf, int flag) +{ + int ret = 0; + static int (*p_fstatat) (int fildes, const char *path, struct stat64 *buf, int flag) = NULL; + if (p_fstatat == NULL) + p_fstatat = (int (*)(int fildes, const char *path, struct stat64 *buf, int flag)) + dlsym (RTLD_NEXT, "fstatat64"); + ret = (*p_fstatat)(fildes, path, buf, flag); + if (buf != NULL) + { + buf->st_uid = 0; /* root */ + buf->st_gid = 2; /* bin */ + } + + return ret; +} +#elif defined LINUX + +uid_t getuid (void) {return 0;} +uid_t geteuid (void) {return 0;} + +/* This is to fool tar */ +#ifdef X86_64 +int __lxstat(int n, const char *path, struct stat *buf) +{ + int ret = 0; + static int (*p_lstat) (int n, const char *path, struct stat *buf) = NULL; + if (p_lstat == NULL) + p_lstat = (int (*)(int n, const char *path, struct stat *buf)) + dlsym (RTLD_NEXT, "__lxstat"); + ret = (*p_lstat)(n, path, buf); + if (buf != NULL) + { + buf->st_uid = 0; /* root */ + buf->st_gid = 0; /* root */ + } + return ret; +} +#else +int __lxstat64(int n, const char *path, struct stat64 *buf) +{ + int ret = 0; + static int (*p_lstat) (int n, const char *path, struct stat64 *buf) = NULL; + if (p_lstat == NULL) + p_lstat = (int (*)(int n, const char *path, struct stat64 *buf)) + dlsym (RTLD_NEXT, "__lxstat64"); + ret = (*p_lstat)(n, path, buf); + if (buf != NULL) + { + buf->st_uid = 0; + buf->st_gid = 0; + } + return ret; +} +#endif +#endif + +#ifdef _cplusplus +} +#endif + diff --git a/setup_native/scripts/source/makefile.mk b/setup_native/scripts/source/makefile.mk new file mode 100644 index 000000000000..6933f53d6149 --- /dev/null +++ b/setup_native/scripts/source/makefile.mk @@ -0,0 +1,90 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=setup_native +TARGET=getuid + +NO_DEFAULT_STL=TRUE +LIBSALCPPRT=$(0) +LIBTARGET=NO + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +# no 'lib' prefix +DLLPRE= + +# no _version.o +VERSIONOBJ= + +.IF "$(OS)" == "LINUX" || "$(OS)" == "SOLARIS" + +.IF "$(OS)" == "LINUX" +CFLAGS+=-D_GNU_SOURCE +.ENDIF + +.IF "$(OS)" == "SOLARIS" +.IF "$(CPU)" == "I" +.IF "$(COM)" != "GCC" +CFLAGS+=-D_KERNEL +.ENDIF +.ENDIF +.ENDIF + +# this object must not be a Ultra SPARC binary, this does not +# work with /usr/bin/sort and such. Needs to be 32 bit even in +# 64 bit builds +.IF "$(OS)" == "SOLARIS" +.IF "$(COM)" != "GCC" +.IF "$(CPU)" == "S" +ENVCFLAGS=-xarch=v8 +.ENDIF +.IF "$(CPU)"=="U" +CFLAGSAPPEND+=-m32 +LINKFLAGSSHL+=-m32 +.ENDIF +.ENDIF +.ENDIF + +SLOFILES = $(SLO)$/getuid.obj + +SHL1OBJS=$(SLOFILES) +SHL1TARGET=$(TARGET) +SHL1STDLIBS=-ldl +SHL1CODETYPE=C + +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/setup_native/scripts/stclient_wrapper.sh b/setup_native/scripts/stclient_wrapper.sh new file mode 100644 index 000000000000..52ff8abcb0ee --- /dev/null +++ b/setup_native/scripts/stclient_wrapper.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# All rights reserved. +# + +if [ `uname -s` = "SunOS" ]; then + STCLIENT=/usr/bin/stclient +else + STCLIENT=/opt/sun/servicetag/bin/stclient +fi + +TARGET_URN= +PRODUCT_NAME= +PRODUCT_VERSION= +PRODUCT_SOURCE= +PARENT_PRODUCT_NAME= +INSTANCE_URN= + +while [ $# -gt 0 ] +do + case "$1" in + -t) TARGET_URN="$2"; shift;; + -p) PRODUCT_NAME="$2"; shift;; + -e) PRODUCT_VERSION="$2"; shift;; + -i) INSTANCE_URN="$2"; shift;; + -P) PARENT_PRODUCT_NAME="$2"; shift;; + -S) PRODUCT_SOURCE="$2"; shift;; + --) shift; break;; + -*) + echo >&2 \ + "usage: $0 -p <product name> -e <product version> -t <urn> -S <source> -P <parent product name> [-i <instance urn>]" + exit 1;; + *) break;; + esac + shift +done + +[ -x "$STCLIENT" ] || exit 1 + +# test if already registered +if [ ! -n $INSTANCE_URN ]; then + TEST=`${STCLIENT} -f -t ${TARGET_URN}`; EXITCODE=$? + + # retry on unexpected error codes + [ ${EXITCODE} -eq 0 -o ${EXITCODE} -eq 225 ] || exit 1 + + # early versions did not have a dedicated exitcode, so need to compare text output + [ ${EXITCODE} -eq 225 -o "${TEST}" = "No records found" ] || echo "${TEST}"; exit 0 +fi + +uname=`uname -p` +zone="global" + +if [ `uname -s` = "SunOS" ]; then + if [ -x /usr/bin/zonename ]; then + zone=`/usr/bin/zonename` + fi +fi + +output=`"${STCLIENT}" -a -p "${PRODUCT_NAME}" -e "${PRODUCT_VERSION}" -t ${TARGET_URN} -S "${PRODUCT_SOURCE}" -P "${PARENT_PRODUCT_NAME}" ${INSTANCE_URN:+"-i"} ${INSTANCE_URN} -m "Sun Microsystems, Inc." -A "${uname}" -z "${zone}"`; EXITCODE=$? + +[ "${INSTANCE_URN}" = "" -a ${EXITCODE} -eq 226 ] && exit 0 + +exit ${EXITCODE} + diff --git a/setup_native/scripts/uninstall_linux.sh b/setup_native/scripts/uninstall_linux.sh new file mode 100644 index 000000000000..9ec68855c927 --- /dev/null +++ b/setup_native/scripts/uninstall_linux.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Linux deinstallation +# No parameter required, all RPMs listed in $HOME/.RPM_OFFICEDATABASE +# will be removed. + +if [ $# -ne 1 ] +then + echo + echo "Usage:" $0 "<office-installation-dir>" + echo " <inst-destination-dir>: directory where the office to be removed is installed" + echo + exit 2 +fi + +INSTALLDIR=$1 + +# Check for old style .RPM_OFFICEDATABASE first +if [ -d ${INSTALLDIR}/.RPM_OFFICEDATABASE ]; then + RPM_DB_PATH=${INSTALLDIR}/.RPM_OFFICEDATABASE +else + RPM_DB_PATH=${INSTALLDIR}/.RPM_DATABASE +fi + +# the RPM_DB_PATH must be absolute +if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then + RPM_DB_PATH=`cd ${RPM_DB_PATH}; pwd` +fi + +RPMLIST=`rpm --dbpath $RPM_DB_PATH --query --all` + +# Output ... +clear +echo "#########################################" +echo "# Deinstallation of Office RPMs #" +echo "#########################################" +echo +echo "Path to the RPM database: " $RPM_DB_PATH +echo "RPMs to deinstall:" +echo "$RPMLIST" +echo "====================================================================" +echo + +# Restore original bootstraprc +mv -f $1/program/bootstraprc.orig $1/program/bootstraprc + +rpm --dbpath $RPM_DB_PATH --erase $RPMLIST || exit 2 + +echo "Removing RPM database ..." +rm -rf $RPM_DB_PATH + +echo +echo "Deinstallation done." + +exit 0 diff --git a/setup_native/scripts/uninstall_solaris.sh b/setup_native/scripts/uninstall_solaris.sh new file mode 100644 index 000000000000..970191f08421 --- /dev/null +++ b/setup_native/scripts/uninstall_solaris.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# First parameter: Root path that will be removed +# MY_ROOT=/export/home/is/root + +if [ $# -ne 1 -o -z "$1" ] +then + echo "One parameter required" + echo "Usage:" + echo "1. parameter: Path to the local root directory" + echo "All packages in local database will be removed!" + exit 2 +fi + +MY_ROOT=$1 + +cd `dirname $0` +DIRECTORY=`pwd` + +GETUID_SO=/tmp/getuid.so.$$ +linenum=??? +tail +$linenum `basename $0` > $GETUID_SO + +PKGLIST=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep -v core` +COREPKG=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep core` +COREPKG01=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep core01` + +echo "#############################################" +echo "# Deinstallation of Office packages #" +echo "#############################################" +echo +echo "Path to the root directory : " $MY_ROOT +echo +echo "Packages to deinstall:" +for i in $PKGLIST $COREPKG; do + echo $i +done + +INSTALL_DIR=$MY_ROOT`pkginfo -R $MY_ROOT -r $COREPKG01` + +# Restore original bootstraprc +mv -f $INSTALL_DIR/program/bootstraprc.orig $INSTALL_DIR/program/bootstraprc + +for i in $PKGLIST $COREPKG; do + LD_PRELOAD=$GETUID_SO /usr/sbin/pkgrm -n -R $MY_ROOT $i +done + +# Removing old root directory, very dangerous! +# rm -rf $MY_ROOT + +# removing library in temp directory +rm -f $GETUID_SO + +echo +echo "Deinstallation done..." + +exit 0 diff --git a/setup_native/scripts/unpack_update.sh b/setup_native/scripts/unpack_update.sh new file mode 100644 index 000000000000..d93bb2749c07 --- /dev/null +++ b/setup_native/scripts/unpack_update.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +EXTENSION=`expr "//$1" : '.*\/.*\.\(t.*\)'` +[ -z $EXTENSION ] && ( echo "Unable to determine file type"; exit 2 ) + +BASEDIR=`dirname "$1"` +FOLDER=`basename "$1" ".$EXTENSION"` +NUM=1 + +DESTPATH="$BASEDIR/$FOLDER" + +while [ -d "$DESTPATH" ]; do + NUM=`expr $NUM + 1` + DESTPATH="$BASEDIR/$FOLDER-$NUM" +done + +mkdir "$DESTPATH" +cd "$DESTPATH" + +if [ "$EXTENSION" = "tar.gz" -o "$EXTENSION" = "tgz" ]; then + if [ -x /usr/bin/gzcat ]; then + /usr/bin/gzcat "$1" | tar -xf - + else + tar -xzf "$1" + fi +elif [ "$EXTENSION" = "tar.bz2" -o "$EXTENSION" = "tbz2" ]; then + /usr/bin/bzcat "$1" | tar -xf - +else + echo "Unsupported type of archive" + exit 2 +fi + +UPDATE=`eval ls */update` && SUBFOLDER=`dirname $UPDATE` && mv $SUBFOLDER/* . && rmdir $SUBFOLDER && echo "$DESTPATH/update" diff --git a/setup_native/scripts/update.sh b/setup_native/scripts/update.sh new file mode 100644 index 000000000000..20b8bbae0292 --- /dev/null +++ b/setup_native/scripts/update.sh @@ -0,0 +1,195 @@ +#!/bin/sh + +GNOMEXCMDS="/usr/bin/gksu" +GNOMECMDS="/usr/bin/gnome-terminal /opt/gnome/bin/gnome-terminal" +KDEXCMDS="/usr/bin/kdesu /opt/kde/bin/kdesu /opt/kde?/bin/kdesu" +KDECMDS="/usr/bin/konsole /opt/kde/bin/konsole /opt/kde?/bin/konsole" +MISCCMDS="/usr/bin/x-terminal-emulator /usr/X11/bin/xterm /usr/openwin/bin/xterm" + +TITLE='${PRODUCTNAME} update' + +# +# Usage +# + +Usage () { + if [ "`basename $0`" = "update" ]; then + echo "Usage: `basename $0` [<path to ${PRODUCTNAME} installation>]" + fi + echo + exit 2 +} + +make_tempfile() { + + # Always prefer mktemp when available + if [ -x "$MKTEMP" ]; then + "$MKTEMP" "/tmp/$1.XXXXXX" + else + TMPCMD="/tmp/$1.$$" + touch $TMPCMD + echo $TMPCMD + fi + +} + +# +# make_command_file - generate a command file to pass to xterm & co +# +run_in_terminal () { + + TMPCMD=`make_tempfile 'OpenOffice.org-Online-Update'` + + cat >> $TMPCMD + + cat >> $TMPCMD << \EOF +if [ $? -eq 0 -a ! -z "$DISPLAY" ]; then + echo + echo "Press <Enter> to close this window" + read DUMMY +fi +EOF + + cat >> $TMPCMD << EOF +rm -f $TMPCMD +EOF + + chmod a+x $TMPCMD + exec "$@" -e $TMPCMD +} + +# +# run the command line passed as positional parameters either via +# gksu/kdesu or via su command in a terminal emulator. +# +elevate() { + + TITLEOPT="" + GEOMOPT="" + case `basename $XTERM` in + "xterm") + TITLEOPT="-title" + GEOMOPT="-geometry " + ;; + "gnome-terminal" | "konsole" | "x-terminal-emulator") + TITLEOPT="--title" + GEOMOPT="--geometry=" + ;; + esac + + case `basename $SU` in + "kdesu" ) + # --caption + SUOPT="-t" + ;; + "gksu" ) + # --title + SUOPT="" + ;; + "su" ) + SUOPT="- root -c" + ;; + esac + + ( echo "echo The application \"$@\" will update your ${PRODUCTNAME} installation." + echo "echo" + echo "$SU" "$SUOPT" "$@" + ) | run_in_terminal "$XTERM" "$TITLEOPT" "$TITLE" ${GEOMOPT}+300+300 +} + + +update_pkg() { + ADMINFILE=`make_tempfile 'OpenOffice.org-Online-Update-admin'` + +cat >> $ADMINFILE << EOF +action=nocheck +conflict=nocheck +setuid=nocheck +idepend=nocheck +rdepend=nocheck +mail= +EOF + + PKGLIST="" + for i in `cd $1; ls -d *`; do + pkginfo -q $i && PKGLIST="$PKGLIST $i" + done + + pkgrm -n -a $ADMINFILE $PKGLIST + pkgadd -n -a $ADMINFILE -d $1 $PKGLIST + + rm -f $ADMINFILE +} + +# +# main +# + +CMD="`basename $0`" +BASEDIR="`dirname $0`" +ABSBASEDIR="`cd $BASEDIR; pwd`" + +if [ -z "$DISPLAY" ]; then + SU="su" + XTERM="" +else + # define search order depending on the desktop in use .. + if [ "`uname -s`" = "SunOS" ]; then + XPROP=/usr/openwin/bin/xprop + GREP=/usr/xpg4/bin/grep + MKTEMP=/usr/bin/mktemp + else + if [ -x /usr/X11/bin/xprop ]; then + XPROP=/usr/X11/bin/xprop + else + XPROP=/usr/bin/xprop + fi + GREP=grep + MKTEMP=/bin/mktemp + fi + + # use desktop specific tools where possible, but prefer X11 su over terminal emulators + if $XPROP -root | $GREP -q '^KWIN_RUNNING'; then + SULIST="$KDEXCMDS $GNOMEXCMDS" + XTERMLIST="$KDECMDS $MISCCMDS" + else + SULIST="$GNOMEXCMDS $KDEXCMDS" + XTERMLIST="$GNOMECMDS $MISCCMDS" + fi + + # search for the first available terminal emulator + for i in $XTERMLIST; do + if [ -x $i ]; then + XTERM=$i + break + fi + done + + # we prefer gksu or kdesu if available + SU="su" + for i in $SULIST; do + if [ -x $i ]; then + SU=$i + break + fi + done +fi + +if [ "$CMD" = "update" ]; then + if [ $# -gt 0 ]; then + [ -d $1 -a $# -eq 1 ] || Usage + elevate "$ABSBASEDIR/$CMD" + else + if [ -d "$BASEDIR/RPMS" ]; then + # do not use --hash as the control sequence to edit the current line does not work + # in our setup (at least not with kdesu) + rpm -v --freshen `find "$BASEDIR"/RPMS -name '*.rpm'` + elif [ -d "$BASEDIR/DEBS" ]; then + dpkg --install --selected-only --recursive "$BASEDIR"/DEBS + elif [ -d "$BASEDIR/packages" ]; then + update_pkg "$BASEDIR/packages" + fi + fi +else + Usage +fi diff --git a/setup_native/scripts/userland.txt b/setup_native/scripts/userland.txt new file mode 100644 index 000000000000..9983ab46fe16 --- /dev/null +++ b/setup_native/scripts/userland.txt @@ -0,0 +1,28 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +USERLANDPACKAGENAME=openoffice.org-userland-1.0-0.noarch.rpm |