forked from mirrors/nixpkgs
Merge pull request #105166 from SamirHafez/plex-updateScript
plex: Add an updateScript
This commit is contained in:
commit
eb079d22f8
|
@ -1,6 +1,10 @@
|
|||
{ stdenv
|
||||
, fetchurl
|
||||
, dpkg
|
||||
, writeScript
|
||||
, curl
|
||||
, jq
|
||||
, common-updater-scripts
|
||||
}:
|
||||
|
||||
# The raw package that fetches and extracts the Plex RPM. Override the source
|
||||
|
@ -52,6 +56,27 @@ stdenv.mkDerivation rec {
|
|||
dontPatchELF = true;
|
||||
dontAutoPatchelf = true;
|
||||
|
||||
passthru.updateScript = writeScript "${pname}-updater" ''
|
||||
#!${stdenv.shell}
|
||||
set -eu -o pipefail
|
||||
PATH=${stdenv.lib.makeBinPath [curl jq common-updater-scripts]}:$PATH
|
||||
|
||||
plexApiJson=$(curl -sS https://plex.tv/api/downloads/5.json)
|
||||
latestVersion="$(echo $plexApiJson | jq .computer.Linux.version | tr -d '"\n')"
|
||||
|
||||
for platform in ${stdenv.lib.concatStringsSep " " meta.platforms}; do
|
||||
arch=$(echo $platform | cut -d '-' -f1)
|
||||
dlUrl="$(echo $plexApiJson | jq --arg arch "$arch" -c '.computer.Linux.releases[] | select(.distro == "debian") | select(.build | contains($arch)) .url' | tr -d '"\n')"
|
||||
|
||||
latestSha="$(nix-prefetch-url $dlUrl)"
|
||||
|
||||
# The script will not perform an update when the version attribute is up to date from previous platform run
|
||||
# We need to clear it before each run
|
||||
update-source-version plexRaw 0 $(yes 0 | head -64 | tr -d "\n") --system=$platform
|
||||
update-source-version plexRaw "$latestVersion" "$latestSha" --system=$platform
|
||||
done
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
homepage = "https://plex.tv/";
|
||||
license = licenses.unfree;
|
||||
|
|
Loading…
Reference in a new issue