Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 60 lines 1.9 kB view raw
1#! /usr/bin/env nix-shell 2#! nix-shell -i bash --pure --keep GITHUB_TOKEN -p nix git curl cacert nix-prefetch-git gzip 3 4base_url_suffix="https://pro-store-packages.uniontech.com/appstore/dists/eagle/appstore/binary-" 5base_url_appendix="/Packages.gz" 6target_package="com.tencent.wechat" 7packages_file="Packages.gz" 8 9url=() 10version=() # TODO: Currently, there is no version differences between archs. This is reserved for future use. 11hash=() 12 13for i in amd64 arm64 loongarch64 14do 15 current_url=$base_url_suffix$i$base_url_appendix 16 curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" -v -L -O $current_url 17 current_version=$(zgrep -A 20 "Package: $target_package" "$packages_file" | awk -v pkg="$target_package" ' 18 BEGIN { found = 0 } 19 { 20 if ($0 ~ "^Package: "pkg) { 21 found = 1; 22 } 23 if (found && $1 == "Version:") { 24 print $2; 25 exit; 26 } 27 } 28 ') 29 version+=("$current_version") 30 sha256sum=$(zgrep -A 20 "Package: $target_package" "$packages_file" | awk -v pkg="$target_package" ' 31 BEGIN { found = 0 } 32 { 33 if ($0 ~ "^Package: "pkg) { 34 found = 1; 35 } 36 if (found && $1 == "SHA256:") { 37 print $2; 38 exit; 39 } 40 } 41 ') 42 url+=("https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_"$version"_"$i".deb") 43 hash+=("$(nix --extra-experimental-features nix-command hash to-sri --type sha256 $sha256sum)") 44done 45 46cat >sources.nix <<EOF 47# Generated by ./update.sh - do not update manually! 48# Last updated: $(date +%F) 49{ 50 version = "${version[0]}"; 51 amd64_url = "${url[0]}"; 52 arm64_url = "${url[1]}"; 53 loongarch64_url = "${url[2]}"; 54 amd64_hash = "${hash[0]}"; 55 arm64_hash = "${hash[1]}"; 56 loongarch64_hash = "${hash[2]}"; 57} 58EOF 59 60rm -r Packages.gz