update macos uninstaller
authorDerrick Brashear <shadow@dementia.org>
Fri, 19 Mar 2010 04:57:13 +0000 (00:57 -0400)
committerDerrick Brashear <shadow@dementia.org>
Fri, 19 Mar 2010 05:11:55 +0000 (22:11 -0700)
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 <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/packaging/MacOS/Uninstall

index 1ca62f7..5364706 100755 (executable)
@@ -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 (<INFO>) {
             m/IFPkgFlagDefaultLocation/ or next;
             $bomroot = <INFO>;
@@ -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 (<LSBOM>)
           {
             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 (<LSBOM>)
           {
             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);
       }
   }