From 86d1dc9737a73e2034fb60e09c820b4fee64d83a Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Tue, 15 May 2012 20:59:18 +0200 Subject: fdo#48914 uninstall process should remove .pyc files from install directory When install location is writable to user (typical on Windows XP), Python generates .pyc files. We can remove them using the RemoveFile table in MSI. We generate an entry for each .py file in the install set. Change-Id: I314582d52162c6f3ae3acc72de9d620680fb23e0 Signed-off-by: David Tardon --- solenv/bin/make_installer.pl | 8 ++++---- solenv/bin/modules/installer/globals.pm | 1 + solenv/bin/modules/installer/windows/file.pm | 21 ++++++++++++++++++++- solenv/bin/modules/installer/windows/removefile.pm | 8 ++------ 4 files changed, 27 insertions(+), 11 deletions(-) (limited to 'solenv') diff --git a/solenv/bin/make_installer.pl b/solenv/bin/make_installer.pl index 164e08fe3acf..22278b2a6eb2 100644 --- a/solenv/bin/make_installer.pl +++ b/solenv/bin/make_installer.pl @@ -1946,15 +1946,15 @@ for ( my $n = 0; $n <= $#installer::globals::languageproducts; $n++ ) # Collection all available directory trees installer::windows::directory::collectdirectorytrees($directoriesforepmarrayref); - $filesinproductlanguageresolvedarrayref = installer::windows::file::create_files_table($filesinproductlanguageresolvedarrayref, \@allfilecomponents, $newidtdir, $allvariableshashref, $uniquefilename, $allupdatesequences, $allupdatecomponents, $allupdatefileorder); - if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "productfiles17c.log", $filesinproductlanguageresolvedarrayref); } - if ( $installer::globals::updatedatabase ) { installer::windows::file::check_file_sequences($allupdatefileorder, $allupdatecomponentorder); } - # Attention: The table "Director.idt" contains language specific strings -> parameter: $languagesarrayref ! installer::windows::directory::create_directory_table($directoriesforepmarrayref, $languagesarrayref, $newidtdir, $allvariableshashref, $shortdirname, $loggingdir); if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "productfiles18.log", $filesinproductlanguageresolvedarrayref); } if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt1.log", $directoriesforepmarrayref); } + $filesinproductlanguageresolvedarrayref = installer::windows::file::create_files_table($filesinproductlanguageresolvedarrayref, $directoriesforepmarrayref, \@allfilecomponents, $newidtdir, $allvariableshashref, $uniquefilename, $allupdatesequences, $allupdatecomponents, $allupdatefileorder); + if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "productfiles17c.log", $filesinproductlanguageresolvedarrayref); } + if ( $installer::globals::updatedatabase ) { installer::windows::file::check_file_sequences($allupdatefileorder, $allupdatecomponentorder); } + # Attention: The table "Registry.idt" contains language specific strings -> parameter: $languagesarrayref ! installer::windows::registry::create_registry_table($registryitemsinproductlanguageresolvedarrayref, \@allregistrycomponents, $newidtdir, $languagesarrayref, $allvariableshashref); if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "registryitems4.log", $registryitemsinproductlanguageresolvedarrayref); } diff --git a/solenv/bin/modules/installer/globals.pm b/solenv/bin/modules/installer/globals.pm index 9913967f153a..a37116e28d25 100644 --- a/solenv/bin/modules/installer/globals.pm +++ b/solenv/bin/modules/installer/globals.pm @@ -478,6 +478,7 @@ BEGIN @forced_properties = ("SERVICETAG_PRODUCTNAME", "SERVICETAG_PRODUCTVERSION", "SERVICETAG_PARENTNAME", "SERVICETAG_SOURCE", "SERVICETAG_URN"); @removedirs = (); + @removefiletable = (); @emptypackages = (); %fontpackageexists = (); diff --git a/solenv/bin/modules/installer/windows/file.pm b/solenv/bin/modules/installer/windows/file.pm index c4315b43aceb..fc3ea769fac9 100644 --- a/solenv/bin/modules/installer/windows/file.pm +++ b/solenv/bin/modules/installer/windows/file.pm @@ -38,6 +38,7 @@ use installer::worker; use installer::windows::font; use installer::windows::idtglobal; use installer::windows::language; +use installer::windows::component; ########################################################################## # Assigning one cabinet file to each file. This is requrired, @@ -855,7 +856,7 @@ sub collect_shortnames_from_old_database sub create_files_table { - my ($filesref, $allfilecomponentsref, $basedir, $allvariables, $uniquefilenamehashref, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref) = @_; + my ($filesref, $dirref, $allfilecomponentsref, $basedir, $allvariables, $uniquefilenamehashref, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref) = @_; installer::logger::include_timestamp_into_logfile("Performance Info: File Table start"); @@ -883,6 +884,7 @@ sub create_files_table installer::windows::idtglobal::write_idt_header(\@filetable, "file"); installer::windows::idtglobal::write_idt_header(\@filehashtable, "filehash"); + installer::windows::idtglobal::write_idt_header(\@installer::globals::removefiletable, "removefile"); for ( my $i = 0; $i <= $#{$filesref}; $i++ ) { @@ -930,6 +932,23 @@ sub create_files_table push(@filetable, $oneline); + if ( $file{'File'} =~ /\.py$/ ) + { + my %removefile = (); + + $removefile{'FileKey'} = "remove_" . $file{'File'} . "c"; + $removefile{'Component_'} = $file{'Component_'}; + $removefile{'FileName'} = $file{'FileName'}; + $removefile{'FileName'} =~ s/\.py$/.pyc/; + $removefile{'FileName'} =~ s/\.PY\|/.PYC|/; + $removefile{'DirProperty'} = installer::windows::component::get_file_component_directory($file{'Component_'}, $filesref, $dirref); + $removefile{'InstallMode'} = 2; # msiInstallStateAbsent + $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t" + . $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n"; + + push(@installer::globals::removefiletable, $oneline); + } + if ( ! $installer::globals::insert_file_at_end ) { push(@allfiles, $onefile); } # Collecting all component conditions diff --git a/solenv/bin/modules/installer/windows/removefile.pm b/solenv/bin/modules/installer/windows/removefile.pm index ec2a6142db71..294a1afe66fb 100644 --- a/solenv/bin/modules/installer/windows/removefile.pm +++ b/solenv/bin/modules/installer/windows/removefile.pm @@ -107,10 +107,6 @@ sub create_removefile_table { my ($folderitemsref, $basedir) = @_; - my @removefiletable = (); - - installer::windows::idtglobal::write_idt_header(\@removefiletable, "removefile"); - # Only the directories created for the FolderItems have to be deleted # with the information in the table RemoveFile @@ -137,13 +133,13 @@ sub create_removefile_table my $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t" . $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n"; - push(@removefiletable, $oneline); + push(@installer::globals::removefiletable, $oneline); } # Saving the file my $removefiletablename = $basedir . $installer::globals::separator . "RemoveFi.idt"; - installer::files::save_file($removefiletablename ,\@removefiletable); + installer::files::save_file($removefiletablename ,\@installer::globals::removefiletable); my $infoline = "Created idt file: $removefiletablename\n"; push(@installer::globals::logfileinfo, $infoline); -- cgit v1.2.3