Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wemeet: new update script #665

Merged
merged 6 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion pkgs/wemeet/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
rsync,
fd,
qt5,
libyuv,
libjpeg8,
}:

let
Expand Down Expand Up @@ -52,6 +54,8 @@ qt5.mkDerivation {
buildInputs = with qt5; [
qtwebengine
qtx11extras
libyuv
libjpeg8
];

installPhase = ''
Expand Down Expand Up @@ -109,7 +113,7 @@ qt5.mkDerivation {
let
script = callPackage ./update.nix { };
in
[ "${script}" ];
[ "${script}/bin/update-wemeet" ];
};

meta = with lib; {
Expand Down
29 changes: 29 additions & 0 deletions pkgs/wemeet/query.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
32 changes: 32 additions & 0 deletions pkgs/wemeet/raw_source.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
44 changes: 38 additions & 6 deletions pkgs/wemeet/source.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
154 changes: 89 additions & 65 deletions pkgs/wemeet/update.nix
Original file line number Diff line number Diff line change
@@ -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 <<EOF
import secrets
import string
print('''.join(secrets.choice(string.ascii_letters) for i in range(16)))
EOF
)
query_url="https://meeting.tencent.com/web-service/query-download-info?q=$query_param&nonce=$nonce_param"
echo "query url: $query_url"

pushd pkgs/wemeet

version_old_x86_64=$(jq --raw-output '."x86_64-linux".version' source.json)
version_old_aarch64=$(jq --raw-output '."aarch64-linux".version' source.json)

source <(curl --location https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=wemeet-bin)

version_x86_64="$pkgver"
version_aarch64="$_pkgver_arm"

echo "''${source_x86_64[0]}"
source_pattern="^[^:]+::(.+)$"
[[ "''${source_x86_64[0]}" =~ $source_pattern ]]
url_x86_64="''${BASH_REMATCH[1]}"
[[ "''${source_aarch64[0]}" =~ $source_pattern ]]
url_aarch64="''${BASH_REMATCH[1]}"

jq --null-input \
--arg version_x86_64 "$version_x86_64" \
--arg url_x86_64 "$url_x86_64" \
--arg sha512sum_x86_64 "''${sha512sums_x86_64[0]}" \
--arg version_aarch64 "$version_aarch64" \
--arg url_aarch64 "$url_aarch64" \
--arg sha512sum_aarch64 "''${sha512sums_aarch64[0]}" \
'{
"x86_64-linux": {
version: $version_x86_64,
url: $url_x86_64,
sha512: $sha512sum_x86_64
},
"aarch64-linux": {
version: $version_aarch64,
url: $url_aarch64,
sha512: $sha512sum_aarch64
}
}' > 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
'';
}