diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 64772355..8c0cd3d8 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -13,8 +13,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@main - with: - ref: master - name: Install nix uses: cachix/install-nix-action@master with: diff --git a/pkgs/wemeet/default.nix b/pkgs/wemeet/default.nix index 318a23be..bcd7852c 100644 --- a/pkgs/wemeet/default.nix +++ b/pkgs/wemeet/default.nix @@ -9,6 +9,8 @@ rsync, fd, qt5, + libyuv, + libjpeg8, }: let @@ -52,6 +54,8 @@ qt5.mkDerivation { buildInputs = with qt5; [ qtwebengine qtx11extras + libyuv + libjpeg8 ]; installPhase = '' @@ -109,7 +113,7 @@ qt5.mkDerivation { let script = callPackage ./update.nix { }; in - [ "${script}" ]; + [ "${script}/bin/update-wemeet" ]; }; meta = with lib; { diff --git a/pkgs/wemeet/query.json b/pkgs/wemeet/query.json new file mode 100644 index 00000000..9b9b3879 --- /dev/null +++ b/pkgs/wemeet/query.json @@ -0,0 +1,29 @@ +[ + { + "package-type": "app", + "channel": "0300000000", + "platform": "linux", + "arch": "x86_64", + "decorators": [ + "deb" + ] + }, + { + "package-type": "app", + "channel": "0300000000", + "platform": "linux", + "arch": "arm64", + "decorators": [ + "deb" + ] + }, + { + "package-type": "app", + "channel": "0300000000", + "platform": "linux", + "arch": "loongarch64", + "decorators": [ + "deb" + ] + } +] diff --git a/pkgs/wemeet/raw_source.json b/pkgs/wemeet/raw_source.json new file mode 100644 index 00000000..00c9c377 --- /dev/null +++ b/pkgs/wemeet/raw_source.json @@ -0,0 +1,32 @@ +{ + "code": 0, + "info-list": [ + { + "channel": "0300000000", + "platform": "linux", + "md5": "fcdc2a010a25561a4d23e168b677b493", + "size": 161153760, + "url": "https://updatecdn.meeting.qq.com/cos/fcdc2a010a25561a4d23e168b677b493/TencentMeeting_0300000000_3.19.1.400_x86_64_default.publish.deb", + "version": "3.19.1.400", + "sub-date": "2024-04-03" + }, + { + "channel": "0300000000", + "platform": "linux_arm64", + "md5": "206c30da5545dba38a29ccbc752dec94", + "size": 144209660, + "url": "https://updatecdn.meeting.qq.com/cos/206c30da5545dba38a29ccbc752dec94/TencentMeeting_0300000000_3.19.1.401_arm64_default.publish.deb", + "version": "3.19.1.401", + "sub-date": "2024-04-17" + }, + { + "channel": "0300000000", + "platform": "linux_deb_loongarch64", + "md5": "23810840e7e8bb38536b2a59ae811343", + "size": 135845236, + "url": "https://updatecdn.meeting.qq.com/cos/23810840e7e8bb38536b2a59ae811343/TencentMeeting_0300000000_3.19.1.401_loongarch64_default.publish.deb", + "version": "3.19.1.401", + "sub-date": "2024-04-17" + } + ] +} diff --git a/pkgs/wemeet/source.json b/pkgs/wemeet/source.json index f9668abf..8560cd9d 100644 --- a/pkgs/wemeet/source.json +++ b/pkgs/wemeet/source.json @@ -1,12 +1,44 @@ { "x86_64-linux": { - "version": "3.19.0.401", - "url": "https://updatecdn.meeting.qq.com/cos/bb4001c715553579a8b3e496233331d4/TencentMeeting_0300000000_3.19.0.401_x86_64_default.publish.deb", - "sha512": "2814febb1596cb8e6db75a7d71915771a9d6750cf162c3cb9b70379130da41d7fca7b3df1567a8de1d2967d97add4d2fc08764fbf4155a79852c75ea8fed754b" + "version": "3.19.1.400", + "url": "https://updatecdn.meeting.qq.com/cos/fcdc2a010a25561a4d23e168b677b493/TencentMeeting_0300000000_3.19.1.400_x86_64_default.publish.deb", + "sha512": "sha512-W3X9kqmz9HfOvXkfQ9Iynomb78p5DMfzwJcNfAetc5CoNb6Rr3EPGbXbWmWrJ2PlHR9PNuIizmiJ16aNZNzgkg==", + "info": { + "channel": "0300000000", + "platform": "linux", + "md5": "fcdc2a010a25561a4d23e168b677b493", + "size": 161153760, + "url": "https://updatecdn.meeting.qq.com/cos/fcdc2a010a25561a4d23e168b677b493/TencentMeeting_0300000000_3.19.1.400_x86_64_default.publish.deb", + "version": "3.19.1.400", + "sub-date": "2024-04-03" + } }, "aarch64-linux": { - "version": "3.19.0.401", - "url": "https://updatecdn.meeting.qq.com/cos/0f96a97b0aaea9b9d5d2c2b912ede656/TencentMeeting_0300000000_3.19.0.401_arm64_default.publish.deb", - "sha512": "6099ec383e74dc776a9864743c9a2c624a5bea34e2ffb32b3fb57b66016a60dc1356ad3b58c6142ed2f3d9db83fc38ffd9c9661b282bf895e20d837277a07c76" + "version": "3.19.1.401", + "url": "https://updatecdn.meeting.qq.com/cos/206c30da5545dba38a29ccbc752dec94/TencentMeeting_0300000000_3.19.1.401_arm64_default.publish.deb", + "sha512": "sha512-2Eu0Bhft8al9D9O2Z03wUNYsfOGeiv8SMKQtR9GIfKZBrsINcy/Bu97MIzeB2wvgyc6KQS/baNKO7FnQkij2OA==", + "info": { + "channel": "0300000000", + "platform": "linux_arm64", + "md5": "206c30da5545dba38a29ccbc752dec94", + "size": 144209660, + "url": "https://updatecdn.meeting.qq.com/cos/206c30da5545dba38a29ccbc752dec94/TencentMeeting_0300000000_3.19.1.401_arm64_default.publish.deb", + "version": "3.19.1.401", + "sub-date": "2024-04-17" + } + }, + "loongarch64-linux": { + "version": "3.19.1.401", + "url": "https://updatecdn.meeting.qq.com/cos/23810840e7e8bb38536b2a59ae811343/TencentMeeting_0300000000_3.19.1.401_loongarch64_default.publish.deb", + "sha512": "sha512-6Q3Ydr5cLyF8VD8+TA8UnLQ+ltjeloqN//tVr2lZux/F8wfezs8yq9ubJP/06QZgvlAxvbqW18rgDfdNdaPnJQ==", + "info": { + "channel": "0300000000", + "platform": "linux_deb_loongarch64", + "md5": "23810840e7e8bb38536b2a59ae811343", + "size": 135845236, + "url": "https://updatecdn.meeting.qq.com/cos/23810840e7e8bb38536b2a59ae811343/TencentMeeting_0300000000_3.19.1.401_loongarch64_default.publish.deb", + "version": "3.19.1.401", + "sub-date": "2024-04-17" + } } } diff --git a/pkgs/wemeet/update.nix b/pkgs/wemeet/update.nix index 6c2a45b3..b3d7c898 100644 --- a/pkgs/wemeet/update.nix +++ b/pkgs/wemeet/update.nix @@ -1,83 +1,107 @@ { - writeShellScript, - lib, + writeShellApplication, + python3, curl, jq, + urlencode, + moreutils, }: -writeShellScript "update-wemeet" '' - set -e +writeShellApplication { + name = "update-wemeet"; + runtimeInputs = [ + python3 + curl + jq + urlencode + moreutils + ]; + text = '' + while [[ $# -gt 0 ]]; do + case $1 in + --write-commit-message) + commit_message_file="$2" + shift 2 + ;; + *) + echo "unknown option $1" 1>&2 + exit 1 + ;; + esac + done - export PATH="${ - lib.makeBinPath [ - curl - jq - ] - }:$PATH" + pushd pkgs/wemeet - while [[ $# -gt 0 ]]; do - case $1 in - --write-commit-message) - commit_message_file="$2" - shift 2 - ;; - *) - echo "unknown option $1" 1>&2 - exit 1 - ;; - esac - done + # query.json is taken from https://meeting.tencent.com/download using browser debugger + query_param=$(jq --raw-output @uri ./query.json) + nonce_param=$(python3 < source.json + echo "curl" + curl --verbose "$query_url" | jq '.' >raw_source.json if [[ -n "$commit_message_file" ]]; then if [[ -f "$commit_message_file" ]]; then rm "$commit_message_file" fi + fi + hash_type="sha512" + for platform in x86_64 aarch64 loongarch64; do + system="$platform-linux" + + version_old=$(jq --arg system "$system" --raw-output '."\($system)".version' source.json) + + if [ "$platform" = "x86_64" ]; then + regex="^linux$" + elif [ "$platform" = "aarch64" ]; then + regex="^linux_arm64$" + elif [ "$platform" = "loongarch64" ]; then + regex="^linux_deb_loongarch64$" + fi - if [[ "$version_x86_64" != "$version_old_x86_64" ]]; then - echo "wemeet (x86_64-linux): $version_old_x86_64 -> $version_x86_64" >> "$commit_message_file" + info=$(jq '."info-list" [] | select(.platform | match("'"$regex"'"))' raw_source.json) + version=$(jq '.version' <<<"$info" --raw-output) + if [ "$version" = "$version_old" ]; then + echo "wemeet ($system): version does not change, skip." + continue fi + url=$(jq '.url' <<<"$info" --raw-output) + hash=$(nix --experimental-features nix-command \ + store prefetch-file --json --hash-type "$hash_type" \ + "$(jq '.url' --raw-output <<<"$info")" |\ + jq '.hash' --raw-output) - if [[ "$version_aarch64" != "$version_old_aarch64" ]]; then - echo "wemeet (aarch64-linux): $version_old_aarch64 -> $version_aarch64" >> "$commit_message_file" + echo "platform: $platform" + echo "info: $info" + echo "url: $url" + echo "version: $version" + echo "hash: $hash" + + jq \ + --arg system "$platform-linux" \ + --arg version "$version" \ + --arg url "$url" \ + --argjson info "$info" \ + --arg hash_type "$hash_type" \ + --arg hash "$hash" \ + '."\($system)" = { version: $version, url: $url, ($hash_type): $hash, info: $info }' \ + source.json | sponge source.json + + if [[ -n "$commit_message_file" ]]; then + if [ "$version_old" = "null" ]; then + echo "wemeet ($system): init at $version" >>"$commit_message_file" + else + echo "wemeet ($system): $version_old -> $version" >>"$commit_message_file" + fi fi - fi + done - popd -'' + popd + ''; +}