linode-cli: add updateScript (#138547)

* linode-cli: add updateScript

* Update pkgs/tools/virtualization/linode-cli/default.nix

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
superherointj 2021-09-22 16:41:14 -03:00 committed by GitHub
parent d10fd707e9
commit 80ea69bdc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View File

@ -11,11 +11,13 @@
}:
let
sha256 = "08j7j9fpxh08vkczjqahb8r55bwks8p3ykrv6a2kfi309629nm96";
# specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`.
specVersion = "4.104.0";
specSha256 = "0lbky0djqsndp33067q6yir5525m3zcgkpvf1z16mkspkixzadqs";
spec = fetchurl {
url = "https://raw.githubusercontent.com/linode/linode-api-docs/v${specVersion}/openapi.yaml";
sha256 = "0lbky0djqsndp33067q6yir5525m3zcgkpvf1z16mkspkixzadqs";
sha256 = specSha256;
};
in
@ -28,7 +30,7 @@ buildPythonApplication rec {
owner = "linode";
repo = pname;
rev = version;
sha256 = "08j7j9fpxh08vkczjqahb8r55bwks8p3ykrv6a2kfi309629nm96";
inherit sha256;
};
# remove need for git history
@ -60,6 +62,8 @@ buildPythonApplication rec {
installShellCompletion --cmd linode-cli --bash <($out/bin/linode-cli --skip-config completion bash)
'';
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "The Linode Command Line Interface";
homepage = "https://github.com/linode/linode-cli";

View File

@ -0,0 +1,30 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq yq-go
set -eu -o pipefail
cd $(dirname "${BASH_SOURCE[0]}")
SPEC_VERSION=$(curl -s https://www.linode.com/docs/api/openapi.yaml | yq eval '.info.version' -)
SPEC_SHA256=$(nix-prefetch-url --quiet https://raw.githubusercontent.com/linode/linode-api-docs/v${SPEC_VERSION}/openapi.yaml)
VERSION=$(curl -s ${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/linode/linode-cli/tags" \
| jq 'map(.name)' \
| grep '"' \
| sed 's/[ ",(^v)]//g' \
| grep -v -e rc -e list \
| cut -d '"' -f4 | sort -rV | head -n 1)
SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/linode/linode-cli/archive/refs/tags/${VERSION}.tar.gz)
setKV () {
sed -i "s/$1 = \".*\"/$1 = \"$2\"/" default.nix
}
setKV specVersion ${SPEC_VERSION}
setKV specSha256 ${SPEC_SHA256}
setKV version ${VERSION}
setKV sha256 ${SHA256}