fork
Configure Feed
Select the types of activity you want to include in your feed.
lol
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{
2 lib,
3 writeShellScript,
4 coreutils,
5 gnused,
6 gnugrep,
7 curl,
8 gnupg,
9 nix,
10 common-updater-scripts,
11
12 # options
13 pname,
14 version,
15 meta,
16 baseUrl ? "https://dist.torproject.org/torbrowser/",
17 # name used to match published archive
18 name ? "tor-browser",
19 prerelease ? false,
20}:
21
22let
23 versionMatch = if prerelease then ''[0-9]+(\.[0-9]+)*.*'' else ''[0-9]+(\.[0-9]+)*'';
24in
25writeShellScript "update-${pname}" ''
26 PATH="${
27 lib.makeBinPath [
28 coreutils
29 curl
30 gnugrep
31 gnused
32 gnupg
33 nix
34 common-updater-scripts
35 ]
36 }"
37 set -euo pipefail
38
39 trap
40
41 url=${baseUrl}
42 version=$(curl -s $url \
43 | sed -rne 's,^.*href="(${versionMatch})/".*,\1,p' \
44 | sort --version-sort | tail -1)
45
46 if [[ "${version}" = "$version" ]]; then
47 echo "The new version same as the old version."
48 exit 0
49 fi
50
51 HOME=$(mktemp -d)
52 export GNUPGHOME=$(mktemp -d)
53 trap 'rm -rf "$HOME" "$GNUPGHOME"' EXIT
54
55 gpg --auto-key-locate nodefault,wkd --locate-keys torbrowser@torproject.org
56 gpg --output $HOME/tor.keyring --export 0xEF6E286DDA85EA2A4BA7DE684E2C6E8793298290
57
58 curl --silent --show-error --fail -o $HOME/shasums "$url$version/sha256sums-signed-build.txt"
59 curl --silent --show-error --fail -o $HOME/shasums.asc "$url$version/sha256sums-signed-build.txt.asc"
60 gpgv --keyring=$HOME/tor.keyring $HOME/shasums.asc $HOME/shasums
61
62 declare -A platforms=(
63 ['x86_64-linux']='linux-x86_64'
64 ['i686-linux']='linux-i686'
65 )
66
67 for platform in ${lib.escapeShellArgs meta.platforms}; do
68 arch="''${platforms[$platform]}"
69 sha256=$(grep "${name}-$arch-$version.tar.xz" "$HOME/shasums" | head -1 | cut -d" " -f1)
70 hash=$(nix --extra-experimental-features nix-command hash to-sri --type sha256 "$sha256")
71
72 update-source-version "${pname}" "$version" "$hash" --ignore-same-version --source-key="sources.$platform"
73 done
74''