aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/applications/video/plex-media-player/update.sh
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/applications/video/plex-media-player/update.sh
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/applications/video/plex-media-player/update.sh')
-rwxr-xr-xinfra/libkookie/nixpkgs/pkgs/applications/video/plex-media-player/update.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/video/plex-media-player/update.sh b/infra/libkookie/nixpkgs/pkgs/applications/video/plex-media-player/update.sh
new file mode 100755
index 000000000000..a8493a16c989
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/applications/video/plex-media-player/update.sh
@@ -0,0 +1,71 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl common-updater-scripts nix-prefetch-scripts jq
+
+set -xeuo pipefail
+
+nixpkgs="$(git rev-parse --show-toplevel)"
+
+oldVersion="$(nix-instantiate --eval -E "with import $nixpkgs {}; plex-media-player.version or (builtins.parseDrvName plex-media-player.name).version" | tr -d '"')"
+latestTag="$(curl -s https://api.github.com/repos/plexinc/plex-media-player/tags | jq -r '.[] | .name' | sort --version-sort | tail -1)"
+latestVersion="$(expr $latestTag : 'v\(.*\)-.*')"
+latestHash="$(expr $latestTag : 'v.*-\(.*\)')"
+
+if [ ! "$oldVersion" = "$latestVersion" ]; then
+ # update default.nix with the new version and hash
+ expectedHash=$(nix-prefetch-git --url https://github.com/plexinc/plex-media-player.git --rev $latestTag --quiet | jq -r '.sha256')
+ update-source-version plex-media-player --version-key=vsnHash "${latestHash}" 0000
+ update-source-version plex-media-player "${latestVersion}" $expectedHash
+
+ # extract the webClientBuildId from the source folder
+ src="$(nix-build --no-out-link $nixpkgs -A plex-media-player.src)"
+ webClientBuildId="$(grep 'set(WEB_CLIENT_BUILD_ID' $src/CMakeModules/WebClient.cmake | cut -d' ' -f2 | tr -d ')')"
+
+ # retreive the included cmake file and hash
+ { read -r webClientBuildIdHash; read -r webClientBuildIdPath; } < \
+ <(nix-prefetch-url --print-path "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/buildid.cmake")
+ webClientDesktopBuildId="$(grep 'set(DESKTOP_VERSION' $webClientBuildIdPath | cut -d' ' -f2 | tr -d ')')"
+ webClientTvBuildId="$(grep 'set(TV_VERSION' $webClientBuildIdPath | cut -d' ' -f2 | tr -d ')')"
+
+ # get the hashes for the other files
+ webClientDesktopHash="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-desktop-${webClientDesktopBuildId}.tar.xz.sha1")"
+ webClientDesktop="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-desktop-${webClientDesktopBuildId}.tar.xz")"
+ webClientTvHash="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-tv-${webClientTvBuildId}.tar.xz.sha1")"
+ webClientTv="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-tv-${webClientTvBuildId}.tar.xz")"
+
+ # update deps.nix
+ cat > $nixpkgs/pkgs/applications/video/plex-media-player/deps.nix <<EOF
+{ fetchurl }:
+
+rec {
+ webClientBuildId = "${webClientBuildId}";
+ webClientDesktopBuildId = "${webClientDesktopBuildId}";
+ webClientTvBuildId = "${webClientTvBuildId}";
+
+ webClient = fetchurl {
+ url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/buildid.cmake";
+ sha256 = "${webClientBuildIdHash}";
+ };
+ webClientDesktopHash = fetchurl {
+ url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-desktop-\${webClientDesktopBuildId}.tar.xz.sha1";
+ sha256 = "${webClientDesktopHash}";
+ };
+ webClientDesktop = fetchurl {
+ url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-desktop-\${webClientDesktopBuildId}.tar.xz";
+ sha256 = "${webClientDesktop}";
+ };
+ webClientTvHash = fetchurl {
+ url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-tv-\${webClientTvBuildId}.tar.xz.sha1";
+ sha256 = "${webClientTvHash}";
+ };
+ webClientTv = fetchurl {
+ url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-tv-\${webClientTvBuildId}.tar.xz";
+ sha256 = "${webClientTv}";
+ };
+}
+EOF
+
+ git add "$nixpkgs"/pkgs/applications/video/plex-media-player/{default,deps}.nix
+ git commit -m "plex-media-player: ${oldVersion} -> ${latestVersion}"
+else
+ echo "plex-media-player is already up-to-date"
+fi