Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


Hi,
    I was looking at the perl installer, and attached are patches to
change most of the chmod system calls into calls to the built-in
command.  This change alone doesn't seem to make a big difference (it
cut about 5 seconds off of a 4 1/2 minute run of ooinstall for me).
    The second patch includes the replacement of a couple of two-step
chmod calls with a single built-in call; the original code indicated
that it was a work-around for removing the sticky bit on Macs.  I
don't have a Mac to test that the new call handles sticky bits in the
same way, but expect that it will from checking the current perlport
doc.

    LGPLv3+/MPL.

Jordan Ayers
From 09210008700de4243b249e157a3df83a317bbac2 Mon Sep 17 00:00:00 2001
From: Jordan Ayers <jordan.ayers@gmail.com>
Date: Sun, 7 Nov 2010 18:02:12 -0600
Subject: [PATCH 1/2] Perl Installer:  Use built-in chmod

Replace several system calls which performed single-file permission sets with the built-in chmod 
command.
---
 solenv/bin/modules/installer/copyproject.pm   |   24 +++++++++---------------
 solenv/bin/modules/installer/download.pm      |    6 ++----
 solenv/bin/modules/installer/epmfile.pm       |   21 ++-------------------
 solenv/bin/modules/installer/javainstaller.pm |    6 ++----
 solenv/bin/modules/installer/languagepack.pm  |    3 +--
 solenv/bin/modules/installer/parameter.pm     |    3 +--
 solenv/bin/modules/installer/simplepackage.pm |   12 +++---------
 solenv/bin/modules/installer/worker.pm        |   12 ++++--------
 8 files changed, 24 insertions(+), 63 deletions(-)

diff --git a/solenv/bin/modules/installer/copyproject.pm 
b/solenv/bin/modules/installer/copyproject.pm
index 88f3b79..93f4d29 100644
--- a/solenv/bin/modules/installer/copyproject.pm
+++ b/solenv/bin/modules/installer/copyproject.pm
@@ -69,17 +69,14 @@ sub copy_project
         
         installer::systemactions::copy_one_file($source, $destination);
 
-        if ( $destination =~ /install\s*$/ )
+        if ( $onefile->{'UnixRights'} )
         {
-            my $localcall = "chmod 775 $destination \>\/dev\/null 2\>\&1";
-            system($localcall);
+            chmod oct($onefile->{'UnixRights'}), $destination;
         }
-
-            if ( $onefile->{'UnixRights'} )
+        elsif ( $destination =~ /install\s*$/ )
         {
-            my $localcall = "chmod $onefile->{'UnixRights'} $destination \>\/dev\/null 2\>\&1";
-            system($localcall);
-            }
+            chmod 0775, $destination;
+        }
     }
         
     # copy ScpActions  
@@ -93,16 +90,13 @@ sub copy_project
         
         installer::systemactions::copy_one_file($source, $destination);
         
-        if ( $destination =~ /install\s*$/ )
+        if ( $onefile->{'UnixRights'} )
         {
-            my $localcall = "chmod 775 $destination \>\/dev\/null 2\>\&1";
-            system($localcall);
+            chmod oct($onefile->{'UnixRights'}), $destination;
         }
-
-        if ( $onefile->{'UnixRights'} )
+        elsif ( $destination =~ /install\s*$/ )
         {
-            my $localcall = "chmod $onefile->{'UnixRights'} $destination \>\/dev\/null 2\>\&1";
-            system($localcall);
+            chmod 0775, $destination;
         }
     }
 
diff --git a/solenv/bin/modules/installer/download.pm b/solenv/bin/modules/installer/download.pm
index 8e70bbb..7b30c43 100644
--- a/solenv/bin/modules/installer/download.pm
+++ b/solenv/bin/modules/installer/download.pm
@@ -118,8 +118,7 @@ sub save_script_file
 
     if ( ! $installer::globals::iswindowsbuild )
     {
-        my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1";
-        system($localcall);
+        chmod 0775, $newscriptfilename;
     }
     
     return $newscriptfilename;
@@ -339,8 +338,7 @@ sub tar_package
         push( @installer::globals::logfileinfo, $infoline);
     }
     
-    my $localcall = "chmod 775 $tarfilename \>\/dev\/null 2\>\&1";
-    $returnvalue = system($localcall);
+    chmod 0775, $tarfilename;
 
     return ( -s $tarfilename );
 }
diff --git a/solenv/bin/modules/installer/epmfile.pm b/solenv/bin/modules/installer/epmfile.pm
index 2af2f3c..0e1b18a 100644
--- a/solenv/bin/modules/installer/epmfile.pm
+++ b/solenv/bin/modules/installer/epmfile.pm
@@ -2875,23 +2875,7 @@ sub create_new_directory_structure
     }
         
     # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
