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:
7 shopt -s inherit_errexit
10 printf >&2 'usage: %s <deps>' "$0"
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
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"
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")
44 # `read` could exit with a non-zero code without a newline at the end
45 done < <(printf '%s\n' "$filtered")
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 \
59 newhash
=$
(nix-prefetch-git
--quiet --rev "$newver" https
://github.com
/aseprite
/skia.git | jq
-r '.hash')
61 -e 's|version = ".*"|version = "'$newver'"|' \
62 -e 's|hash = ".*"|hash = "'$newhash'"|' \
67 trap 'ret=$?; rm -rf -- "$temp"; exit $ret' EXIT
68 update_version
> "$temp"