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'
5 git_dir
='/var/tmp/firefox_decrypt.git'
6 nix_file
="$(dirname "${BASH_SOURCE[0]}")/default.nix"
13 set -- '\033[32m%s\033[39m\n' "$@"
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."
43 new_sha256
=$
(nix-prefetch-git
--rev "$new_rev" "$git_dir" | jq
-r .sha256
)
44 update-source-version
"$pkg" \
49 git commit
--verbose --message "$pkg: $old_version -> $new_version"