Unverified Commit 6611254c authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

Merge pull request #245211 from fee1-dead-contrib/qq/updatescript

qq: add update script
parents ba5a9668 e286ed3a
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -23,23 +23,23 @@
}:

let
  version = "3.2.1-17153";
  _hash = "b69de82d";
  sources = import ./sources.nix;
  srcs = {
    x86_64-linux = fetchurl {
      url = "https://dldir1.qq.com/qqfile/qq/QQNT/${_hash}/linuxqq_${version}_amd64.deb";
      hash = "sha256-+GjTjv0K2vnlkb46KhMvRRFWuIEBz23Lg3QhiA7QzkA=";
      url = "https://dldir1.qq.com/qqfile/qq/QQNT/${sources.urlhash}/linuxqq_${sources.version}_amd64.deb";
      hash = sources.amd64_hash;
    };
    aarch64-linux = fetchurl {
      url = "https://dldir1.qq.com/qqfile/qq/QQNT/${_hash}/linuxqq_${version}_arm64.deb";
      hash = "sha256-BtmmVpKZF15aU7RRmXl9g5leg2jz5sT4vYXluq9aIYk=";
      url = "https://dldir1.qq.com/qqfile/qq/QQNT/${sources.urlhash}/linuxqq_${sources.version}_arm64.deb";
      hash = sources.arm64_hash;
    };
  };
  src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation {
  pname = "qq";
  inherit version src;
  version = sources.version;
  inherit src;

  nativeBuildInputs = [
    autoPatchelfHook
@@ -98,6 +98,8 @@ stdenv.mkDerivation {
    )
  '';

  passthru.updateScript = ./update.sh;

  meta = with lib; {
    homepage = "https://im.qq.com/linuxqq/";
    description = "Messaging app";
+8 −0
Original line number Diff line number Diff line
# Generated by ./update.sh - do not update manually!
# Last updated: 2023-09-26
{
  version = "3.2.1-17153";
  urlhash = "b69de82d";
  arm64_hash = "sha256-BtmmVpKZF15aU7RRmXl9g5leg2jz5sT4vYXluq9aIYk=";
  amd64_hash = "sha256-+GjTjv0K2vnlkb46KhMvRRFWuIEBz23Lg3QhiA7QzkA=";
}
+31 −0
Original line number Diff line number Diff line
#! /usr/bin/env nix-shell
#! nix-shell -i bash --pure --keep GITHUB_TOKEN -p nix git curl cacert nix-prefetch-git jq

set -euo pipefail

cd $(readlink -e $(dirname "${BASH_SOURCE[0]}"))

payload=$(curl https://im.qq.com/rainbow/linuxQQDownload | grep -oP "var params= \K\{.*\}(?=;)")
amd64_url=$(jq -r .x64DownloadUrl.deb <<< "$payload")
arm64_url=$(jq -r .armDownloadUrl.deb <<< "$payload")

urlhash=$(grep -oP "(?<=QQNT/)[a-e0-9]+(?=/linuxqq)" <<< "$amd64_url")
version=$(grep -oP "(?<=/linuxqq_).*(?=_amd64.deb)" <<< "$amd64_url")

amd64_hash=$(nix-prefetch-url $amd64_url)
arm64_hash=$(nix-prefetch-url $arm64_url)

# use friendlier hashes
amd64_hash=$(nix hash to-sri --type sha256 "$amd64_hash")
arm64_hash=$(nix hash to-sri --type sha256 "$arm64_hash")

cat >sources.nix <<EOF
# Generated by ./update.sh - do not update manually!
# Last updated: $(date +%F)
{
  version = "$version";
  urlhash = "$urlhash";
  arm64_hash = "$arm64_hash";
  amd64_hash = "$amd64_hash";
}
EOF