about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/networking/instant-messengers/mikutter/update.sh
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-04-28 14:39:00 +0000
committerAlyssa Ross <hi@alyssa.is>2021-06-10 08:52:36 +0000
commit693e64ef7421374338ddb1dc12b9573feec75972 (patch)
tree2526ac075d248699c35d63e04499890ee4381f5f /nixpkgs/pkgs/applications/networking/instant-messengers/mikutter/update.sh
parent7014df2256694d97093d6f2bb1db340d346dea88 (diff)
parent8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17 (diff)
downloadnixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.gz
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.bz2
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.lz
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.xz
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.zst
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.zip
Merge commit '8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17'
Diffstat (limited to 'nixpkgs/pkgs/applications/networking/instant-messengers/mikutter/update.sh')
-rwxr-xr-xnixpkgs/pkgs/applications/networking/instant-messengers/mikutter/update.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/networking/instant-messengers/mikutter/update.sh b/nixpkgs/pkgs/applications/networking/instant-messengers/mikutter/update.sh
new file mode 100755
index 000000000000..142fd8ca9424
--- /dev/null
+++ b/nixpkgs/pkgs/applications/networking/instant-messengers/mikutter/update.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p bundler bundix curl jq common-updater-scripts
+# shellcheck shell=bash
+
+set -euo pipefail
+
+main() {
+    local currentVer="$1"
+    local scriptDir="$2"
+    local latestVer
+    local srcDir
+
+    if [[ -z "$UPDATE_NIX_ATTR_PATH" ]]; then
+        echo "[ERROR] Please run the following instead:" >&2
+        echo >&2
+        echo "    % nix-shell maintainers/scripts/update.nix --argstr path mikutter" >&2
+        exit 1
+    fi
+
+    latestVer="$(queryLatestVersion)"
+    if [[ "$currentVer" == "$latestVer" ]]; then
+        echo "[INFO] mikutter is already up to date" >&2
+        exit
+    fi
+
+    update-source-version "$UPDATE_NIX_ATTR_PATH" "$latestVer"
+
+    cd "$scriptDir"
+
+    rm -rf deps
+    mkdir deps
+    cd deps
+
+    srcDir="$(nix-build ../../../../../.. --no-out-link -A mikutter.src)"
+    tar xvf "$srcDir" --strip-components=1
+    find . -not -name Gemfile -exec rm {} \;
+    find . -type d -exec rmdir -p --ignore-fail-on-non-empty {} \; || true
+
+    bundle lock
+    bundix
+}
+
+queryLatestVersion() {
+    curl -sS 'https://mikutter.hachune.net/download.json?count=1' \
+        | jq -r '.[].version_string' \
+        | head -n1
+}
+
+main "$@"
+
+# vim:set ft=bash: