Kaydet (Commit) 7172f697 authored tarafından Joerg Skottke [jsk]'s avatar Joerg Skottke [jsk]

jl154: Local merge

...@@ -298,6 +298,69 @@ sub get_sourcepath_from_filename_and_includepath ...@@ -298,6 +298,69 @@ sub get_sourcepath_from_filename_and_includepath
return \$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 # Finding all files with a specified file extension
# in a specified directory. # in a specified directory.
...@@ -880,7 +943,6 @@ sub copy_files_into_directory_structure ...@@ -880,7 +943,6 @@ sub copy_files_into_directory_structure
print "Copying files\n"; print "Copying files\n";
my $unopkgfile = ""; my $unopkgfile = "";
my @extensions = ();
for ( my $i = 1; $i <= $maxsequence; $i++ ) for ( my $i = 1; $i <= $maxsequence; $i++ )
{ {
...@@ -923,8 +985,6 @@ sub copy_files_into_directory_structure ...@@ -923,8 +985,6 @@ sub copy_files_into_directory_structure
if ( ! $copyreturn) { exit_program("ERROR: Could not copy $source to $dest\n"); } 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 # Searching unopkg.exe
if ( $destfile =~ /unopkg\.exe\s*$/ ) { $unopkgfile = $destfile; } if ( $destfile =~ /unopkg\.exe\s*$/ ) { $unopkgfile = $destfile; }
# if (( $^O =~ /cygwin/i ) && ( $destfile =~ /\.exe\s*$/ )) { change_privileges($destfile, "775"); } # if (( $^O =~ /cygwin/i ) && ( $destfile =~ /\.exe\s*$/ )) { change_privileges($destfile, "775"); }
...@@ -935,7 +995,7 @@ sub copy_files_into_directory_structure ...@@ -935,7 +995,7 @@ sub copy_files_into_directory_structure
# } # }
} }
return ($unopkgfile, \@extensions); return ($unopkgfile);
} }
###################################################### ######################################################
...@@ -1026,12 +1086,19 @@ sub get_temppath ...@@ -1026,12 +1086,19 @@ sub get_temppath
} }
#################################################################################### ####################################################################################
# Registering one extension # Registering extensions
#################################################################################### ####################################################################################
sub register_one_extension sub register_extensions_sync
{ {
my ($unopkgfile, $extension, $temppath) = @_; 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 $from = cwd();
...@@ -1051,22 +1118,17 @@ sub register_one_extension ...@@ -1051,22 +1118,17 @@ sub register_one_extension
$path_displayed = 1; $path_displayed = 1;
} }
$temppath =~ s/\\/\//g; $localtemppath =~ s/\\/\//g;
$temppath = "/".$temppath;
# 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 ) { if ( $^O =~ /cygwin/i ) {
$executable = "./" . $executable; $executable = "./" . $executable;
$preregdir = qx{cygpath -m "$preregdir"};
chomp($preregdir);
} }
my $systemcall = $executable . " add --shared --verbose --suppress-license " . "\"" . $localextension . "\"" . " -env:UserInstallation=file://" . $temppath . " 2\>\&1 |"; $preregdir =~ s/\/\s*$//g;
my $systemcall = $executable . " sync --verbose -env:BUNDLED_EXTENSIONS_USER=\"file:///" . $preregdir . "\"" . " -env:UserInstallation=file:///" . $localtemppath . " 2\>\&1 |";
print "... $systemcall\n"; print "... $systemcall\n";
...@@ -1094,10 +1156,8 @@ sub register_one_extension ...@@ -1094,10 +1156,8 @@ sub register_one_extension
sub register_extensions sub register_extensions
{ {
my ($unopkgfile, $extensions, $temppath) = @_; my ($unopkgfile, $temppath, $preregdir) = @_;
if ( $#{$extensions} > -1 )
{
print "Registering extensions:\n"; print "Registering extensions:\n";
if (( ! -f $unopkgfile ) || ( $unopkgfile eq "" )) if (( ! -f $unopkgfile ) || ( $unopkgfile eq "" ))
...@@ -1106,14 +1166,10 @@ sub register_extensions ...@@ -1106,14 +1166,10 @@ sub register_extensions
} }
else else
{ {
foreach $extension ( @{$extensions} ) { register_one_extension($unopkgfile, $extension, $temppath); } register_extensions_sync($unopkgfile, $temppath, $preregdir);
remove_complete_directory($temppath, 1) remove_complete_directory($temppath, 1);
}
}
else
{
print "No extensions to register.\n";
} }
} }
#################################################################################### ####################################################################################
...@@ -1357,7 +1413,7 @@ my ( $filehash, $fileorder, $maxsequence ) = analyze_file_file($filecontent); ...@@ -1357,7 +1413,7 @@ my ( $filehash, $fileorder, $maxsequence ) = analyze_file_file($filecontent);
my $fullpathhash = create_directory_structure($dirhash, $targetdir); my $fullpathhash = create_directory_structure($dirhash, $targetdir);
# Copying files # 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); } if ( $^O =~ /cygwin/i ) { change_privileges_full($targetdir); }
my $msidatabase = $targetdir . $separator . $databasefilename; my $msidatabase = $targetdir . $separator . $databasefilename;
...@@ -1369,10 +1425,14 @@ $filename = $helperdir . $separator . "CustomAction.idt"; ...@@ -1369,10 +1425,14 @@ $filename = $helperdir . $separator . "CustomAction.idt";
$filecontent = read_file($filename); $filecontent = read_file($filename);
my $register_extensions_exists = analyze_customaction_file($filecontent); 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 ) if ( $register_extensions_exists )
{ {
# Registering extensions # Registering extensions
register_extensions($unopkgfile, $extensions, $temppath); register_extensions($unopkgfile, $temppath, $preregdir);
} }
# Saving info in Summary Information Stream of msi database (required for following patches) # Saving info in Summary Information Stream of msi database (required for following patches)
......
DO NOT DELETE THIS FILE
\ No newline at end of file
...@@ -2,3 +2,5 @@ SetProductInstallationPath ...@@ -2,3 +2,5 @@ SetProductInstallationPath
RegisterLanguagePack RegisterLanguagePack
GetUserInstallMode GetUserInstallMode
IsOfficeRunning IsOfficeRunning
RegisterExtensions
...@@ -77,6 +77,7 @@ STDSHL+= \ ...@@ -77,6 +77,7 @@ STDSHL+= \
#SHL1LIBS = $(SLB)$/$(TARGET).lib #SHL1LIBS = $(SLB)$/$(TARGET).lib
SHL1OBJS = $(SLOFILES) \ SHL1OBJS = $(SLOFILES) \
$(SLO)$/registerextensions.obj \
$(SLO)$/seterror.obj $(SLO)$/seterror.obj
SHL1TARGET = $(TARGET) SHL1TARGET = $(TARGET)
......
...@@ -7,3 +7,5 @@ IsOfficeRunning ...@@ -7,3 +7,5 @@ IsOfficeRunning
SetFeatureState SetFeatureState
SetNewFeatureState SetNewFeatureState
ShowOnlineUpdateDialog ShowOnlineUpdateDialog
RegisterExtensions
RemoveExtensions
...@@ -76,6 +76,7 @@ SHL1OBJS = $(SLOFILES) \ ...@@ -76,6 +76,7 @@ SHL1OBJS = $(SLOFILES) \
$(SLO)$/shutdown_quickstart.obj \ $(SLO)$/shutdown_quickstart.obj \
$(SLO)$/quickstarter.obj \ $(SLO)$/quickstarter.obj \
$(SLO)$/upgrade.obj \ $(SLO)$/upgrade.obj \
$(SLO)$/registerextensions.obj \
$(SLO)$/seterror.obj $(SLO)$/seterror.obj
SHL1TARGET = $(TARGET) SHL1TARGET = $(TARGET)
......
...@@ -7,6 +7,8 @@ RebuildShellIconCache ...@@ -7,6 +7,8 @@ RebuildShellIconCache
ExecutePostUninstallScript ExecutePostUninstallScript
CompleteInstallPath CompleteInstallPath
MigrateInstallPath MigrateInstallPath
RegisterExtensions
RemoveExtensions
CheckInstallDirectory CheckInstallDirectory
SetAdminInstallProperty SetAdminInstallProperty
CreateLayerLinks CreateLayerLinks
......
...@@ -63,6 +63,7 @@ SLOFILES = \ ...@@ -63,6 +63,7 @@ SLOFILES = \
$(SLO)$/setadmininstall.obj \ $(SLO)$/setadmininstall.obj \
$(SLO)$/layerlinks.obj \ $(SLO)$/layerlinks.obj \
$(SLO)$/dotnetcheck.obj \ $(SLO)$/dotnetcheck.obj \
$(SLO)$/registerextensions.obj \
$(SLO)$/copyeditiondata.obj \ $(SLO)$/copyeditiondata.obj \
$(SLO)$/vistaspecial.obj \ $(SLO)$/vistaspecial.obj \
$(SLO)$/checkrunningoffice.obj \ $(SLO)$/checkrunningoffice.obj \
......
...@@ -319,203 +319,57 @@ extern "C" UINT __stdcall RegisterExtensions(MSIHANDLE handle) ...@@ -319,203 +319,57 @@ extern "C" UINT __stdcall RegisterExtensions(MSIHANDLE handle)
{ {
std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
std::_tstring sUnoPkgFile = sInstDir + TEXT("program\\unopkg.exe"); std::_tstring sUnoPkgFile = sInstDir + TEXT("program\\unopkg.exe");
std::_tstring sShareInstallDir = sInstDir + TEXT("share\\extension\\install\\");
std::_tstring sPattern = sShareInstallDir + TEXT("*.oxt");
std::_tstring mystr; std::_tstring mystr;
WIN32_FIND_DATA aFindFileData; WIN32_FIND_DATA aFindFileData;
mystr = "unopkg file: " + sUnoPkgFile; mystr = "unopkg file: " + sUnoPkgFile;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK); //MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
mystr = "oxt file directory: " + sShareInstallDir;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// Find unopkg.exe
HANDLE hFindUnopkg = FindFirstFile( sUnoPkgFile.c_str(), &aFindFileData );
if ( hFindUnopkg != INVALID_HANDLE_VALUE )
{
// unopkg.exe exists in program directory
// Finding all oxt files in sShareInstallDir
HANDLE hFindOxt = FindFirstFile( sPattern.c_str(), &aFindFileData );
if ( hFindOxt != INVALID_HANDLE_VALUE )
{
bool fNextFile = false;
do
{
const std::_tstring sTempFolder(createTempFolder());
std::_tstring sOxtFile = sShareInstallDir + aFindFileData.cFileName;
std::_tstring sCommandPart1 = sUnoPkgFile + " add --shared --suppress-license --bundled " + "\"" + sOxtFile + "\"";
std::_tstring sCommand = sCommandPart1
+ TEXT(" -env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml")
+ TEXT(" -env:UserInstallation=") + sTempFolder;
mystr = "Command: " + sCommand;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
DWORD exitCode = 0;
bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
// unopkg in OOo 2.2.1 and early had a bug that it failed when receiving
// a bootstrap parameter (-env:...) then it exited with a value != 0.
if (fSuccess && exitCode != 0)
{
std::_tstring sCommand = sCommandPart1;
mystr = "Command: " + sCommand;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
}
deleteTempFolder(sTempFolder);
// if ( fSuccess )
// {
// mystr = "Executed successfully!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
// else
// {
// mystr = "An error occured during execution!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
fNextFile = FindNextFile( hFindOxt, &aFindFileData );
} while ( fNextFile );
FindClose( hFindOxt );
}
}
// else
// {
// mystr = "Error: Did not find " + sUnoPkgFile;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
return ERROR_SUCCESS;
}
extern "C" UINT __stdcall DeregisterExtensions(MSIHANDLE handle)
{
std::_tstring mystr;
// Finding the product with the help of the propery FINDPRODUCT,
// that contains a Windows Registry key, that points to the install location.
TCHAR szValue[8192];
DWORD nValueSize = sizeof(szValue);
HKEY hKey;
std::_tstring sInstDir;
std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") );
// MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK );
if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) )
{
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
{
sInstDir = szValue;
}
RegCloseKey( hKey );
}
else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) )
{
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
{
sInstDir = szValue;
}
RegCloseKey( hKey );
}
else
{
return ERROR_SUCCESS;
}
// MessageBox( NULL, sInstDir.c_str(), "install location", MB_OK );
// Searching for the unopkg.exe
std::_tstring sUnoPkgFile = sInstDir + TEXT("program\\unopkg.exe");
std::_tstring sShareInstallDir = sInstDir + TEXT("share\\extension\\install\\");
std::_tstring sPattern = sShareInstallDir + TEXT("*.oxt");
WIN32_FIND_DATA aFindFileData;
// Find unopkg.exe // Find unopkg.exe
HANDLE hFindUnopkg = FindFirstFile( sUnoPkgFile.c_str(), &aFindFileData ); HANDLE hFindUnopkg = FindFirstFile( sUnoPkgFile.c_str(), &aFindFileData );
if ( hFindUnopkg != INVALID_HANDLE_VALUE ) if ( hFindUnopkg != INVALID_HANDLE_VALUE )
{ {
// unopkg.exe exists in program directory // unopkg.exe exists in program directory
// Finding all oxt files in sShareInstallDir
HANDLE hFindOxt = FindFirstFile( sPattern.c_str(), &aFindFileData );
if ( hFindOxt != INVALID_HANDLE_VALUE )
{
bool fNextFile = false;
do
{
const std::_tstring sTempFolder(createTempFolder()); const std::_tstring sTempFolder(createTempFolder());
// When removing extensions, only the oxt file name is required, without path std::_tstring sCommandPart1 = sUnoPkgFile + " sync";
// Therefore no quoting is required
// std::_tstring sOxtFile = sShareInstallDir + aFindFileData.cFileName;
std::_tstring sOxtFile = aFindFileData.cFileName;
std::_tstring sCommandPart1 = sUnoPkgFile + " remove --shared --bundled " + "\""
+ sOxtFile + "\"";
std::_tstring sCommand = sCommandPart1 std::_tstring sCommand = sCommandPart1
+ TEXT(" -env:BUNDLED_EXTENSIONS_USER=$BRAND_BASE_DIR/share/prereg/bundled")
+ TEXT(" -env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml") + TEXT(" -env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml")
+ TEXT(" -env:UserInstallation=") + sTempFolder; + TEXT(" -env:UserInstallation=") + sTempFolder;
mystr = "Command: " + sCommand; mystr = "Command: " + sCommand;
//MessageBox(NULL, mystr.c_str(), "Command", MB_OK); //MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
DWORD exitCode = 0; DWORD exitCode = 0;
bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode); bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
// unopkg in OOo 2.2.1 and early had a bug that it failed when receiving
// a bootstrap parameter (-env:...) then it exited with a value != 0.
if (fSuccess && exitCode != 0)
{
std::_tstring sCommand = sCommandPart1;
mystr = "Command: " + sCommand;
//MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode);
}
deleteTempFolder(sTempFolder); deleteTempFolder(sTempFolder);
if ( fSuccess ) // if ( fSuccess )
{ // {
mystr = "Executed successfully!"; // mystr = "Executed successfully!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK); // MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
} // }
else // else
{ // {
mystr = "An error occured during execution!"; // mystr = "An error occured during execution!";
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK); // MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
} // }
fNextFile = FindNextFile( hFindOxt, &aFindFileData ); FindClose( hFindUnopkg );
}
} while ( fNextFile ); // else
// {
FindClose( hFindOxt ); // mystr = "Error: Did not find " + sUnoPkgFile;
} // MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
} // }
// else
// {
// mystr = "Not found: " + sUnoPkgFile;
// MessageBox(NULL, mystr.c_str(), "Command", MB_OK);
// }
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle)
{ {
std::_tstring mystr; std::_tstring mystr;
...@@ -529,7 +383,7 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) ...@@ -529,7 +383,7 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle)
std::_tstring sInstDir; std::_tstring sInstDir;
std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") ); std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") );
// MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK ); //MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK );
if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) )
{ {
...@@ -552,22 +406,22 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) ...@@ -552,22 +406,22 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle)
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
// Removing complete directory "share\uno_packages\cache" // Removing complete directory "Basis\presets\bundled"
std::_tstring sCacheDir = sInstDir + TEXT("share\\uno_packages\\cache"); std::_tstring sCacheDir = sInstDir + TEXT("share\\prereg\\bundled");
bool fSuccess = RemoveCompleteDirectory( sCacheDir ); bool fSuccess = RemoveCompleteDirectory( sCacheDir );
if ( fSuccess ) // if ( fSuccess )
{ // {
mystr = "Executed successfully!"; // mystr = "Executed successfully!";
// MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK); // MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK);
} // }
else // else
{ // {
mystr = "An error occured during execution!"; // mystr = "An error occured during execution!";
// MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK); // MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK);
} // }
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment