From b54e3ca2d2031ee6e1ec680a27dd13f9e31bbb2d Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Tue, 21 Nov 2023 12:34:28 -0500 Subject: [PATCH] openzfs: update livecheck --- Casks/o/openzfs.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Casks/o/openzfs.rb b/Casks/o/openzfs.rb index b482db7e68..6feacc3c05 100644 --- a/Casks/o/openzfs.rb +++ b/Casks/o/openzfs.rb @@ -71,18 +71,21 @@ cask "openzfs" do livecheck do url "https://openzfsonosx.org/forum/viewforum.php?f=20" - regex(/viewtopic.*t=(\d+).*zfs[._-]macOS[._-]v?(\d+(?:(?:\.)\d+)+)/i) - strategy :page_match do |page| - match = page.scan(regex) - next if match.blank? + regex(/viewtopic[^"' >]*t=(\d+).*zfs[._-]macOS[._-]v?(\d+(?:(?:\.)\d+)+)/i) + strategy :page_match do |page, regex| + # Find the first [stable] release topic on the News forum + post_id, version = page.scan(regex).first + next if post_id.blank? || version.blank? - post_id, version = match.first + # Fetch the release topic page + release_page = Homebrew::Livecheck::Strategy.page_content( + "https://openzfsonosx.org/forum/viewtopic.php?f=20&t=#{post_id}", + ) + next if release_page[:content].blank? - post_url = "https://openzfsonosx.org/forum/viewtopic.php?f=20&t=#{post_id}" + # Find the `id` of the file for the current `arch` download_id_regex = /href=.*file.php\?id=(\d+).+OpenZFSonOsX[._-]v?#{version}[._-]#{arch}\.pkg/i - - download_id = Homebrew::Livecheck::Strategy::PageMatch - .find_versions(url: post_url, regex: download_id_regex)[:matches].values.first + download_id = release_page[:content][download_id_regex, 1] next if download_id.blank? "#{version},#{download_id}"