From a2a4bef78c0c879a2bbf00d20289764cf51558e9 Mon Sep 17 00:00:00 2001 From: les Date: Thu, 10 Sep 2026 17:44:54 -0700 Subject: [PATCH] fix(cask): replace uninstall_postflight with uninstall_postflight_steps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The legacy `uninstall_postflight` block is deprecated and prints a warning on every uninstall: Warning: Calling uninstall_postflight is deprecated! Use uninstall_postflight_steps instead. `uninstall_postflight_steps` requires structured step calls with literal arguments — no arbitrary Ruby. This commit: * swaps the deprecated block for `uninstall_postflight_steps` * replaces `binaries.each` / `File.readlink().include?("redis-stack")` with one `remove ... symlink_target_contains: "redis-stack"` per binary * replaces `Dir[...] / File.basename / File.delete` with a single `remove ".../lib/*.so", symlink_target_contains: "redis-stack"` * uses the `{{HOMEBREW_PREFIX}}` template syntax (steps-DSL requires this in place of Ruby interpolation `#{HOMEBREW_PREFIX}`) Behavior is preserved: only symlinks whose target references the caskroom are removed, leaving any user-installed binaries/libraries at the same path untouched. The `postflight` block on the install side is also deprecated for the same reason but requires a larger refactor (Dir[] glob, File.symlink loops, FileUtils.cp unless-exist); left for a follow-up. --- Casks/redis-stack-server.rb | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Casks/redis-stack-server.rb b/Casks/redis-stack-server.rb index 16b5f20..ef44ff1 100644 --- a/Casks/redis-stack-server.rb +++ b/Casks/redis-stack-server.rb @@ -40,22 +40,22 @@ end end - uninstall_postflight do - basepath = HOMEBREW_PREFIX.to_s - - binaries.each do |item| - dest = "#{basepath}/bin/#{item}" - next unless File.exist?(dest) - - File.delete(dest) if File.readlink(dest).include?("redis-stack") - end - - # unlink libraries - caskbase = "#{caskroom_path}/#{version}" - Dir["#{caskbase}/lib/*.so"].each do |item| - lib = File.basename(item) - destlib = "#{basepath}/lib/#{lib}" - File.delete(destlib) - end + uninstall_postflight_steps do + # Only remove a binary symlink if it actually points into the caskroom — + # mirrors the original File.readlink().include?("redis-stack") check. + # Paths use the {{HOMEBREW_PREFIX}} template (not Ruby interpolation), + # which the steps DSL substitutes at load time. + remove "{{HOMEBREW_PREFIX}}/bin/redis-cli", symlink_target_contains: "redis-stack" + remove "{{HOMEBREW_PREFIX}}/bin/redis-benchmark", symlink_target_contains: "redis-stack" + remove "{{HOMEBREW_PREFIX}}/bin/redis-check-aof", symlink_target_contains: "redis-stack" + remove "{{HOMEBREW_PREFIX}}/bin/redis-check-rdb", symlink_target_contains: "redis-stack" + remove "{{HOMEBREW_PREFIX}}/bin/redis-sentinel", symlink_target_contains: "redis-stack" + remove "{{HOMEBREW_PREFIX}}/bin/redis-server", symlink_target_contains: "redis-stack" + remove "{{HOMEBREW_PREFIX}}/bin/redis-stack-server", symlink_target_contains: "redis-stack" + + # The postflight symlinks every .so from caskroom into {{HOMEBREW_PREFIX}}/lib. + # Only remove the symlinks whose target references redis-stack so any + # user-installed libraries at the same path are preserved. + remove "{{HOMEBREW_PREFIX}}/lib/*.so", symlink_target_contains: "redis-stack" end end