1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: systemactions.pm,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
33 package pre2par
::systemactions
;
39 ######################################################
40 # Creating a new direcotory
41 ######################################################
52 $returnvalue = mkdir($directory, 0775);
56 $infoline = "Created directory: $directory\n";
57 push(@pre2par::globals
::logfileinfo
, $infoline);
59 if ($pre2par::globals
::isunix
)
61 my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1";
67 # New solution in parallel packing: It is possible, that the directory now exists, although it
68 # was not created in this process. There is only an important error, if the directory does not
73 pre2par
::exiter
::exit_program
("Error: Could not create directory: $directory", "create_directory");
77 $infoline = "\nAnother process created this directory in exactly this moment :-) : $directory\n";
78 push(@pre2par::globals
::logfileinfo
, $infoline);
84 $infoline = "\nAlready existing directory, did not create: $directory\n";
85 push(@pre2par::globals
::logfileinfo
, $infoline);
89 #######################################################################
90 # Creating the directories, in which files are generated or unzipped
91 #######################################################################
93 sub create_directories
95 my ($directory, $languagesref) =@_;
97 $pre2par::globals
::unpackpath
=~ s/\Q$pre2par::globals::separator\E\s*$//; # removing ending slashes and backslashes
99 my $path = $pre2par::globals
::unpackpath
; # this path already exists
101 $path = $path . $pre2par::globals
::separator
. $pre2par::globals
::build
. $pre2par::globals
::separator
;
102 create_directory
($path);
104 $path = $path . $pre2par::globals
::minor
. $pre2par::globals
::separator
;
105 create_directory
($path);
107 if ($directory eq "unzip" )
109 $path = $path . "common" . $pre2par::globals
::productextension
. $pre2par::globals
::separator
;
110 create_directory
($path);
112 $path = $path . $directory . $pre2par::globals
::separator
;
113 create_directory
($path);
117 $path = $path . $pre2par::globals
::compiler
. $pre2par::globals
::productextension
. $pre2par::globals
::separator
;
118 create_directory
($path);
120 $path = $path . $pre2par::globals
::product
. $pre2par::globals
::separator
;
121 create_directory
($path);
123 $path = $path . $directory . $pre2par::globals
::separator
;
124 create_directory
($path);
126 if (!($$languagesref eq "" )) # this will be a path like "01_49", for Profiles and ConfigurationFiles, idt-Files
128 $path = $path . $$languagesref . $pre2par::globals
::separator
;
129 create_directory
($path);
133 $path =~ s/\Q$pre2par::globals::separator\E\s*$//;
138 ########################
140 ########################
144 my ($source, $dest) = @_;
146 my ($copyreturn, $returnvalue, $infoline);
148 $copyreturn = copy
($source, $dest);
152 $infoline = "Copy: $source to $dest\n";
157 $infoline = "Error: Could not copy $source to $dest\n";
161 push(@pre2par::globals
::logfileinfo
, $infoline);
166 ##########################################
167 # Copying all files from one directory
168 # to another directory
169 ##########################################
173 my ($sourcedir, $destdir) = @_;
175 my ($onefile, $sourcefile, $destfile);
176 my @sourcefiles = ();
178 $sourcedir =~ s/\Q$pre2par::globals::separator\E\s*$//;
179 $destdir =~ s/\Q$pre2par::globals::separator\E\s*$//;
182 push(@pre2par::globals
::logfileinfo
, $infoline);
183 $infoline = "Copying files from directory $sourcedir to directory $destdir\n";
184 push(@pre2par::globals
::logfileinfo
, $infoline);
186 opendir(DIR
, $sourcedir);
187 @sourcefiles = readdir(DIR
);
190 foreach $onefile (@sourcefiles)
192 if ((!($onefile eq ".")) && (!($onefile eq "..")))
194 $sourcefile = $sourcedir . $pre2par::globals
::separator
. $onefile;
195 $destfile = $destdir . $pre2par::globals
::separator
. $onefile;
196 if ( -f
$sourcefile ) # only files, no directories
198 copy_one_file
($sourcefile, $destfile);