From 9c39116015ffd53e532656146ab984c4294bdf65 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Fri, 19 Mar 2010 00:57:13 -0400 Subject: [PATCH] update macos uninstaller make the uninstaller cope with the new receipts format and location FIXES 125634 Change-Id: I6cf0cd3e979a34115f391477657ec37f0c3d8faa Reviewed-on: http://gerrit.openafs.org/1593 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/packaging/MacOS/Uninstall | 55 ++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/packaging/MacOS/Uninstall b/src/packaging/MacOS/Uninstall index 1ca62f7..5364706 100755 --- a/src/packaging/MacOS/Uninstall +++ b/src/packaging/MacOS/Uninstall @@ -90,29 +90,41 @@ sub remove_main_packages # opendir (DIR, $ARGV[0]) or die "ERROR: package directory $ARGV[0] not found\n"; # my @pkglist = grep /\.pkg$/, readdir DIR; # closedir DIR; - my @pkglist = ("OpenAFS", + my @pkglist = ("org.openafs.OpenAFS-debug", + "org.openafs.OpenAFS", + "OpenAFS", + "OpenAFS-debug-extension", ); foreach (@pkglist) { s/\.pkg$//; my $pkgname = $_; - my $pkgname_fullpath = "$receipts_dir/$pkgname.pkg"; - my $pkgname_bom_fullpath = undef; - - next if (! -d "$pkgname_fullpath" ); - - print_verbose ("Removing package $pkgname.pkg\n"); - - my $f = "$pkgname_fullpath/Contents/Resources/$pkgname.bom"; - if (-f $f && -r $f) { - $pkgname_bom_fullpath = $f; - } - - next if (!defined ($pkgname_bom_fullpath)); + my $bompath = undef; + my $infopath = undef; + my $pkgname_plist_newpath = "/var/db/receipts/$pkgname.pkg.plist"; + my $pkgname_bom_newpath = "/var/db/receipts/$pkgname.pkg.bom"; + my $pkgname_plist_fullpath = "/Library/Receipts/$pkgname.pkg/Contents/Info.plist"; + my $pkgname_bom_fullpath = "/Library/Receipts/$pkgname.pkg/Contents/Archive.bom"; + + if (-f $pkgname_plist_newpath && -r $pkgname_plist_newpath && -f $pkgname_bom_newpath && -r $pkgname_bom_newpath) { + print_verbose ("Removing package $pkgname.pkg\n"); + $bompath = $pkgname_bom_newpath; + $infopath = $pkgname_plist_newpath; + } else { + if (-f $pkgname_plist_fullpath && -r $pkgname_plist_fullpath && -f $pkgname_bom_fullpath && -r $pkgname_bom_fullpath) { + print_verbose ("Removing package $pkgname.pkg\n"); + $bompath = $pkgname_bom_fullpath; + $infopath = $pkgname_plist_fullpath; + } else { + next; + } + } + + next if (!defined ($bompath)); my $bomroot = ""; - open (INFO, "$pkgname_fullpath/Contents/Info.plist") or next; + open (INFO, "$infopath") or next; while () { m/IFPkgFlagDefaultLocation/ or next; $bomroot = ; @@ -125,7 +137,7 @@ sub remove_main_packages spin_rate_slow (); - open (LSBOM, "/usr/bin/lsbom -l -f -p f '$pkgname_bom_fullpath' |") or next; + open (LSBOM, "/usr/bin/lsbom -l -f -p f '$bompath' |") or next; while () { chomp; @@ -139,7 +151,7 @@ sub remove_main_packages my $rooth = { }; - open (LSBOM, "/usr/bin/lsbom -d -p f '$pkgname_bom_fullpath' |") or next; + open (LSBOM, "/usr/bin/lsbom -d -p f '$bompath' |") or next; while () { chomp; @@ -163,7 +175,12 @@ sub remove_main_packages spin_rate_fast (); remove_empty_directories ($rooth, "/"); - remove_package_receipts ("$pkgname.pkg") if (!defined ($ARGV[1]) || !$ARGV[1]) ; + if (-d "$receipts_dir/$pkgname.pkg" ) { + remove_package_receipts ("$pkgname.pkg") if (!defined ($ARGV[1]) || !$ARGV[1]) ; + } else { + unshift(@rmfiles, "$bompath"); + unshift(@rmfiles, "$infopath"); + } } } @@ -269,7 +286,7 @@ sub remove_a_file else { unshift(@rmfiles, "$fn"); - unshift(@rmfiles, "$fn") if ( -f $ufs_rsrc_file); + unshift(@rmfiles, "$ufs_rsrc_file") if ( -f $ufs_rsrc_file); } } -- 1.9.4