summaryrefslogtreecommitdiff
path: root/guix/packages.scm
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2022-12-09 11:46:37 +0100
committerLudovic Courtès <ludo@gnu.org>2022-12-13 17:46:39 +0100
commit052faadde70c44043d0db73bd254f664e1905ceb (patch)
tree5b8562e19d355f8af9ce707a6fc5913526811c23 /guix/packages.scm
parenta2f0297af0b53239cdcee62abe044532e80ca32b (diff)
packages: Add 'package-upstream-name*'.
* guix/packages.scm (package-upstream-name*): New procedure. * tests/packages.scm ("package-upstream-name*"): New test. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/packages.scm')
-rw-r--r--guix/packages.scm33
1 files changed, 33 insertions, 0 deletions
diff --git a/guix/packages.scm b/guix/packages.scm
index 8f119d9fa7..6e61e16aa4 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -89,6 +89,7 @@
this-package
package-name
package-upstream-name
+ package-upstream-name*
package-version
package-full-name
package-source
@@ -691,6 +692,38 @@ it has in Guix."
(or (assq-ref (package-properties package) 'upstream-name)
(package-name package)))
+(define (package-upstream-name* package)
+ "Return the upstream name of PACKAGE, accounting for commonly-used
+package name prefixes in addition to the @code{upstream-name} property."
+ (let ((namespaces (list "cl-"
+ "ecl-"
+ "emacs-"
+ "ghc-"
+ "go-"
+ "guile-"
+ "java-"
+ "julia-"
+ "lua-"
+ "minetest-"
+ "node-"
+ "ocaml-"
+ "perl-"
+ "python-"
+ "r-"
+ "ruby-"
+ "rust-"
+ "sbcl-"
+ "texlive-"))
+ (name (package-name package)))
+ (or (assq-ref (package-properties package) 'upstream-name)
+ (let loop ((prefixes namespaces))
+ (match prefixes
+ (() name)
+ ((prefix rest ...)
+ (if (string-prefix? prefix name)
+ (substring name (string-length prefix))
+ (loop rest))))))))
+
(define (hidden-package p)
"Return a \"hidden\" version of P--i.e., one that 'fold-packages' and thus,
user interfaces, ignores."