From 80e09c8dec623dd72872e154daad7229a8df6f8c Mon Sep 17 00:00:00 2001
From: Markus Reiter <me@reitermark.us>
Date: Fri, 21 Apr 2017 15:50:39 +0200
Subject: [PATCH] =?UTF-8?q?Partly=20revert=20=E2=80=9CFix=20`uninstall=20:?=
 =?UTF-8?q?pkgutil`=20leaving=20empty=20`.app`=20directories.=E2=80=9D.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Library/Homebrew/cask/lib/hbc/pkg.rb   | 7 +++++--
 Library/Homebrew/test/cask/pkg_spec.rb | 9 +++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb
index 902d564494..c9aa3180f1 100644
--- a/Library/Homebrew/cask/lib/hbc/pkg.rb
+++ b/Library/Homebrew/cask/lib/hbc/pkg.rb
@@ -63,7 +63,10 @@ module Hbc
     end
 
     def pkgutil_bom_all
-      @pkgutil_bom_all ||= info.fetch("paths").keys.map { |p| root.join(p) }
+      @pkgutil_bom_all ||= @command.run!("/usr/sbin/pkgutil", args: ["--files", package_id])
+                                   .stdout
+                                   .split("\n")
+                                   .map { |path| root.join(path) }
     end
 
     def root
@@ -71,7 +74,7 @@ module Hbc
     end
 
     def info
-      @info ||= @command.run!("/usr/sbin/pkgutil", args: ["--export-plist", package_id])
+      @info ||= @command.run!("/usr/sbin/pkgutil", args: ["--pkg-info-plist", package_id])
                         .plist
     end
 
diff --git a/Library/Homebrew/test/cask/pkg_spec.rb b/Library/Homebrew/test/cask/pkg_spec.rb
index 9930cd00ff..e507ceda01 100644
--- a/Library/Homebrew/test/cask/pkg_spec.rb
+++ b/Library/Homebrew/test/cask/pkg_spec.rb
@@ -36,7 +36,12 @@ describe Hbc::Pkg, :cask do
       it "forgets the pkg" do
         allow(fake_system_command).to receive(:run!).with(
           "/usr/sbin/pkgutil",
-          args: ["--export-plist", "my.fake.pkg"],
+          args: ["--pkg-info-plist", "my.fake.pkg"],
+        ).and_return(empty_response)
+
+        expect(fake_system_command).to receive(:run!).with(
+          "/usr/sbin/pkgutil",
+          args: ["--files", "my.fake.pkg"],
         ).and_return(empty_response)
 
         expect(fake_system_command).to receive(:run!).with(
@@ -139,7 +144,7 @@ describe Hbc::Pkg, :cask do
 
       expect(fake_system_command).to receive(:run!).with(
         "/usr/sbin/pkgutil",
-      args: ["--export-plist", pkg_id],
+      args: ["--pkg-info-plist", pkg_id],
       ).and_return(
         Hbc::SystemCommand::Result.new(nil, pkg_info_plist, nil, 0),
       )
-- 
GitLab