diff options
author | Ingo Schmidt <is@openoffice.org> | 2010-07-12 18:02:39 +0200 |
---|---|---|
committer | Ingo Schmidt <is@openoffice.org> | 2010-07-12 18:02:39 +0200 |
commit | 00d5cdc080f6381c0b42f231763195298bbca5ba (patch) | |
tree | d156dc52e448fd9be60f11fa8b58d1720ab566d6 /setup_native/scripts | |
parent | jl154 #162868# unopkg is back in packaging and installation (diff) | |
download | core-00d5cdc080f6381c0b42f231763195298bbca5ba.tar.gz core-00d5cdc080f6381c0b42f231763195298bbca5ba.zip |
jl154 #162868# unopkg is back in packaging and installation
Diffstat (limited to 'setup_native/scripts')
-rw-r--r-- | setup_native/scripts/admin.pl | 120 |
1 files changed, 88 insertions, 32 deletions
diff --git a/setup_native/scripts/admin.pl b/setup_native/scripts/admin.pl index c69888299c6d..49b36fbe2f2d 100644 --- a/setup_native/scripts/admin.pl +++ b/setup_native/scripts/admin.pl @@ -299,6 +299,68 @@ sub get_sourcepath_from_filename_and_includepath 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"; + + return $extensiondir; +} + ######################################################## # Finding all files with a specified file extension # in a specified directory. @@ -787,6 +849,12 @@ sub create_directory_structure 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; } @@ -876,7 +944,6 @@ sub copy_files_into_directory_structure print "Copying files\n"; my $unopkgfile = ""; - my @extensions = (); for ( my $i = 1; $i <= $maxsequence; $i++ ) { @@ -919,8 +986,6 @@ sub copy_files_into_directory_structure if ( ! $copyreturn) { exit_program("ERROR: Could not copy $source to $dest\n"); } - # Collecting all extensions - if ( $destfile =~ /\.oxt\s*$/ ) { push(@extensions, $destfile); } # Searching unopkg.exe if ( $destfile =~ /unopkg\.exe\s*$/ ) { $unopkgfile = $destfile; } # if (( $^O =~ /cygwin/i ) && ( $destfile =~ /\.exe\s*$/ )) { change_privileges($destfile, "775"); } @@ -931,7 +996,7 @@ sub copy_files_into_directory_structure # } } - return ($unopkgfile, \@extensions); + return ($unopkgfile); } ###################################################### @@ -1025,9 +1090,9 @@ sub get_temppath # Registering extensions #################################################################################### -sub do_register_extensions +sub register_extensions_sync { - my ($unopkgfile, $extension, $localtemppath) = @_; + my ($unopkgfile, $localtemppath) = @_; my $from = cwd(); @@ -1048,21 +1113,14 @@ sub do_register_extensions } $localtemppath =~ s/\\/\//g; - $localtemppath = "/".$localtemppath; - - # Converting path of $extension for cygwin - - my $localextension = $extension; - if ( $^O =~ /cygwin/i ) { - $localextension = qx{cygpath -w "$extension"}; - $localextension =~ s/\\/\\\\/g; - } if ( $^O =~ /cygwin/i ) { $executable = "./" . $executable; + $bundleddir = qx{cygpath -m "$bundleddir"}; + chomp($bundleddir); } - my $systemcall = $executable . " sync --verbose -env:BUNDLED_EXTENSIONS_USER=\"file://" . $bundleddir . "\"" . " -env:UserInstallation=file://" . $localtemppath . " 2\>\&1 |"; + my $systemcall = $executable . " sync --verbose -env:BUNDLED_EXTENSIONS_USER=\"file:///" . $bundleddir . "\"" . " -env:UserInstallation=file:///" . $localtemppath . " 2\>\&1 |"; print "... $systemcall\n"; @@ -1090,26 +1148,20 @@ sub do_register_extensions sub register_extensions { - my ($unopkgfile, $extensions, $temppath) = @_; + my ($unopkgfile, $temppath) = @_; - if ( $#{$extensions} > -1 ) - { - print "Registering extensions:\n"; + print "Registering extensions:\n"; - if (( ! -f $unopkgfile ) || ( $unopkgfile eq "" )) - { - print("WARNING: Could not find unopkg.exe (Language Pack?)!\n"); - } - else - { - do_register_extensions($unopkgfile, $extension, $temppath); } - remove_complete_directory($temppath, 1) - } + if (( ! -f $unopkgfile ) || ( $unopkgfile eq "" )) + { + print("WARNING: Could not find unopkg.exe (Language Pack?)!\n"); } else { - print "No extensions to register.\n"; + register_extensions_sync($unopkgfile, $temppath); + remove_complete_directory($temppath, 1); } + } #################################################################################### @@ -1353,7 +1405,7 @@ my ( $filehash, $fileorder, $maxsequence ) = analyze_file_file($filecontent); my $fullpathhash = create_directory_structure($dirhash, $targetdir); # Copying files -my ($unopkgfile, $extensions) = copy_files_into_directory_structure($fileorder, $filehash, $componenthash, $fullpathhash, $maxsequence, $unpackdir, $installdir, $dirhash); +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; @@ -1365,10 +1417,14 @@ $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 = get_extensions_dir($unopkgfile); +if ( -d $extensionfolder ) { remove_empty_dirs_in_folder($extensionfolder, 1); } + if ( $register_extensions_exists ) { # Registering extensions - register_extensions($unopkgfile, $extensions, $temppath); + register_extensions($unopkgfile, $temppath); } # Saving info in Summary Information Stream of msi database (required for following patches) |