Commit eeb6008c authored by Weijia Wang's avatar Weijia Wang
Browse files

vivaldi: add updateScript

parent 1d23a200
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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";
+16 −0
Original line number Diff line number Diff line
#!/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
+6 −9
Original line number Diff line number Diff line
@@ -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)