utils: Move 'package-name->name+version' to (guix build utils).

* guix/utils.scm (package-name->name+version): Move to...
* guix/build/utils.scm (package-name->name+version): ... here.  New
  procedure.
* guix/build/emacs-build-system.scm (package-name->name+version):
  Remove.
This commit is contained in:
Ludovic Courtès 2015-08-30 14:59:31 +02:00
parent b7c7c03eb5
commit 8c578a6094
3 changed files with 26 additions and 45 deletions

View File

@ -150,28 +150,6 @@ second hyphen. This corresponds to 'name-version' as used in ELPA packages."
strip-store-file-name) strip-store-file-name)
store-dir)) store-dir))
;; from (guix utils). Should we put it in (guix build utils)?
(define (package-name->name+version name)
"Given NAME, a package name like \"foo-0.9.1b\", return two values:
\"foo\" and \"0.9.1b\". When the version part is unavailable, NAME and
#f are returned. The first hyphen followed by a digit is considered to
introduce the version part."
;; See also `DrvName' in Nix.
(define number?
(cut char-set-contains? char-set:digit <>))
(let loop ((chars (string->list name))
(prefix '()))
(match chars
(()
(values name #f))
((#\- (? number? n) rest ...)
(values (list->string (reverse prefix))
(list->string (cons n rest))))
((head tail ...)
(loop tail (cons head prefix))))))
(define %standard-phases (define %standard-phases
(modify-phases gnu:%standard-phases (modify-phases gnu:%standard-phases
(delete 'configure) (delete 'configure)

View File

@ -21,6 +21,7 @@
(define-module (guix build utils) (define-module (guix build utils)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-11) #:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-60) #:use-module (srfi srfi-60)
#:use-module (ice-9 ftw) #:use-module (ice-9 ftw)
#:use-module (ice-9 match) #:use-module (ice-9 match)
@ -34,6 +35,7 @@
#:export (%store-directory #:export (%store-directory
store-file-name? store-file-name?
strip-store-file-name strip-store-file-name
package-name->name+version
parallel-job-count parallel-job-count
directory-exists? directory-exists?
@ -94,6 +96,27 @@ is typically a \"PACKAGE-VERSION\" string."
(string-drop file (string-drop file
(+ 34 (string-length (%store-directory))))) (+ 34 (string-length (%store-directory)))))
(define (package-name->name+version name)
"Given NAME, a package name like \"foo-0.9.1b\", return two values:
\"foo\" and \"0.9.1b\". When the version part is unavailable, NAME and
#f are returned. The first hyphen followed by a digit is considered to
introduce the version part."
;; See also `DrvName' in Nix.
(define number?
(cut char-set-contains? char-set:digit <>))
(let loop ((chars (string->list name))
(prefix '()))
(match chars
(()
(values name #f))
((#\- (? number? n) rest ...)
(values (list->string (reverse prefix))
(list->string (cons n rest))))
((head tail ...)
(loop tail (cons head prefix))))))
(define parallel-job-count (define parallel-job-count
;; Number of processes to be passed next to GNU Make's `-j' argument. ;; Number of processes to be passed next to GNU Make's `-j' argument.
(make-parameter (make-parameter

View File

@ -29,7 +29,8 @@
#:use-module (srfi srfi-60) #:use-module (srfi srfi-60)
#:use-module (rnrs bytevectors) #:use-module (rnrs bytevectors)
#:use-module ((rnrs io ports) #:select (put-bytevector)) #:use-module ((rnrs io ports) #:select (put-bytevector))
#:use-module ((guix build utils) #:select (dump-port)) #:use-module ((guix build utils)
#:select (dump-port package-name->name+version))
#:use-module ((guix build syscalls) #:select (errno mkdtemp!)) #:use-module ((guix build syscalls) #:select (errno mkdtemp!))
#:use-module (ice-9 vlist) #:use-module (ice-9 vlist)
#:use-module (ice-9 format) #:use-module (ice-9 format)
@ -39,6 +40,7 @@
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:use-module (ice-9 format) #:use-module (ice-9 format)
#:use-module (system foreign) #:use-module (system foreign)
#:re-export (package-name->name+version)
#:export (bytevector->base16-string #:export (bytevector->base16-string
base16-string->bytevector base16-string->bytevector
@ -71,7 +73,6 @@
version-prefix version-prefix
version-major+minor version-major+minor
guile-version>? guile-version>?
package-name->name+version
string-replace-substring string-replace-substring
arguments-from-environment-variable arguments-from-environment-variable
file-extension file-extension
@ -573,27 +574,6 @@ minor version numbers from version-string."
(micro-version)) (micro-version))
str)) str))
(define (package-name->name+version name)
"Given NAME, a package name like \"foo-0.9.1b\", return two values:
\"foo\" and \"0.9.1b\". When the version part is unavailable, NAME and
#f are returned. The first hyphen followed by a digit is considered to
introduce the version part."
;; See also `DrvName' in Nix.
(define number?
(cut char-set-contains? char-set:digit <>))
(let loop ((chars (string->list name))
(prefix '()))
(match chars
(()
(values name #f))
((#\- (? number? n) rest ...)
(values (list->string (reverse prefix))
(list->string (cons n rest))))
((head tail ...)
(loop tail (cons head prefix))))))
(define (file-extension file) (define (file-extension file)
"Return the extension of FILE or #f if there is none." "Return the extension of FILE or #f if there is none."
(let ((dot (string-rindex file #\.))) (let ((dot (string-rindex file #\.)))