blackmagic-desktop-video: add updateScript
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
{
|
||||
stdenv,
|
||||
cacert,
|
||||
curl,
|
||||
runCommandLocal,
|
||||
lib,
|
||||
autoPatchelfHook,
|
||||
libcxx,
|
||||
libGL,
|
||||
cacert,
|
||||
common-updater-scripts,
|
||||
curl,
|
||||
gcc,
|
||||
jq,
|
||||
lib,
|
||||
libGL,
|
||||
libcxx,
|
||||
runCommandLocal,
|
||||
stdenv,
|
||||
writeShellApplication,
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "blackmagic-desktop-video";
|
||||
version = "14.4.1a4";
|
||||
version = "14.4.1";
|
||||
|
||||
buildInputs = [
|
||||
autoPatchelfHook
|
||||
@@ -23,12 +26,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# yes, the below download function is an absolute mess.
|
||||
# blame blackmagicdesign.
|
||||
src =
|
||||
let
|
||||
# from the URL the download page where you click the "only download" button is at
|
||||
REFERID = "5baba0af3eda41ee9cd0ec7349660d74";
|
||||
# from the URL that the POST happens to, see browser console
|
||||
DOWNLOADID = "bc31044728f146859c6d9e0ccef868d8";
|
||||
in
|
||||
runCommandLocal "${finalAttrs.pname}-${lib.versions.majorMinor finalAttrs.version}-src.tar.gz"
|
||||
{
|
||||
outputHashMode = "recursive";
|
||||
@@ -37,13 +34,15 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
||||
|
||||
nativeBuildInputs = [ curl ];
|
||||
nativeBuildInputs = [
|
||||
curl
|
||||
jq
|
||||
];
|
||||
|
||||
# ENV VARS
|
||||
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
|
||||
inherit REFERID;
|
||||
SITEURL = "https://www.blackmagicdesign.com/api/register/us/download/${DOWNLOADID}";
|
||||
DOWNLOADSURL = "https://www.blackmagicdesign.com/api/support/us/downloads.json";
|
||||
|
||||
USERAGENT = builtins.concatStringsSep " " [
|
||||
"User-Agent: Mozilla/5.0 (X11; Linux ${stdenv.hostPlatform.linuxArch})"
|
||||
@@ -58,8 +57,24 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"platform" = "Linux";
|
||||
"policy" = true;
|
||||
};
|
||||
|
||||
PRODUCT = "Desktop Video";
|
||||
VERSION = finalAttrs.version;
|
||||
}
|
||||
''
|
||||
DOWNLOADID=$(
|
||||
curl --silent --compressed "$DOWNLOADSURL" \
|
||||
| jq --raw-output '.downloads[] | .urls.Linux?[]? | select(.downloadTitle | test("^'"$PRODUCT $VERSION"'( Update)?$")) | .downloadId'
|
||||
)
|
||||
REFERID=$(
|
||||
curl --silent --compressed "$DOWNLOADSURL" \
|
||||
| jq --raw-output '.downloads[] | .urls.Linux?[]? | select(.downloadTitle | test("^'"$PRODUCT $VERSION"'( Update)?$")) | .releaseId'
|
||||
)
|
||||
echo "Download ID is $DOWNLOADID"
|
||||
echo "Refer ID is $REFERID"
|
||||
test -n "$REFERID"
|
||||
test -n "$DOWNLOADID"
|
||||
SITEURL="https://www.blackmagicdesign.com/api/register/us/download/$DOWNLOADID";
|
||||
RESOLVEURL=$(curl \
|
||||
-s \
|
||||
-H "$USERAGENT" \
|
||||
@@ -75,13 +90,30 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
> $out
|
||||
'';
|
||||
|
||||
passthru.updateScript = lib.getExe (writeShellApplication {
|
||||
# mostly stolen from pkgs/by-name/da/davinci-resolve/package.nix :)
|
||||
name = "update-blackmagic-desktop-video";
|
||||
runtimeInputs = [
|
||||
common-updater-scripts
|
||||
curl
|
||||
jq
|
||||
];
|
||||
text = ''
|
||||
set -o errexit
|
||||
downloadsJSON="$(curl --fail --silent https://www.blackmagicdesign.com/api/support/us/downloads.json)"
|
||||
latestLinuxVersion="$(echo "$downloadsJSON" | jq '[.downloads[] | select(.urls.Linux) | .urls.Linux[] | select(.downloadTitle | test("Desktop Video")) | .downloadTitle]' | grep -oP 'Desktop Video \K\d\d\.\d+(\.\d+)?' | sort | tail -n 1)"
|
||||
|
||||
update-source-version blackmagic-desktop-video "$latestLinuxVersion"
|
||||
'';
|
||||
});
|
||||
|
||||
postUnpack =
|
||||
let
|
||||
arch = stdenv.hostPlatform.uname.processor;
|
||||
in
|
||||
''
|
||||
tar xf Blackmagic_Desktop_Video_Linux_${lib.head (lib.splitString "a" finalAttrs.version)}/other/${arch}/desktopvideo-${finalAttrs.version}-${arch}.tar.gz
|
||||
unpacked=$NIX_BUILD_TOP/desktopvideo-${finalAttrs.version}-${stdenv.hostPlatform.uname.processor}
|
||||
tar xf Blackmagic_Desktop_Video_Linux_${finalAttrs.version}/other/${arch}/desktopvideo-${finalAttrs.version}*-${arch}.tar.gz
|
||||
unpacked=$NIX_BUILD_TOP/desktopvideo-${finalAttrs.version}*-${stdenv.hostPlatform.uname.processor}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
||||
@@ -37,22 +37,24 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
arch = stdenv.hostPlatform.uname.processor;
|
||||
in
|
||||
''
|
||||
tar xf Blackmagic_Desktop_Video_Linux_${lib.head (lib.splitString "a" finalAttrs.version)}/other/${arch}/desktopvideo-${finalAttrs.version}-${arch}.tar.gz
|
||||
moduleRoot=$NIX_BUILD_TOP/desktopvideo-${finalAttrs.version}-${stdenv.hostPlatform.uname.processor}/usr/src
|
||||
tar xf Blackmagic_Desktop_Video_Linux_${finalAttrs.version}/other/${arch}/desktopvideo-${finalAttrs.version}*-${arch}.tar.gz
|
||||
bmVersion=$(ls -d $NIX_BUILD_TOP/desktopvideo-${finalAttrs.version}*-${arch}/usr/src | sed -e 's/.*desktopvideo-\([[:digit:]\.a-z]\+\).*/\1/')
|
||||
|
||||
moduleRoot=$NIX_BUILD_TOP/desktopvideo-$bmVersion-${arch}/usr/src
|
||||
sourceRoot=$moduleRoot
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
make -C $moduleRoot/blackmagic-${finalAttrs.version} -j$NIX_BUILD_CORES
|
||||
make -C $moduleRoot/blackmagic-io-${finalAttrs.version} -j$NIX_BUILD_CORES
|
||||
make -C $moduleRoot/blackmagic-$bmVersion -j$NIX_BUILD_CORES
|
||||
make -C $moduleRoot/blackmagic-io-$bmVersion -j$NIX_BUILD_CORES
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
make -C $KERNELDIR M=$moduleRoot/blackmagic-${finalAttrs.version} modules_install
|
||||
make -C $KERNELDIR M=$moduleRoot/blackmagic-io-${finalAttrs.version} modules_install
|
||||
make -C $KERNELDIR M=$moduleRoot/blackmagic-$bmVersion modules_install
|
||||
make -C $KERNELDIR M=$moduleRoot/blackmagic-io-$bmVersion modules_install
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user