Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / video / plex-media-player / update.sh
bloba8493a16c989793ecbf7f9014117d1c9edbd3177
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl common-updater-scripts nix-prefetch-scripts jq
4 set -xeuo pipefail
6 nixpkgs="$(git rev-parse --show-toplevel)"
8 oldVersion="$(nix-instantiate --eval -E "with import $nixpkgs {}; plex-media-player.version or (builtins.parseDrvName plex-media-player.name).version" | tr -d '"')"
9 latestTag="$(curl -s https://api.github.com/repos/plexinc/plex-media-player/tags | jq -r '.[] | .name' | sort --version-sort | tail -1)"
10 latestVersion="$(expr $latestTag : 'v\(.*\)-.*')"
11 latestHash="$(expr $latestTag : 'v.*-\(.*\)')"
13 if [ ! "$oldVersion" = "$latestVersion" ]; then
14 # update default.nix with the new version and hash
15 expectedHash=$(nix-prefetch-git --url https://github.com/plexinc/plex-media-player.git --rev $latestTag --quiet | jq -r '.sha256')
16 update-source-version plex-media-player --version-key=vsnHash "${latestHash}" 0000
17 update-source-version plex-media-player "${latestVersion}" $expectedHash
19 # extract the webClientBuildId from the source folder
20 src="$(nix-build --no-out-link $nixpkgs -A plex-media-player.src)"
21 webClientBuildId="$(grep 'set(WEB_CLIENT_BUILD_ID' $src/CMakeModules/WebClient.cmake | cut -d' ' -f2 | tr -d ')')"
23 # retreive the included cmake file and hash
24 { read -r webClientBuildIdHash; read -r webClientBuildIdPath; } < \
25 <(nix-prefetch-url --print-path "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/buildid.cmake")
26 webClientDesktopBuildId="$(grep 'set(DESKTOP_VERSION' $webClientBuildIdPath | cut -d' ' -f2 | tr -d ')')"
27 webClientTvBuildId="$(grep 'set(TV_VERSION' $webClientBuildIdPath | cut -d' ' -f2 | tr -d ')')"
29 # get the hashes for the other files
30 webClientDesktopHash="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-desktop-${webClientDesktopBuildId}.tar.xz.sha1")"
31 webClientDesktop="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-desktop-${webClientDesktopBuildId}.tar.xz")"
32 webClientTvHash="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-tv-${webClientTvBuildId}.tar.xz.sha1")"
33 webClientTv="$(nix-prefetch-url "https://artifacts.plex.tv/web-client-pmp/${webClientBuildId}/web-client-tv-${webClientTvBuildId}.tar.xz")"
35 # update deps.nix
36 cat > $nixpkgs/pkgs/applications/video/plex-media-player/deps.nix <<EOF
37 { fetchurl }:
39 rec {
40 webClientBuildId = "${webClientBuildId}";
41 webClientDesktopBuildId = "${webClientDesktopBuildId}";
42 webClientTvBuildId = "${webClientTvBuildId}";
44 webClient = fetchurl {
45 url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/buildid.cmake";
46 sha256 = "${webClientBuildIdHash}";
48 webClientDesktopHash = fetchurl {
49 url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-desktop-\${webClientDesktopBuildId}.tar.xz.sha1";
50 sha256 = "${webClientDesktopHash}";
52 webClientDesktop = fetchurl {
53 url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-desktop-\${webClientDesktopBuildId}.tar.xz";
54 sha256 = "${webClientDesktop}";
56 webClientTvHash = fetchurl {
57 url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-tv-\${webClientTvBuildId}.tar.xz.sha1";
58 sha256 = "${webClientTvHash}";
60 webClientTv = fetchurl {
61 url = "https://artifacts.plex.tv/web-client-pmp/\${webClientBuildId}/web-client-tv-\${webClientTvBuildId}.tar.xz";
62 sha256 = "${webClientTv}";
65 EOF
67 git add "$nixpkgs"/pkgs/applications/video/plex-media-player/{default,deps}.nix
68 git commit -m "plex-media-player: ${oldVersion} -> ${latestVersion}"
69 else
70 echo "plex-media-player is already up-to-date"