From eeb6008cdc7d73a9685bc27fcbaceb6e8d78ceb8 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Mon, 13 Mar 2023 19:07:58 +0200 Subject: [PATCH] vivaldi: add updateScript --- .../networking/browsers/vivaldi/default.nix | 2 ++ .../browsers/vivaldi/update-vivaldi.sh | 16 ++++++++++++++++ .../networking/browsers/vivaldi/update.sh | 15 ++++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100755 pkgs/applications/networking/browsers/vivaldi/update-vivaldi.sh diff --git a/pkgs/applications/networking/browsers/vivaldi/default.nix b/pkgs/applications/networking/browsers/vivaldi/default.nix index ec9ba8dddb9a..4a39858a02a5 100644 --- a/pkgs/applications/networking/browsers/vivaldi/default.nix +++ b/pkgs/applications/networking/browsers/vivaldi/default.nix @@ -100,6 +100,8 @@ in stdenv.mkDerivation rec { runHook postInstall ''; + passthru.updateScript = ./update-vivaldi.sh; + meta = with lib; { description = "A Browser for our Friends, powerful and personal"; homepage = "https://vivaldi.com"; diff --git a/pkgs/applications/networking/browsers/vivaldi/update-vivaldi.sh b/pkgs/applications/networking/browsers/vivaldi/update-vivaldi.sh new file mode 100755 index 000000000000..6e1d68f13994 --- /dev/null +++ b/pkgs/applications/networking/browsers/vivaldi/update-vivaldi.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl common-updater-scripts + +set -eu -o pipefail + +version=$(curl -sS https://vivaldi.com/download/ | sed -rne 's/.*vivaldi-stable_([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)-1_amd64\.deb.*/\1/p') + +update_hash() { + url="https://downloads.vivaldi.com/stable/vivaldi-stable_$version-1_$2.deb" + hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "$url")) + update-source-version vivaldi 0 sha256-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB= --system=$1 + update-source-version vivaldi "$version" "$hash" --system=$1 +} + +update_hash aarch64-linux arm64 +update_hash x86_64-linux amd64 diff --git a/pkgs/applications/networking/browsers/vivaldi/update.sh b/pkgs/applications/networking/browsers/vivaldi/update.sh index ec8a9d7d6624..56b0e10352bf 100755 --- a/pkgs/applications/networking/browsers/vivaldi/update.sh +++ b/pkgs/applications/networking/browsers/vivaldi/update.sh @@ -14,26 +14,23 @@ version() { vivaldi_version_old=$(version vivaldi) vivaldi_version=$(curl -sS https://vivaldi.com/download/ | sed -rne 's/.*vivaldi-stable_([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)-1_amd64\.deb.*/\1/p') -if [[ "$vivaldi_version" = "$vivaldi_version_old" ]]; then - echo "vivaldi is already up-to-date" +if [[ ! "$vivaldi_version" = "$vivaldi_version_old" ]]; then + echo "vivaldi is not up-to-date, not updating codecs" + (cd "$root" && nix-shell maintainers/scripts/update.nix --argstr package vivaldi) exit fi -# Download vivaldi and save hash and file path. +echo "vivaldi is up-to-date, updating codecs" + +# Download vivaldi and save file path. url="https://downloads.vivaldi.com/stable/vivaldi-stable_${vivaldi_version}-1_amd64.deb" mapfile -t prefetch < <(nix-prefetch-url --print-path "$url") -hash=${prefetch[0]} path=${prefetch[1]} nixpkgs="$(git rev-parse --show-toplevel)" default_nix="$nixpkgs/pkgs/applications/networking/browsers/vivaldi/default.nix" ffmpeg_nix="$nixpkgs/pkgs/applications/networking/browsers/vivaldi/ffmpeg-codecs.nix" -(cd "$root" && update-source-version vivaldi "$vivaldi_version" "$hash") - -git add "${default_nix}" -git commit -m "vivaldi: ${vivaldi_version_old} -> ${vivaldi_version}" - # Check vivaldi-ffmpeg-codecs version. chromium_version_old=$(version vivaldi-ffmpeg-codecs) ffmpeg_update_script=$(bsdtar xOf "$path" data.tar.xz | bsdtar xOf - ./opt/vivaldi/update-ffmpeg)