diff options
author | Lily Foster <lily@lily.flowers> | 2023-03-21 19:34:23 -0400 |
---|---|---|
committer | Lily Foster <lily@lily.flowers> | 2023-03-21 19:34:23 -0400 |
commit | 5113be6584810b63ae9be37f3d887bc09e7c1334 (patch) | |
tree | d71fe229b1a2d001d997fc7b960d2167b9726a95 /pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh | |
parent | 60c1d71f2ba4c80178ec84523c2ca0801522e0a6 (diff) |
teams-for-linux: add updateScript
Diffstat (limited to 'pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh')
-rwxr-xr-x | pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh b/pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh new file mode 100755 index 0000000000000..650edf188611f --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/teams-for-linux/update.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p nix jq common-updater-scripts + +set -euo pipefail + +nixpkgs="$(git rev-parse --show-toplevel || (printf 'Could not find root of nixpkgs repo\nAre we running from within the nixpkgs git repo?\n' >&2; exit 1))" + +stripwhitespace() { + sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' +} + +nixeval() { + nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1" | jq -r . +} + +vendorhash() { + (nix --extra-experimental-features nix-command build --impure --argstr nixpkgs "$nixpkgs" --argstr attr "$1" --expr '{ nixpkgs, attr }: let pkgs = import nixpkgs {}; in with pkgs.lib; (getAttrFromPath (splitString "." attr) pkgs).overrideAttrs (attrs: { outputHash = fakeHash; })' --no-link 2>&1 >/dev/null | tail -n3 | grep -F got: | cut -d: -f2- | stripwhitespace) 2>/dev/null || true +} + +findpath() { + path="$(nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1.meta.position" | jq -r . | cut -d: -f1)" + outpath="$(nix --extra-experimental-features nix-command eval --json --impure --expr "builtins.fetchGit \"$nixpkgs\"")" + + if [ -n "$outpath" ]; then + path="${path/$(echo "$outpath" | jq -r .)/$nixpkgs}" + fi + + echo "$path" +} + +attr="${UPDATE_NIX_ATTR_PATH:-teams-for-linux}" +version="$(cd "$nixpkgs" && list-git-tags --pname="$(nixeval "$attr".pname)" --attr-path="$attr" | grep '^v' | sed -e 's|^v||' | sort -V | tail -n1)" + +pkgpath="$(findpath "$attr")" + +updated="$(cd "$nixpkgs" && update-source-version "$attr" "$version" --file="$pkgpath" --print-changes | jq -r length)" + +if [ "$updated" -eq 0 ]; then + echo 'update.sh: Package version not updated, nothing to do.' + exit 0 +fi + +curhash="$(nixeval "$attr.offlineCache.outputHash")" +newhash="$(vendorhash "$attr.offlineCache")" + +if [ -n "$newhash" ] && [ "$curhash" != "$newhash" ]; then + sed -i -e "s|\"$curhash\"|\"$newhash\"|" "$pkgpath" +else + echo 'update.sh: New vendorHash same as old vendorHash, nothing to do.' +fi |