-        
-    my $localcall = "chmod 775 $newdir \>\/dev\/null 2\>\&1";
-    my $callreturnvalue = system($localcall);
-
-    my $callinfoline = "Systemcall: $localcall\n";
-    push( @installer::globals::logfileinfo, $callinfoline);
-        
-    if ($callreturnvalue)
-    {
-        $callinfoline = "ERROR: Could not execute \"$localcall\"!\n";
-        push( @installer::globals::logfileinfo, $callinfoline);
-    }
-    else
-    {
-        $callinfoline = "Success: Executed \"$localcall\" successfully!\n";
-        push( @installer::globals::logfileinfo, $callinfoline);
-    }
+    chmod 0775, $newdir;
 }
 
 ######################################################
@@ -3453,8 +3437,7 @@ sub finalize_linux_patch
     push( @installer::globals::logfileinfo, $infoline);
 
     # Setting unix rights 755
-    my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1";
-    system($localcall);
+    chmod 0755, $newscriptfilename;
 }
 
 1;
diff --git a/solenv/bin/modules/installer/javainstaller.pm 
b/solenv/bin/modules/installer/javainstaller.pm
index 57ed700..0420158 100644
--- a/solenv/bin/modules/installer/javainstaller.pm
+++ b/solenv/bin/modules/installer/javainstaller.pm
@@ -1168,8 +1168,7 @@ sub copy_setup_locally
     if ($$loadernameref eq "") { installer::exiter::exit_program("ERROR: Could not find Java 
loader $loadername!", "copy_setup_locally"); }
 
     installer::systemactions::copy_one_file($$loadernameref, $newname);
-    my $localcall = "chmod 775 $newname \>\/dev\/null 2\>\&1";
-    system($localcall);
+    chmod 0775, $newname;
 }
 
 
@@ -1185,8 +1184,7 @@ sub put_loader_into_installset
 
     installer::systemactions::copy_one_file($filename, $installname);
     
-    my $localcall = "chmod 775 $installname \>\/dev\/null 2\>\&1";
-    system($localcall);
+    chmod 0775, $installname;
 }
 
 #################################################################
diff --git a/solenv/bin/modules/installer/languagepack.pm 
b/solenv/bin/modules/installer/languagepack.pm
index e46dbc7..509dfac 100644
--- a/solenv/bin/modules/installer/languagepack.pm
+++ b/solenv/bin/modules/installer/languagepack.pm
@@ -466,8 +466,7 @@ sub include_package_into_script
         push( @installer::globals::logfileinfo, $infoline);
     }
     
-    my $localcall = "chmod 775 $scriptfilename \>\/dev\/null 2\>\&1";
-    system($localcall);
+    chmod 0775, $scriptfilename;
 
 }
 
diff --git a/solenv/bin/modules/installer/parameter.pm b/solenv/bin/modules/installer/parameter.pm
index 6e0c05e..b5b20e4 100644
--- a/solenv/bin/modules/installer/parameter.pm
+++ b/solenv/bin/modules/installer/parameter.pm
@@ -449,8 +449,7 @@ sub setglobalvariables
 
         if ( $installer::globals::compiler =~ /^unxmac/ )
         {
-            my $localcall = "chmod 777 $installer::globals::temppath \>\/dev\/null 2\>\&1";
-            system($localcall);
+            chmod 0777, $installer::globals::temppath;
         }
 
         $installer::globals::temppath = $installer::globals::temppath . 
$installer::globals::separator . "i";
diff --git a/solenv/bin/modules/installer/simplepackage.pm 
b/solenv/bin/modules/installer/simplepackage.pm
index 9ad0fc6..a5cdc13 100644
--- a/solenv/bin/modules/installer/simplepackage.pm
+++ b/solenv/bin/modules/installer/simplepackage.pm
@@ -500,10 +500,8 @@ sub create_package
             replace_variables_in_scriptfile($scriptfilecontent, $volume_name, $allvariables);
             installer::files::save_file($scriptfilename, $scriptfilecontent);
 
-            $systemcall = "chmod 775 " . "\"" . $scriptfilename . "\"";
-            system($systemcall);
-            $systemcall = "chmod 775 " . "\"" . $scripthelperrealfilename . "\"";
-            system($systemcall);
+            chmod 0775, $scriptfilename;
+            chmod 0775, $scripthelperrealfilename;
 
             # Copy also Info.plist and icon file
             # Finding both files in solver
@@ -717,13 +715,9 @@ sub create_simple_package
             if ( ! $installer::globals::iswindowsbuild )
             {
                 # see issue 102274 
-                my $unixrights = "";
                 if ( $onefile->{'UnixRights'} )
                 {
-                    $unixrights = $onefile->{'UnixRights'};
-                    
-                    my $localcall = "$installer::globals::wrapcmd chmod $unixrights 
\'$destination\' \>\/dev\/null 2\>\&1";
-                    system($localcall);
+                    chmod oct($onefile->{'UnixRights'}), $destination;
                 }
             }
         }
