From ed9d88e5ee5dd5aa71c807c6f60c9c5cf58d3676 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 3 Oct 2024 14:04:25 -0400 Subject: [PATCH] makemkv: add updateScript We exit early when the versions are the same to avoid unnecessary work in the second `update-source-version` call that has `--ignore-same-version`. That arg is necessary as otherwise it becomes a no-op since the version was updated in the previous `update-source-version` invocation. --- pkgs/applications/video/makemkv/default.nix | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkgs/applications/video/makemkv/default.nix b/pkgs/applications/video/makemkv/default.nix index e1a6162a8794..69e90d8c94e2 100644 --- a/pkgs/applications/video/makemkv/default.nix +++ b/pkgs/applications/video/makemkv/default.nix @@ -1,5 +1,6 @@ { autoPatchelfHook, + common-updater-scripts, curl, fetchurl, ffmpeg, @@ -8,6 +9,8 @@ openssl, pkg-config, qtbase, + rubyPackages, + writeShellApplication, zlib, withJava ? true, @@ -83,6 +86,35 @@ mkDerivation { runHook postInstall ''; + passthru = { + srcs = { + inherit src_bin src_oss; + }; + updateScript = lib.getExe (writeShellApplication { + name = "update-makemkv"; + runtimeInputs = [ + common-updater-scripts + curl + rubyPackages.nokogiri + ]; + text = '' + get_version() { + # shellcheck disable=SC2016 + curl --fail --silent 'https://forum.makemkv.com/forum/viewtopic.php?f=3&t=224' \ + | nokogiri -e 'puts $_.css("head title").first.text.match(/\bMakeMKV (\d+\.\d+\.\d+) /)[1]' + } + oldVersion=${lib.escapeShellArg version} + newVersion=$(get_version) + if [[ $oldVersion == $newVersion ]]; then + echo "$0: New version same as old version, nothing to do." >&2 + exit + fi + update-source-version makemkv "$newVersion" --source-key=passthru.srcs.src_bin + update-source-version makemkv "$newVersion" --source-key=passthru.srcs.src_oss --ignore-same-version + ''; + }); + }; + meta = with lib; { description = "Convert blu-ray and dvd to mkv"; longDescription = ''