diff mbox series

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

Message ID 20220810141843.21051-1-raingloom@riseup.net
State New
Headers show
Series [bug#57118] gnu: Add linode-cli. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Csepp Aug. 10, 2022, 2:18 p.m. UTC
* gnu/packages/python-xyz.scm (linode-cli): New variable.
---
 gnu/packages/python-xyz.scm | 69 +++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

Comments

Mathieu Othacehe Aug. 15, 2022, 8:32 a.m. UTC | #1
Hey,

> * gnu/packages/python-xyz.scm (linode-cli): New variable.

You also need to mention the linode-openapi-spec variable.

> +    (synopsis "Tool for managing Linode resources")
> +    (home-page "https://www.linode.com/docs/products/tools/cli/")

These are usually at the end of the package definition.

> +                               (assoc-ref inputs
> +                                          "linode-openapi-spec")

It would be preferable to use the gexp mechanism.

> +                                   (assoc-ref outputs "out")

Here too.

> +     "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.")

This package provides a wrapper around Linode API which gives the
ability to manage Linode accounts from the command line.  Almost ...

Sentences must be separated by two spaces.

Could you please send a v2?

Thanks,

Mathieu
Steve George April 1, 2024, 7:53 a.m. UTC | #2
Hi,

Bumping this linode-cli patch.

According to the repository there is now a license (Apache 2).

https://github.com/linode/linode-api-docs/blob/development/LICENSE.txt

Steve
diff mbox series

Patch

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)))