diff --git a/solenv/bin/modules/installer/worker.pm b/solenv/bin/modules/installer/worker.pm
index 1bd58b2..6600dbf 100644
--- a/solenv/bin/modules/installer/worker.pm
+++ b/solenv/bin/modules/installer/worker.pm
@@ -107,8 +107,7 @@ sub copy_install_sets_to_ship
     if (( ! $installer::globals::iswindowsbuild ) && ( $installer::globals::addjavainstaller ))
     {
         # Setting Unix rights for Java starter ("setup")
-        my $localcall = "chmod 775 $localshipinstalldir/setup \>\/dev\/null 2\>\&1";
-        system($localcall);
+        chmod 0775, "$localshipinstalldir/setup";
     }
 
     # unpacking the tar.gz file for Solaris
@@ -2207,8 +2206,7 @@ sub put_scpactions_into_installset
         
         if ( $onescpaction->{'UnixRights'} )
         {
-            my $localcall = "chmod $onescpaction->{'UnixRights'} $destfile \>\/dev\/null 2\>\&1";
-            system($localcall);
+            chmod oct($onescpaction->{'UnixRights'}), $destfile;
         }
 
     }
@@ -3202,8 +3200,7 @@ sub tar_package
         push( @installer::globals::logfileinfo, $infoline);
     }
     
-    my $localcall = "chmod 775 $tarfilename \>\/dev\/null 2\>\&1";
-    $returnvalue = system($localcall);
+    chmod 0775, $tarfilename;
 
     my $fulltarfile = $installdir . $installer::globals::separator . $tarfilename;
     my $filesize = ( -s $fulltarfile );
@@ -3240,8 +3237,7 @@ sub untar_package
         push( @installer::globals::logfileinfo, $infoline);
     }
     
-    my $localcall = "chmod 775 $tarfilename \>\/dev\/null 2\>\&1";
-    $returnvalue = system($localcall);
+    chmod 0775, $tarfilename;
 }
 
 #########################################################
-- 
1.7.1

From 6506f14c53d2c9b63184d2bbe654f187d62c2308 Mon Sep 17 00:00:00 2001
From: Jordan Ayers <jordan.ayers@gmail.com>
Date: Sun, 7 Nov 2010 18:03:56 -0600
Subject: [PATCH 2/2] Perl Installer:  Use built-in chmod

Replace system calls which performed single-file permission sets with calls to the built-in chmod.
Replace the implementation of create_directory with a call to create_directory_with_privileges.
---
 solenv/bin/modules/installer/systemactions.pm |  124 ++-----------------------
 1 files changed, 7 insertions(+), 117 deletions(-)

