chromium,chromedriver: 129.0.6668.91 -> 129.0.6668.100
[NixPkgs.git] / pkgs / by-name / sk / skia-aseprite / update.sh
blob78f7e67da6e90bd6724e7be67c21a46b646e7767
1 #!/usr/bin/env nix-shell
2 #!nix-shell --pure -i bash
3 #!nix-shell -p cacert curl git jq nix-prefetch-git
4 # shellcheck shell=bash
5 # vim: set tabstop=2 shiftwidth=2 expandtab:
6 set -euo pipefail
7 shopt -s inherit_errexit
9 [ $# -gt 0 ] || {
10 printf >&2 'usage: %s <deps>' "$0"
11 exit 1
14 pkgpath=$(git rev-parse --show-toplevel)/pkgs/by-name/sk/skia-aseprite
15 depfilter=$(tr ' ' '|' <<< "$*")
16 depfile=$pkgpath/deps.nix
17 pkgfile=$pkgpath/package.nix
19 update_deps() {
20 local deps third_party_deps name url rev hash prefetch
22 version=$(sed -n 's|.*version = "\(.*\)".*|\1|p' < "$pkgfile")
23 deps=$(curl -fsS https://raw.githubusercontent.com/aseprite/skia/$version/DEPS)
24 third_party_deps=$(sed -n 's|[ ",]||g; s|:| |; s|@| |; s|^third_party/externals/||p' <<< "$deps")
25 filtered=$(grep -E -- "$depfilter" <<< "$third_party_deps")
26 if [[ -z $filtered ]]; then
27 printf >&2 '%s: error: filter "%s" matched nothing' "$0" "$depfilter"
28 return 1
31 printf '{ fetchgit }:\n{\n'
32 while read -r name url rev; do
33 printf >&2 'Fetching %s@%s\n' "$name" "$rev"
34 prefetch=$(nix-prefetch-git --quiet --rev "$rev" "$url")
35 hash=$(jq -r '.hash' <<< "$prefetch")
37 cat << EOF
38 $name = fetchgit {
39 url = "$url";
40 rev = "$rev";
41 hash = "$hash";
43 EOF
44 # `read` could exit with a non-zero code without a newline at the end
45 done < <(printf '%s\n' "$filtered")
46 printf '}\n'
49 update_version() {
50 local newver newrev
51 newver=$(
52 curl --fail \
53 --header 'Accept: application/vnd.github+json' \
54 --location --show-error --silent \
55 ${GITHUB_TOKEN:+ --user \":$GITHUB_TOKEN\"} \
56 https://api.github.com/repos/aseprite/skia/releases/latest \
57 | jq -r .tag_name
59 newhash=$(nix-prefetch-git --quiet --rev "$newver" https://github.com/aseprite/skia.git | jq -r '.hash')
60 sed \
61 -e 's|version = ".*"|version = "'$newver'"|' \
62 -e 's|hash = ".*"|hash = "'$newhash'"|' \
63 -- "$pkgfile"
66 temp=$(mktemp)
67 trap 'ret=$?; rm -rf -- "$temp"; exit $ret' EXIT
68 update_version > "$temp"
69 cp "$temp" "$pkgfile"
70 update_deps > "$temp"
71 cp "$temp" "$depfile"