python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / security / firefox_decrypt / update.sh
bloba56807f0ba0c484f806628c51ae867f9b72e892c
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p common-updater-scripts git jq nix nix-prefetch-git
3 git_url='https://github.com/unode/firefox_decrypt.git'
4 git_branch='master'
5 git_dir='/var/tmp/firefox_decrypt.git'
6 nix_file="$(dirname "${BASH_SOURCE[0]}")/default.nix"
7 pkg='firefox_decrypt'
9 set -euo pipefail
11 info() {
12 if [ -t 2 ]; then
13 set -- '\033[32m%s\033[39m\n' "$@"
14 else
15 set -- '%s\n' "$@"
17 printf "$@" >&2
20 old_rev=$(nix-instantiate --eval --strict --json -A "$pkg.src.rev" | jq -r)
21 old_version=$(nix-instantiate --eval --strict --json -A "$pkg.version" | jq -r)
22 today=$(LANG=C date -u +'%Y-%m-%d')
24 info "fetching $git_url..."
25 if [ ! -d "$git_dir" ]; then
26 git init --initial-branch="$git_branch" "$git_dir"
27 git -C "$git_dir" remote add origin "$git_url"
29 git -C "$git_dir" fetch origin "$git_branch"
31 # use latest commit before today, we should not call the version *today*
32 # because there might still be commits coming
33 # use the day of the latest commit we picked as version
34 new_rev=$(git -C "$git_dir" log -n 1 --format='format:%H' --before="${today}T00:00:00Z" "origin/$git_branch")
35 new_version="unstable-$(git -C "$git_dir" log -n 1 --format='format:%cs' "$new_rev")"
36 info "latest commit before $today: $new_rev"
38 if [ "$new_rev" = "$old_rev" ]; then
39 info "$pkg is up-to-date."
40 exit
43 new_sha256=$(nix-prefetch-git --rev "$new_rev" "$git_dir" | jq -r .sha256)
44 update-source-version "$pkg" \
45 "$new_version" \
46 "$new_sha256" \
47 --rev="$new_rev"
48 git add "$nix_file"
49 git commit --verbose --message "$pkg: $old_version -> $new_version"