32 lines
1.2 KiB
Bash
Executable File
32 lines
1.2 KiB
Bash
Executable File
#! /usr/bin/env nix-shell
|
|
#! nix-shell -i bash -p nix-prefetch-git jq ruby mastodon.updateScript prefetch-yarn-deps
|
|
|
|
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
|
|
# self-explanatory
|
|
UPDATE_URL="https://gitlab.com/tootcat/glitch.git"
|
|
|
|
nix flake update
|
|
|
|
# intermediate variables
|
|
PREFETCHED_JSON="$(nix-prefetch-git "$UPDATE_URL")"
|
|
GIT_REV="$(echo "$PREFETCHED_JSON" | jq -r '.rev')"
|
|
REPO_PATH="$(echo "$PREFETCHED_JSON" | jq -r '.path')"
|
|
# i believe this is the most "correct" way to get the version string from the source
|
|
VERSION="$(ruby -e "require '${REPO_PATH}/lib/mastodon/version.rb'; puts Mastodon::Version.to_s")"
|
|
|
|
cd mastodon
|
|
update.sh --url "$UPDATE_URL" --ver "$VERSION" --rev "$GIT_REV"
|
|
|
|
# prefetch-yarn-deps outputs everything on stdout so we tee /dev/stderr
|
|
# so that we can have human-readable output too and just take the end...
|
|
#
|
|
# it also writes an extra line at the end so we take the last two lines
|
|
#
|
|
# this sucks but uh whatever
|
|
YARN_SHA256="$(prefetch-yarn-deps -v "${REPO_PATH}/yarn.lock" | tee /dev/stderr | tail -n2)"
|
|
# now we write it as a nix string (double quoted) to this file so it can be imported
|
|
echo "\"$YARN_SHA256\"" > yarn-sha256.nix
|