diff --git a/solenv/bin/modules/installer/systemactions.pm 
b/solenv/bin/modules/installer/systemactions.pm
index 83502ef..626af7f 100644
--- a/solenv/bin/modules/installer/systemactions.pm
+++ b/solenv/bin/modules/installer/systemactions.pm
@@ -42,109 +42,8 @@ use installer::remover;
 sub create_directory
 {
     my ($directory) = @_;
-        
-    my $returnvalue = 1;
-    my $infoline = "";
-
-    if (!(-d $directory))
-    {
-        $returnvalue = mkdir($directory, 0775);
-
-        if ($returnvalue)
-        {
-            $infoline = "\nCreated directory: $directory\n";
-            push(@installer::globals::logfileinfo, $infoline);
-    
-            my $localcall = "chmod 0775 $directory \>\/dev\/null 2\>\&1";
-            system($localcall);
-
-            # chmod 0775 is not sufficient on mac to remove sticky tag
-            $localcall = "chmod a-s $directory \>\/dev\/null 2\>\&1";
-            system($localcall);                        
-        }
-        else
-        {
-            # New solution in parallel packing: It is possible, that the directory now exists, 
although it
-            # was not created in this process. There is only an important error, if the directory 
does not
-            # exist now. 
-
-            $infoline = "\nDid not succeed in creating directory: \"$directory\". Further attempts 
will follow.\n";
-            push(@installer::globals::logfileinfo, $infoline);
-            
-            if (!(-d $directory))
-            {
-                # Problem with parallel packaging? -> Try a little harder, before exiting.
-                # Did someone else remove the parent directory in the meantime?
-                my $parentdir = $directory;
-                installer::pathanalyzer::get_path_from_fullqualifiedname(\$parentdir);
-                if (!(-d $parentdir))
-                {
-                    $returnvalue = mkdir($parentdir, 0775);
-
-                    if ($returnvalue)
-                    {
-                        $infoline = "\nAttention: Successfully created parent directory (should 
already be created before): $parentdir\n";
-                        push(@installer::globals::logfileinfo, $infoline);
-    
-                        my $localcall = "chmod 775 $parentdir \>\/dev\/null 2\>\&1";
-                        system($localcall);
-                    }
-                    else
-                    {
-                        $infoline = "\Error: \"$directory\" could not be created. Even the parent 
directory \"$parentdir\" does not exist and could not be created.\n";
-                        push(@installer::globals::logfileinfo, $infoline);
-                        if ( -d $parentdir )
-                        {
-                            $infoline = "\nAttention: Finally the parent directory \"$parentdir\" 
exists, but I could not create it.\n";
-                            push(@installer::globals::logfileinfo, $infoline);
-                        }
-                        else
-                        {
-                            # Now it is time to exit, even the parent could not be created.
-                            installer::exiter::exit_program("ERROR: Could not create parent 
directory \"$parentdir\"", "create_directory");
-                        }
-                    }          
-                }
-            
-                # At this point we have to assume, that the parent directory exist.
-                # Trying once more to create the desired directory
 
-                $returnvalue = mkdir($directory, 0775);
-
-                if ($returnvalue)
-                {
-                    $infoline = "\nAttention: Created directory \"$directory\" in the second 
try.\n";
-                    push(@installer::globals::logfileinfo, $infoline);
-    
-                    my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1";
-                    system($localcall);
-                }
-                else
-                {
-                    if ( -d $directory )
-                    {
-                        $infoline = "\nAttention: Finally the directory \"$directory\" exists, but 
I could not create it.\n";
-                        push(@installer::globals::logfileinfo, $infoline);
-                    }
-                    else
-                    {
-                        # It is time to exit, even the second try failed.
-                        installer::exiter::exit_program("ERROR: Failed to create the directory: 
$directory", "create_directory");
-                    }  
-                }                              
-            }
-            else
-            {
-                $infoline = "\nAnother process created this directory in exactly this moment :-) : 
$directory\n";
-                push(@installer::globals::logfileinfo, $infoline);
-            }
-        }
-    }
-    else
-    {
-        $infoline = "\nAlready existing directory, did not create: $directory\n";
-        push(@installer::globals::logfileinfo, $infoline);
-    }
+    create_directory_with_privileges( $directory, "755" );
 }
 
 ######################################################
@@ -157,10 +56,10 @@ sub create_directory_with_privileges
         
     my $returnvalue = 1;
     my $infoline = "";
+    my $localprivileges = oct("0".$privileges); # changes "777" to 0777
 
     if (!(-d $directory))
     {
-        my $localprivileges = oct("0".$privileges); # changes "777" to 0777
         $returnvalue = mkdir($directory, $localprivileges);
 
         if ($returnvalue)
@@ -168,8 +67,7 @@ sub create_directory_with_privileges
             $infoline = "\nCreated directory: $directory\n";
             push(@installer::globals::logfileinfo, $infoline);
     
-            my $localcall = "chmod $privileges $directory \>\/dev\/null 2\>\&1";
-            system($localcall);
+            chmod $localprivileges, $directory;
         }
         else
         {
@@ -195,8 +93,7 @@ sub create_directory_with_privileges
                         $infoline = "\nAttention: Successfully created parent directory (should 
already be created before): $parentdir\n";
                         push(@installer::globals::logfileinfo, $infoline);
     
-                        my $localcall = "chmod $privileges $parentdir \>\/dev\/null 2\>\&1";
-                        system($localcall);
+                        chmod $localprivileges, $parentdir;
                     }
                     else
                     {
@@ -225,8 +122,7 @@ sub create_directory_with_privileges
                     $infoline = "\nAttention: Created directory \"$directory\" in the second 
try.\n";
                     push(@installer::globals::logfileinfo, $infoline);
     
-                    my $localcall = "chmod $privileges $directory \>\/dev\/null 2\>\&1";
-                    system($localcall);
+                    chmod $localprivileges, $directory;
                 }
                 else
                 {
@@ -254,8 +150,7 @@ sub create_directory_with_privileges
         $infoline = "\nAlready existing directory, did not create: $directory\n";
         push(@installer::globals::logfileinfo, $infoline);
 
-        my $localcall = "chmod $privileges $directory \>\/dev\/null 2\>\&1";
-        system($localcall);
+        chmod $localprivileges, $directory;
     }
 }
 
@@ -1443,12 +1338,7 @@ sub try_to_create_directory
             $infoline = "\nCreated directory: $directory\n";
             push(@installer::globals::logfileinfo, $infoline);
     
-            my $localcall = "chmod 0775 $directory \>\/dev\/null 2\>\&1";
-            system($localcall);
-
-            # chmod 0775 is not sufficient on mac to remove sticky tag
-            $localcall = "chmod a-s $directory \>\/dev\/null 2\>\&1";
-            system($localcall);
+            chmod 0775, $directory;
         }
         else
         {
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.