Bump for 3.6-28
[LibreOffice.git] / solenv / bin / modules / par2script / systemactions.pm
blob149fafe93b0bb294d6c0773bb0d5c65c3c03046f
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
11 # OpenOffice.org is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Lesser General Public License version 3
13 # only, as published by the Free Software Foundation.
15 # OpenOffice.org is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Lesser General Public License version 3 for more details
19 # (a copy is included in the LICENSE file that accompanied this code).
21 # You should have received a copy of the GNU Lesser General Public License
22 # version 3 along with OpenOffice.org. If not, see
23 # <http://www.openoffice.org/license.html>
24 # for a copy of the LGPLv3 License.
26 #*************************************************************************
29 package par2script::systemactions;
31 use File::Copy;
32 use par2script::exiter;
33 use par2script::globals;
35 ######################################################
36 # Creating a new direcotory
37 ######################################################
39 sub create_directory
41 my ($directory) = @_;
43 my $returnvalue = 1;
45 if (!(-d $directory))
47 $returnvalue = mkdir($directory, 0775);
49 if ($returnvalue)
51 $infoline = "Created directory: $directory\n";
52 push(@par2script::globals::logfileinfo, $infoline);
54 if ($par2script::globals::isunix)
56 my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1";
57 system($localcall);
60 else
62 par2script::exiter::exit_program("Error: Could not create directory: $directory", "create_directory");
67 #######################################################################
68 # Creating the directories, in which files are generated or unzipped
69 #######################################################################
71 sub create_directories
73 my ($directory, $languagesref) =@_;
75 $par2script::globals::unpackpath =~ s/\Q$par2script::globals::separator\E\s*$//; # removing ending slashes and backslashes
77 my $path = $par2script::globals::unpackpath; # this path already exists
79 $path = $path . $par2script::globals::separator . $par2script::globals::build . $par2script::globals::separator;
80 create_directory($path);
82 $path = $path . $par2script::globals::minor . $par2script::globals::separator;
83 create_directory($path);
85 if ($directory eq "unzip" )
87 $path = $path . "common" . $par2script::globals::productextension . $par2script::globals::separator;
88 create_directory($path);
90 $path = $path . $directory . $par2script::globals::separator;
91 create_directory($path);
93 else
95 $path = $path . $par2script::globals::compiler . $par2script::globals::productextension . $par2script::globals::separator;
96 create_directory($path);
98 $path = $path . $par2script::globals::product . $par2script::globals::separator;
99 create_directory($path);
101 $path = $path . $directory . $par2script::globals::separator;
102 create_directory($path);
104 if (!($$languagesref eq "" )) # this will be a path like "01_49", for Profiles and ConfigurationFiles, idt-Files
106 $path = $path . $$languagesref . $par2script::globals::separator;
107 create_directory($path);
111 $path =~ s/\Q$par2script::globals::separator\E\s*$//;
113 return $path;
116 ########################
117 # Copying one file
118 ########################
120 sub copy_one_file
122 my ($source, $dest) = @_;
124 my ($copyreturn, $returnvalue);
125 my $infoline;
127 $copyreturn = copy($source, $dest);
129 if ($copyreturn)
131 $infoline = "Copy: $source to $dest\n";
132 $returnvalue = 1;
134 else
136 $infoline = "Error: Could not copy $source to $dest $!\n";
137 $returnvalue = 0;
140 push(@par2script::globals::logfileinfo, $infoline);
142 return $returnvalue;
145 ##########################################
146 # Copying all files from one directory
147 # to another directory
148 ##########################################
150 sub copy_directory
152 my ($sourcedir, $destdir) = @_;
154 my ($onefile, $sourcefile, $destfile);
155 my @sourcefiles = ();
157 $sourcedir =~ s/\Q$par2script::globals::separator\E\s*$//;
158 $destdir =~ s/\Q$par2script::globals::separator\E\s*$//;
160 $infoline = "\n";
161 push(@par2script::globals::logfileinfo, $infoline);
162 $infoline = "Copying files from directory $sourcedir to directory $destdir\n";
163 push(@par2script::globals::logfileinfo, $infoline);
165 opendir(DIR, $sourcedir);
166 @sourcefiles = readdir(DIR);
167 closedir(DIR);
169 foreach $onefile (@sourcefiles)
171 if ((!($onefile eq ".")) && (!($onefile eq "..")))
173 $sourcefile = $sourcedir . $par2script::globals::separator . $onefile;
174 $destfile = $destdir . $par2script::globals::separator . $onefile;
175 if ( -f $sourcefile ) # only files, no directories
177 copy_one_file($sourcefile, $destfile);