guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#57118] [PATCH] gnu: Add linode-cli.


From: raingloom
Subject: [bug#57118] [PATCH] gnu: Add linode-cli.
Date: Wed, 10 Aug 2022 16:18:43 +0200

* gnu/packages/python-xyz.scm (linode-cli): New variable.
---
 gnu/packages/python-xyz.scm | 69 +++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index e5326274c0..1625df48c2 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -30353,3 +30353,72 @@ (define-public i3-autotiling
      "Script for Sway and i3 to automatically switch the horizontal/vertical
  window split orientation.")
     (license license:gpl3)))
+
+;; linode-cli would normally fetch this at build time
+;; TODO: is there a way to refer to previous versions? is there even a point
+;; in trying to?
+(define linode-openapi-spec
+  (origin
+    (method url-fetch)
+    (uri "https://www.linode.com/docs/api/openapi.yaml";)
+    (sha256
+     (base32
+      "1jcjfnagjihcy03fcmn5sghdf7a80798xjgj1x7z3ncqwd5aggwg"))))
+
+(define-public linode-cli
+  (package
+    (name "linode-cli")
+    (version "5.22.0")
+    (synopsis "Tool for managing Linode resources")
+    (home-page "https://www.linode.com/docs/products/tools/cli/";)
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/linode/linode-cli";)
+             (commit version)))
+       (sha256
+        (base32
+         "1fv53wikx745kci86xrsq9kfsgv0a65srhywdw32cab1wywwpn2z"))))
+    (build-system python-build-system)
+    (arguments '(#:tests? #f ;; requires personal access token
+                 #:phases
+                 (modify-phases %standard-phases
+                   (add-after 'build 'bake-api
+                     (lambda* (#:key inputs #:allow-other-keys)
+                       ;; The "build" make target tries to do some Python 2
+                       ;; stuff, so instead we just take the two lines we care
+                       ;; about:
+                       (invoke "python3" "-m" "linodecli" "bake"
+                               (assoc-ref inputs
+                                          "linode-openapi-spec")
+                               "--skip-config")
+                       (copy-file "data-3" "linodecli/data-3")))
+                   (add-before 'install 'fix-bash-completions-path
+                     (lambda* (#:key outputs #:allow-other-keys)
+                       ;; rename it so setup.py thinks it's missing and
+                       ;; doesn't try to install it to /etc
+                       (rename-file "linode-cli.sh" "completions")
+                       ;; TODO for some reason these don't work?
+                       ;; I don't use bash, so I leave it for someone else to
+                       ;; figure out.
+                       (install-file "completions"
+                                  (string-append
+                                   (assoc-ref outputs "out")
+                                   "/share/bash-completion/"))))
+                   (replace 'sanity-check
+                     (lambda _
+                       ;; this way it doesn't ask for an access token
+                       (invoke "linode-cli" "--version" "--skip-config"))))))
+    (native-inputs
+     `(("linode-openapi-spec" ,linode-openapi-spec)))
+    (inputs
+     (list
+      python-terminaltables
+      python-requests
+      python-pyyaml))
+    (description
+     "A wrapper around the Linode API, which gives you the ability to manage
+your Linode account from the command line. Almost any task that can be done
+through the Cloud Manager can also be performed through the CLI.")
+    (license license:bsd-3)))
-- 
2.37.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]