gnu: Add 'version-prefix' and 'version-major+minor'; use them.

The procedure version-prefix truncates a version string to a certain
number of components. version-major+minor is a special case of this,
which extracts the "major.minor" part of the string. Previously this
was handled by an expression common to several packages.

* guix/utils.scm (version-prefix, version-major+minor): New procedures
* gnu/packages/backup.scm (duplicity): Use version-major+minor.
* gnu/packages/cmake.scm (cmake): Likewise.
* gnu/packages/gnome.scm (libbonobo, libbonoboui): Likewise.
* gnu/packages/gnutls.scm (gnutls): Likewise.
* gnu/packages/mail.scm (gmime): Likewise.
* gnu/packages/mpd.scm (mpd): Likewise.
* gnu/packages/mpi.scm (openmpi): Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Ian Denhardt 2014-10-18 22:03:42 -04:00 committed by Ludovic Courtès
parent 38bf090e7c
commit 29a7c98a42
8 changed files with 43 additions and 30 deletions

View file

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -20,6 +21,7 @@ (define-module (gnu packages backup)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build utils) #:use-module (guix build utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (guix build-system python) #:use-module (guix build-system python)
@ -38,8 +40,7 @@ (define-module (gnu packages backup)
#:use-module (gnu packages pkg-config) #:use-module (gnu packages pkg-config)
#:use-module (gnu packages rsync) #:use-module (gnu packages rsync)
#:use-module (gnu packages ssh) #:use-module (gnu packages ssh)
#:use-module (gnu packages xml) #:use-module (gnu packages xml))
#:use-module (srfi srfi-1))
(define-public duplicity (define-public duplicity
(package (package
@ -49,7 +50,7 @@ (define-public duplicity
(origin (origin
(method url-fetch) (method url-fetch)
(uri (string-append "https://code.launchpad.net/duplicity/" (uri (string-append "https://code.launchpad.net/duplicity/"
(string-join (take (string-split version #\.) 2) ".") (version-major+minor version)
"-series/" version "/+download/duplicity-" "-series/" version "/+download/duplicity-"
version ".tar.gz")) version ".tar.gz"))
(sha256 (sha256

View file

@ -2,6 +2,7 @@
;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -22,14 +23,14 @@ (define-module (gnu packages cmake)
#:use-module ((guix licenses) #:select (bsd-3)) #:use-module ((guix licenses) #:select (bsd-3))
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu packages backup) #:use-module (gnu packages backup)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages curl) #:use-module (gnu packages curl)
#:use-module (gnu packages file) #:use-module (gnu packages file)
#:use-module (gnu packages xml) #:use-module (gnu packages xml))
#:use-module (srfi srfi-1))
(define-public cmake (define-public cmake
(package (package
@ -39,8 +40,7 @@ (define-public cmake
(method url-fetch) (method url-fetch)
(uri (string-append (uri (string-append
"http://www.cmake.org/files/v" "http://www.cmake.org/files/v"
(string-join (take (string-split version #\.) 2) (version-major+minor version)
".")
"/cmake-" version ".tar.gz")) "/cmake-" version ".tar.gz"))
(sha256 (sha256
(base32 "11q21vyrr6c6smyjy81k2k07zmn96ggjia9im9cxwvj0n88bm1fq")) (base32 "11q21vyrr6c6smyjy81k2k07zmn96ggjia9im9cxwvj0n88bm1fq"))
@ -91,8 +91,7 @@ (define-public cmake
"--mandir=share/man" "--mandir=share/man"
,(string-append ,(string-append
"--docdir=share/doc/cmake-" "--docdir=share/doc/cmake-"
(string-join (take (string-split version #\.) 2) (version-major+minor version))))))
"."))))))
%standard-phases))))) %standard-phases)))))
(inputs (inputs
`(("file" ,file) `(("file" ,file)

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr> ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -21,6 +22,7 @@ (define-module (gnu packages gnome)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu packages bison) #:use-module (gnu packages bison)
@ -42,8 +44,7 @@ (define-module (gnu packages gnome)
#:use-module (gnu packages xml) #:use-module (gnu packages xml)
#:use-module (gnu packages gl) #:use-module (gnu packages gl)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages xorg) #:use-module (gnu packages xorg))
#:use-module (srfi srfi-1))
(define-public brasero (define-public brasero
(package (package
@ -706,8 +707,7 @@ (define-public libbonobo
(source (origin (source (origin
(method url-fetch) (method url-fetch)
(uri (string-append "mirror://gnome/sources/" name "/" (uri (string-append "mirror://gnome/sources/" name "/"
(string-join (take (string-split version #\.) 2) (version-major+minor version)
".")
"/" name "-" version ".tar.bz2")) "/" name "-" version ".tar.bz2"))
(sha256 (sha256
(base32 "0swp4kk6x7hy1rvd1f9jba31lvfc6qvafkvbpg9h0r34fzrd8q4i")) (base32 "0swp4kk6x7hy1rvd1f9jba31lvfc6qvafkvbpg9h0r34fzrd8q4i"))
@ -1077,7 +1077,7 @@ (define-public libbonoboui
(method url-fetch) (method url-fetch)
(uri (string-append (uri (string-append
"mirror://gnome/sources/" name "/" "mirror://gnome/sources/" name "/"
(string-join (take (string-split version #\.) 2) ".") (version-major+minor version)
"/" name "-" version ".tar.bz2")) "/" name "-" version ".tar.bz2"))
(sha256 (sha256
(base32 (base32

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -21,6 +22,7 @@ (define-module (gnu packages gnutls)
#:use-module (guix licenses) #:use-module (guix licenses)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module ((gnu packages compression) #:prefix guix:) #:use-module ((gnu packages compression) #:prefix guix:)
#:use-module (gnu packages) #:use-module (gnu packages)
@ -29,8 +31,7 @@ (define-module (gnu packages gnutls)
#:use-module (gnu packages perl) #:use-module (gnu packages perl)
#:use-module (gnu packages which) #:use-module (gnu packages which)
#:use-module (gnu packages texinfo) #:use-module (gnu packages texinfo)
#:use-module (gnu packages pkg-config) #:use-module (gnu packages pkg-config))
#:use-module (srfi srfi-1))
(define-public libtasn1 (define-public libtasn1
(package (package
@ -69,8 +70,7 @@ (define-public gnutls
;; Note: Releases are no longer on ftp.gnu.org since the ;; Note: Releases are no longer on ftp.gnu.org since the
;; schism (after version 3.1.5). ;; schism (after version 3.1.5).
(string-append "mirror://gnupg/gnutls/v" (string-append "mirror://gnupg/gnutls/v"
(string-join (take (string-split version #\.) 2) (version-major+minor version)
".")
"/gnutls-" version ".tar.xz")) "/gnutls-" version ".tar.xz"))
(sha256 (sha256
(base32 (base32

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -49,9 +50,9 @@ (define-module (gnu packages mail)
#:select (gpl2 gpl2+ gpl3+ lgpl2.1+ lgpl3+)) #:select (gpl2 gpl2+ gpl3+ lgpl2.1+ lgpl3+))
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (guix build-system python) #:use-module (guix build-system python))
#:use-module (srfi srfi-1))
(define-public mailutils (define-public mailutils
(package (package
@ -192,9 +193,7 @@ (define-public gmime
(source (origin (source (origin
(method url-fetch) (method url-fetch)
(uri (string-append "mirror://gnome/sources/gmime/" (uri (string-append "mirror://gnome/sources/gmime/"
(string-join (take (string-split version #\.) (version-major+minor version)
2)
".")
"/gmime-" version ".tar.xz")) "/gmime-" version ".tar.xz"))
(sha256 (sha256
(base32 (base32

View file

@ -2,6 +2,7 @@
;;; Copyright © 2014 David Thompson <dthompson2@worcester.edu> ;;; Copyright © 2014 David Thompson <dthompson2@worcester.edu>
;;; Copyright © 2014 Andreas Enge <andreas@enge.fr> ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2014 Cyrill Schenkel <cyrill.schenkel@gmail.com> ;;; Copyright © 2014 Cyrill Schenkel <cyrill.schenkel@gmail.com>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -19,11 +20,11 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages mpd) (define-module (gnu packages mpd)
#:use-module (srfi srfi-1)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages avahi) #:use-module (gnu packages avahi)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
@ -72,8 +73,7 @@ (define mpd
(method url-fetch) (method url-fetch)
(uri (uri
(string-append "http://musicpd.org/download/mpd/" (string-append "http://musicpd.org/download/mpd/"
(string-join (take (string-split (version-major+minor version)
version #\.) 2) ".")
"/mpd-" version ".tar.gz")) "/mpd-" version ".tar.gz"))
(sha256 (sha256
(base32 (base32

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -22,6 +23,7 @@ (define-module (gnu packages mpi)
#:use-module ((guix licenses) #:use-module ((guix licenses)
#:hide (expat)) #:hide (expat))
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu packages gcc) #:use-module (gnu packages gcc)
@ -32,8 +34,7 @@ (define-module (gnu packages mpi)
#:use-module (gnu packages xml) #:use-module (gnu packages xml)
#:use-module (gnu packages ncurses) #:use-module (gnu packages ncurses)
#:use-module (gnu packages pkg-config) #:use-module (gnu packages pkg-config)
#:use-module (gnu packages valgrind) #:use-module (gnu packages valgrind))
#:use-module (srfi srfi-1))
(define-public hwloc (define-public hwloc
(package (package
@ -88,8 +89,7 @@ (define-public openmpi
(origin (origin
(method url-fetch) (method url-fetch)
(uri (string-append "http://www.open-mpi.org/software/ompi/v" (uri (string-append "http://www.open-mpi.org/software/ompi/v"
(string-join (take (string-split version #\.) 2) (version-major+minor version)
".")
"/downloads/openmpi-" version ".tar.bz2")) "/downloads/openmpi-" version ".tar.bz2"))
(sha256 (sha256
(base32 (base32

View file

@ -2,6 +2,7 @@
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -65,6 +66,8 @@ (define-module (guix utils)
%current-target-system %current-target-system
version-compare version-compare
version>? version>?
version-prefix
version-major+minor
guile-version>? guile-version>?
package-name->name+version package-name->name+version
string-tokenize* string-tokenize*
@ -518,6 +521,17 @@ (define version-compare
((negative? result) '<) ((negative? result) '<)
(else '=)))))) (else '=))))))
(define (version-prefix version-string num-parts)
"Truncate version-string to the first num-parts components of the version.
For example, (version-prefix \"2.1.47.4.23\" 3) returns \"2.1.47\""
(string-join (take (string-split version-string #\.) num-parts) "."))
(define (version-major+minor version-string)
"Return \"<major>.<minor>\", where major and minor are the major and
minor version numbers from version-string."
(version-prefix version-string 2))
(define (version>? a b) (define (version>? a b)
"Return #t when A denotes a newer version than B." "Return #t when A denotes a newer version than B."
(eq? '> (version-compare a b))) (eq? '> (version-compare a b)))