2013-01-06 00:47:50 +01:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
|
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
|
2013-01-17 22:20:42 +01:00
|
|
|
|
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
|
2012-11-01 01:46:15 +01:00
|
|
|
|
;;;
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; This file is part of GNU Guix.
|
2012-11-01 01:46:15 +01:00
|
|
|
|
;;;
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
2012-11-01 01:46:15 +01:00
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
2012-11-01 01:46:15 +01:00
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
Replace individual scripts with master 'guix' script.
* scripts/guix.in: New script.
* Makefile.am (bin_SCRIPTS): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
(MODULES): Add 'guix/scripts/build.scm', 'guix/scripts/download.scm',
'guix/scripts/import.scm', 'guix/scripts/package.scm', and
'guix/scripts/gc.scm'.
* configure.ac (AC_CONFIG_FILES): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Remove shell script boilerplate. Move to guix-COMMAND.in
to guix/scripts/COMMAND.scm. Rename module from (guix-COMMAND) to
(guix scripts COMMAND). Change "guix-COMMAND" to "guix COMMAND" in
usage help string.
* pre-inst-env.in: Add "@abs_top_builddir@/scripts" to the front of $PATH.
Export $GUIX_UNINSTALLED.
* tests/guix-build.sh, tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-gc.sh, tests/guix-package.sh: Use "guix COMMAND" instead of
"guix-COMMAND".
* doc/guix.texi: Replace all occurrences of "guix-COMMAND" with
"guix COMMAND".
* po/POTFILES.in: Update.
2013-02-14 10:15:25 +01:00
|
|
|
|
(define-module (guix scripts package)
|
2012-11-03 21:19:43 +01:00
|
|
|
|
#:use-module (guix ui)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#:use-module (guix store)
|
|
|
|
|
#:use-module (guix derivations)
|
|
|
|
|
#:use-module (guix packages)
|
|
|
|
|
#:use-module (guix utils)
|
2012-12-13 22:53:05 +01:00
|
|
|
|
#:use-module (guix config)
|
2013-01-14 23:44:58 +01:00
|
|
|
|
#:use-module ((guix build utils) #:select (directory-exists? mkdir-p))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#:use-module (ice-9 ftw)
|
|
|
|
|
#:use-module (ice-9 format)
|
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:use-module (ice-9 regex)
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
#:use-module (ice-9 vlist)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
|
#:use-module (srfi srfi-11)
|
|
|
|
|
#:use-module (srfi srfi-26)
|
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
|
#:use-module (srfi srfi-37)
|
2013-01-18 01:06:47 +01:00
|
|
|
|
#:use-module (gnu packages)
|
2013-01-18 01:06:24 +01:00
|
|
|
|
#:use-module ((gnu packages base) #:select (guile-final))
|
|
|
|
|
#:use-module ((gnu packages bootstrap) #:select (%bootstrap-guile))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#:export (guix-package))
|
|
|
|
|
|
|
|
|
|
(define %store
|
2013-01-15 22:39:03 +01:00
|
|
|
|
(make-parameter #f))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; User environment.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define %user-environment-directory
|
|
|
|
|
(and=> (getenv "HOME")
|
|
|
|
|
(cut string-append <> "/.guix-profile")))
|
|
|
|
|
|
|
|
|
|
(define %profile-directory
|
2013-01-14 23:44:58 +01:00
|
|
|
|
(string-append (or (getenv "NIX_STATE_DIR") %state-directory) "/profiles/"
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(or (and=> (getenv "USER")
|
|
|
|
|
(cut string-append "per-user/" <>))
|
|
|
|
|
"default")))
|
|
|
|
|
|
|
|
|
|
(define %current-profile
|
2012-12-13 23:02:22 +01:00
|
|
|
|
;; Call it `guix-profile', not `profile', to allow Guix profiles to
|
|
|
|
|
;; coexist with Nix profiles.
|
|
|
|
|
(string-append %profile-directory "/guix-profile"))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
(define (profile-manifest profile)
|
|
|
|
|
"Return the PROFILE's manifest."
|
|
|
|
|
(let ((manifest (string-append profile "/manifest")))
|
|
|
|
|
(if (file-exists? manifest)
|
|
|
|
|
(call-with-input-file manifest read)
|
2013-02-06 23:01:04 +01:00
|
|
|
|
'(manifest (version 1) (packages ())))))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
(define (manifest-packages manifest)
|
|
|
|
|
"Return the packages listed in MANIFEST."
|
|
|
|
|
(match manifest
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(('manifest ('version 0)
|
|
|
|
|
('packages ((name version output path) ...)))
|
|
|
|
|
(zip name version output path
|
|
|
|
|
(make-list (length name) '())))
|
|
|
|
|
|
|
|
|
|
;; Version 1 adds a list of propagated inputs to the
|
|
|
|
|
;; name/version/output/path tuples.
|
|
|
|
|
(('manifest ('version 1)
|
|
|
|
|
('packages (packages ...)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
packages)
|
2013-02-06 23:01:04 +01:00
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(_
|
|
|
|
|
(error "unsupported manifest format" manifest))))
|
|
|
|
|
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(define (profile-regexp profile)
|
|
|
|
|
"Return a regular expression that matches PROFILE's name and number."
|
|
|
|
|
(make-regexp (string-append "^" (regexp-quote (basename profile))
|
|
|
|
|
"-([0-9]+)")))
|
|
|
|
|
|
2013-01-17 22:41:47 +01:00
|
|
|
|
(define (profile-numbers profile)
|
|
|
|
|
"Return the list of generation numbers of PROFILE, or '(0) if no
|
|
|
|
|
former profiles were found."
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(define* (scandir name #:optional (select? (const #t))
|
|
|
|
|
(entry<? (@ (ice-9 i18n) string-locale<?)))
|
|
|
|
|
;; XXX: Bug-fix version introduced in Guile v2.0.6-62-g139ce19.
|
|
|
|
|
(define (enter? dir stat result)
|
|
|
|
|
(and stat (string=? dir name)))
|
|
|
|
|
|
|
|
|
|
(define (visit basename result)
|
|
|
|
|
(if (select? basename)
|
|
|
|
|
(cons basename result)
|
|
|
|
|
result))
|
|
|
|
|
|
|
|
|
|
(define (leaf name stat result)
|
|
|
|
|
(and result
|
|
|
|
|
(visit (basename name) result)))
|
|
|
|
|
|
|
|
|
|
(define (down name stat result)
|
|
|
|
|
(visit "." '()))
|
|
|
|
|
|
|
|
|
|
(define (up name stat result)
|
|
|
|
|
(visit ".." result))
|
|
|
|
|
|
|
|
|
|
(define (skip name stat result)
|
|
|
|
|
;; All the sub-directories are skipped.
|
|
|
|
|
(visit (basename name) result))
|
|
|
|
|
|
|
|
|
|
(define (error name* stat errno result)
|
|
|
|
|
(if (string=? name name*) ; top-level NAME is unreadable
|
|
|
|
|
result
|
|
|
|
|
(visit (basename name*) result)))
|
|
|
|
|
|
|
|
|
|
(and=> (file-system-fold enter? leaf down up skip error #f name lstat)
|
|
|
|
|
(lambda (files)
|
|
|
|
|
(sort files entry<?))))
|
|
|
|
|
|
|
|
|
|
(match (scandir (dirname profile)
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(cute regexp-exec (profile-regexp profile) <>))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(#f ; no profile directory
|
2013-01-17 22:41:47 +01:00
|
|
|
|
'(0))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(() ; no profiles
|
2013-01-17 22:41:47 +01:00
|
|
|
|
'(0))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
((profiles ...) ; former profiles around
|
2013-01-17 22:41:47 +01:00
|
|
|
|
(map (compose string->number
|
|
|
|
|
(cut match:substring <> 1)
|
|
|
|
|
(cute regexp-exec (profile-regexp profile) <>))
|
|
|
|
|
profiles))))
|
|
|
|
|
|
|
|
|
|
(define (previous-profile-number profile number)
|
|
|
|
|
"Return the number of the generation before generation NUMBER of
|
|
|
|
|
PROFILE, or 0 if none exists. It could be NUMBER - 1, but it's not the
|
|
|
|
|
case when generations have been deleted (there are \"holes\")."
|
|
|
|
|
(fold (lambda (candidate highest)
|
|
|
|
|
(if (and (< candidate number) (> candidate highest))
|
|
|
|
|
candidate
|
|
|
|
|
highest))
|
|
|
|
|
0
|
|
|
|
|
(profile-numbers profile)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
(define (profile-derivation store packages)
|
|
|
|
|
"Return a derivation that builds a profile (a user environment) with
|
2013-02-06 23:01:04 +01:00
|
|
|
|
all of PACKAGES, a list of name/version/output/path/deps tuples."
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(define builder
|
|
|
|
|
`(begin
|
|
|
|
|
(use-modules (ice-9 pretty-print)
|
|
|
|
|
(guix build union))
|
|
|
|
|
|
|
|
|
|
(setvbuf (current-output-port) _IOLBF)
|
|
|
|
|
(setvbuf (current-error-port) _IOLBF)
|
|
|
|
|
|
|
|
|
|
(let ((output (assoc-ref %outputs "out"))
|
|
|
|
|
(inputs (map cdr %build-inputs)))
|
|
|
|
|
(format #t "building user environment `~a' with ~a packages...~%"
|
|
|
|
|
output (length inputs))
|
|
|
|
|
(union-build output inputs)
|
|
|
|
|
(call-with-output-file (string-append output "/manifest")
|
|
|
|
|
(lambda (p)
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(pretty-print '(manifest (version 1)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(packages ,packages))
|
|
|
|
|
p))))))
|
|
|
|
|
|
|
|
|
|
(build-expression->derivation store "user-environment"
|
|
|
|
|
(%current-system)
|
|
|
|
|
builder
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(append-map (match-lambda
|
|
|
|
|
((name version output path deps)
|
|
|
|
|
`((,name ,path)
|
|
|
|
|
,@deps)))
|
|
|
|
|
packages)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#:modules '((guix build union))))
|
|
|
|
|
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(define (profile-number profile)
|
|
|
|
|
"Return PROFILE's number or 0. An absolute file name must be used."
|
|
|
|
|
(or (and=> (false-if-exception (regexp-exec (profile-regexp profile)
|
|
|
|
|
(basename (readlink profile))))
|
|
|
|
|
(compose string->number (cut match:substring <> 1)))
|
|
|
|
|
0))
|
|
|
|
|
|
2013-01-27 17:58:46 +01:00
|
|
|
|
(define (switch-symlinks link target)
|
|
|
|
|
"Atomically switch LINK, a symbolic link, to point to TARGET. Works
|
|
|
|
|
both when LINK already exists and when it does not."
|
|
|
|
|
(let ((pivot (string-append link ".new")))
|
|
|
|
|
(symlink target pivot)
|
|
|
|
|
(rename-file pivot link)))
|
|
|
|
|
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(define (roll-back profile)
|
|
|
|
|
"Roll back to the previous generation of PROFILE."
|
2013-01-17 22:41:47 +01:00
|
|
|
|
(let* ((number (profile-number profile))
|
|
|
|
|
(previous-number (previous-profile-number profile number))
|
2013-01-22 22:35:16 +01:00
|
|
|
|
(previous-profile (format #f "~a-~a-link"
|
|
|
|
|
profile previous-number))
|
2013-01-17 22:41:47 +01:00
|
|
|
|
(manifest (string-append previous-profile "/manifest")))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
|
|
|
|
|
(define (switch-link)
|
|
|
|
|
;; Atomically switch PROFILE to the previous profile.
|
2013-01-27 17:58:46 +01:00
|
|
|
|
(format #t (_ "switching from generation ~a to ~a~%")
|
|
|
|
|
number previous-number)
|
|
|
|
|
(switch-symlinks profile previous-profile))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
|
2013-01-27 17:18:55 +01:00
|
|
|
|
(cond ((not (file-exists? profile)) ; invalid profile
|
2013-01-17 22:41:47 +01:00
|
|
|
|
(format (current-error-port)
|
2013-01-27 17:18:55 +01:00
|
|
|
|
(_ "error: profile `~a' does not exist~%")
|
2013-01-17 22:41:47 +01:00
|
|
|
|
profile))
|
2013-01-27 17:18:55 +01:00
|
|
|
|
((zero? number) ; empty profile
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "nothing to do: already at the empty profile~%")))
|
|
|
|
|
((or (zero? previous-number) ; going to emptiness
|
2013-01-17 22:41:47 +01:00
|
|
|
|
(not (file-exists? previous-profile)))
|
2013-01-27 17:18:55 +01:00
|
|
|
|
(let*-values (((drv-path drv)
|
|
|
|
|
(profile-derivation (%store) '()))
|
|
|
|
|
((prof)
|
|
|
|
|
(derivation-output-path
|
|
|
|
|
(assoc-ref (derivation-outputs drv) "out"))))
|
|
|
|
|
(when (not (build-derivations (%store) (list drv-path)))
|
|
|
|
|
(leave (_ "failed to build the empty profile~%")))
|
|
|
|
|
|
2013-01-27 17:58:46 +01:00
|
|
|
|
(switch-symlinks previous-profile prof)
|
2013-01-27 17:18:55 +01:00
|
|
|
|
(switch-link)))
|
|
|
|
|
(else (switch-link))))) ; anything else
|
2013-01-17 22:20:42 +01:00
|
|
|
|
|
2013-01-28 07:29:10 +01:00
|
|
|
|
(define (find-packages-by-description rx)
|
|
|
|
|
"Search in SYNOPSIS and DESCRIPTION using RX. Return a list of
|
|
|
|
|
matching packages."
|
|
|
|
|
(define (same-location? p1 p2)
|
|
|
|
|
;; Compare locations of two packages.
|
|
|
|
|
(equal? (package-location p1) (package-location p2)))
|
|
|
|
|
|
|
|
|
|
(delete-duplicates
|
|
|
|
|
(sort
|
|
|
|
|
(fold-packages (lambda (package result)
|
|
|
|
|
(define matches?
|
|
|
|
|
(cut regexp-exec rx <>))
|
|
|
|
|
|
|
|
|
|
(if (or (and=> (package-synopsis package)
|
|
|
|
|
(compose matches? gettext))
|
|
|
|
|
(and=> (package-description package)
|
|
|
|
|
(compose matches? gettext)))
|
|
|
|
|
(cons package result)
|
|
|
|
|
result))
|
|
|
|
|
'())
|
|
|
|
|
(lambda (p1 p2)
|
|
|
|
|
(string<? (package-name p1)
|
|
|
|
|
(package-name p2))))
|
|
|
|
|
same-location?))
|
|
|
|
|
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(define (input->name+path input)
|
|
|
|
|
"Convert the name/package/sub-drv tuple INPUT to a name/store-path tuple."
|
|
|
|
|
(let loop ((input input))
|
|
|
|
|
(match input
|
|
|
|
|
((name package)
|
|
|
|
|
(loop `(,name ,package "out")))
|
|
|
|
|
((name package sub-drv)
|
|
|
|
|
(let*-values (((_ drv)
|
|
|
|
|
(package-derivation (%store) package))
|
|
|
|
|
((out)
|
|
|
|
|
(derivation-output-path
|
|
|
|
|
(assoc-ref (derivation-outputs drv) sub-drv))))
|
|
|
|
|
`(,name ,out))))))
|
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Command-line options.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define %default-options
|
|
|
|
|
;; Alist of default option values.
|
|
|
|
|
`((profile . ,%current-profile)))
|
|
|
|
|
|
|
|
|
|
(define (show-help)
|
Replace individual scripts with master 'guix' script.
* scripts/guix.in: New script.
* Makefile.am (bin_SCRIPTS): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
(MODULES): Add 'guix/scripts/build.scm', 'guix/scripts/download.scm',
'guix/scripts/import.scm', 'guix/scripts/package.scm', and
'guix/scripts/gc.scm'.
* configure.ac (AC_CONFIG_FILES): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Remove shell script boilerplate. Move to guix-COMMAND.in
to guix/scripts/COMMAND.scm. Rename module from (guix-COMMAND) to
(guix scripts COMMAND). Change "guix-COMMAND" to "guix COMMAND" in
usage help string.
* pre-inst-env.in: Add "@abs_top_builddir@/scripts" to the front of $PATH.
Export $GUIX_UNINSTALLED.
* tests/guix-build.sh, tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-gc.sh, tests/guix-package.sh: Use "guix COMMAND" instead of
"guix-COMMAND".
* doc/guix.texi: Replace all occurrences of "guix-COMMAND" with
"guix COMMAND".
* po/POTFILES.in: Update.
2013-02-14 10:15:25 +01:00
|
|
|
|
(display (_ "Usage: guix package [OPTION]... PACKAGES...
|
2012-11-01 01:46:15 +01:00
|
|
|
|
Install, remove, or upgrade PACKAGES in a single transaction.\n"))
|
|
|
|
|
(display (_ "
|
|
|
|
|
-i, --install=PACKAGE install PACKAGE"))
|
|
|
|
|
(display (_ "
|
|
|
|
|
-r, --remove=PACKAGE remove PACKAGE"))
|
|
|
|
|
(display (_ "
|
|
|
|
|
-u, --upgrade=REGEXP upgrade all the installed packages matching REGEXP"))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(display (_ "
|
|
|
|
|
--roll-back roll back to the previous generation"))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(newline)
|
|
|
|
|
(display (_ "
|
|
|
|
|
-p, --profile=PROFILE use PROFILE instead of the user's default profile"))
|
|
|
|
|
(display (_ "
|
|
|
|
|
-n, --dry-run show what would be done without actually doing it"))
|
|
|
|
|
(display (_ "
|
2013-01-07 22:54:54 +01:00
|
|
|
|
--bootstrap use the bootstrap Guile to build the profile"))
|
2012-12-12 14:59:16 +01:00
|
|
|
|
(display (_ "
|
|
|
|
|
--verbose produce verbose output"))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(newline)
|
|
|
|
|
(display (_ "
|
2013-01-28 07:29:10 +01:00
|
|
|
|
-s, --search=REGEXP search in synopsis and description using REGEXP"))
|
|
|
|
|
(display (_ "
|
2012-11-19 22:39:45 +01:00
|
|
|
|
-I, --list-installed[=REGEXP]
|
|
|
|
|
list installed packages matching REGEXP"))
|
2012-11-19 23:02:59 +01:00
|
|
|
|
(display (_ "
|
|
|
|
|
-A, --list-available[=REGEXP]
|
|
|
|
|
list available packages matching REGEXP"))
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(newline)
|
|
|
|
|
(display (_ "
|
2012-11-01 01:46:15 +01:00
|
|
|
|
-h, --help display this help and exit"))
|
|
|
|
|
(display (_ "
|
|
|
|
|
-V, --version display version information and exit"))
|
|
|
|
|
(newline)
|
2013-01-05 15:55:47 +01:00
|
|
|
|
(show-bug-report-information))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
(define %options
|
|
|
|
|
;; Specification of the command-line options.
|
|
|
|
|
(list (option '(#\h "help") #f #f
|
|
|
|
|
(lambda args
|
|
|
|
|
(show-help)
|
|
|
|
|
(exit 0)))
|
|
|
|
|
(option '(#\V "version") #f #f
|
|
|
|
|
(lambda args
|
2013-02-17 16:25:30 +01:00
|
|
|
|
(show-version-and-exit "guix package")))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
(option '(#\i "install") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'install arg result)))
|
|
|
|
|
(option '(#\r "remove") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'remove arg result)))
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
(option '(#\u "upgrade") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'upgrade arg result)))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(option '("roll-back") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'roll-back? #t result)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(option '(#\p "profile") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'profile arg
|
|
|
|
|
(alist-delete 'profile result))))
|
|
|
|
|
(option '(#\n "dry-run") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'dry-run? #t result)))
|
2013-01-07 22:54:54 +01:00
|
|
|
|
(option '("bootstrap") #f #f
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(lambda (opt name arg result)
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(alist-cons 'bootstrap? #t result)))
|
2012-12-12 14:59:16 +01:00
|
|
|
|
(option '("verbose") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'verbose? #t result)))
|
2013-01-28 07:29:10 +01:00
|
|
|
|
(option '(#\s "search") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(cons `(query search ,(or arg ""))
|
|
|
|
|
result)))
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(option '(#\I "list-installed") #f #t
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(cons `(query list-installed ,(or arg ""))
|
2012-11-19 23:02:59 +01:00
|
|
|
|
result)))
|
|
|
|
|
(option '(#\A "list-available") #f #t
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(cons `(query list-available ,(or arg ""))
|
2012-11-19 22:39:45 +01:00
|
|
|
|
result)))))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Entry point.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (guix-package . args)
|
|
|
|
|
(define (parse-options)
|
|
|
|
|
;; Return the alist of option values.
|
|
|
|
|
(args-fold args %options
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(leave (_ "~A: unrecognized option~%") name))
|
|
|
|
|
(lambda (arg result)
|
2013-01-24 22:00:54 +01:00
|
|
|
|
(leave (_ "~A: extraneous argument~%") arg))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
%default-options))
|
|
|
|
|
|
2013-01-07 23:58:24 +01:00
|
|
|
|
(define (guile-missing?)
|
|
|
|
|
;; Return #t if %GUILE-FOR-BUILD is not available yet.
|
|
|
|
|
(let ((out (derivation-path->output-path (%guile-for-build))))
|
2013-01-15 22:39:03 +01:00
|
|
|
|
(not (valid-path? (%store) out))))
|
2013-01-07 23:58:24 +01:00
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(define (show-what-to-build drv dry-run?)
|
|
|
|
|
;; Show what will/would be built in realizing the derivations listed
|
|
|
|
|
;; in DRV.
|
|
|
|
|
(let* ((req (append-map (lambda (drv-path)
|
|
|
|
|
(let ((d (call-with-input-file drv-path
|
|
|
|
|
read-derivation)))
|
2013-01-15 22:39:03 +01:00
|
|
|
|
(derivation-prerequisites-to-build
|
|
|
|
|
(%store) d)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
drv))
|
|
|
|
|
(req* (delete-duplicates
|
2013-01-15 22:39:03 +01:00
|
|
|
|
(append (remove (compose (cute valid-path? (%store) <>)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
derivation-path->output-path)
|
|
|
|
|
drv)
|
|
|
|
|
(map derivation-input-path req)))))
|
|
|
|
|
(if dry-run?
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(N_ "~:[the following derivation would be built:~%~{ ~a~%~}~;~]"
|
|
|
|
|
"~:[the following derivations would be built:~%~{ ~a~%~}~;~]"
|
|
|
|
|
(length req*))
|
|
|
|
|
(null? req*) req*)
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(N_ "~:[the following derivation will be built:~%~{ ~a~%~}~;~]"
|
|
|
|
|
"~:[the following derivations will be built:~%~{ ~a~%~}~;~]"
|
|
|
|
|
(length req*))
|
|
|
|
|
(null? req*) req*))))
|
|
|
|
|
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
(define newest-available-packages
|
|
|
|
|
(memoize find-newest-available-packages))
|
|
|
|
|
|
|
|
|
|
(define (find-best-packages-by-name name version)
|
|
|
|
|
(if version
|
|
|
|
|
(find-packages-by-name name version)
|
|
|
|
|
(match (vhash-assoc name (newest-available-packages))
|
|
|
|
|
((_ version pkgs ...) pkgs)
|
|
|
|
|
(#f '()))))
|
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(define (find-package name)
|
|
|
|
|
;; Find the package NAME; NAME may contain a version number and a
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
;; sub-derivation name. If the version number is not present,
|
|
|
|
|
;; return the preferred newest version.
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(define request name)
|
|
|
|
|
|
2013-02-01 09:17:35 +01:00
|
|
|
|
(define (ensure-output p sub-drv)
|
|
|
|
|
(if (member sub-drv (package-outputs p))
|
|
|
|
|
p
|
|
|
|
|
(leave (_ "~a: error: package `~a' lacks output `~a'~%")
|
|
|
|
|
(location->string (package-location p))
|
|
|
|
|
(package-full-name p)
|
|
|
|
|
sub-drv)))
|
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(let*-values (((name sub-drv)
|
|
|
|
|
(match (string-rindex name #\:)
|
|
|
|
|
(#f (values name "out"))
|
2012-11-07 19:14:22 +01:00
|
|
|
|
(colon (values (substring name 0 colon)
|
|
|
|
|
(substring name (+ 1 colon))))))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
((name version)
|
2012-11-04 01:29:18 +01:00
|
|
|
|
(package-name->name+version name)))
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
(match (find-best-packages-by-name name version)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
((p)
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(list name (package-version p) sub-drv (ensure-output p sub-drv)
|
|
|
|
|
(package-transitive-propagated-inputs p)))
|
2012-11-19 22:19:26 +01:00
|
|
|
|
((p p* ...)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "warning: ambiguous package specification `~a'~%")
|
|
|
|
|
request)
|
|
|
|
|
(format (current-error-port)
|
2012-11-19 23:21:54 +01:00
|
|
|
|
(_ "warning: choosing ~a from ~a~%")
|
|
|
|
|
(package-full-name p)
|
|
|
|
|
(location->string (package-location p)))
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(list name (package-version p) sub-drv (ensure-output p sub-drv)
|
|
|
|
|
(package-transitive-propagated-inputs p)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(()
|
|
|
|
|
(leave (_ "~a: package not found~%") request)))))
|
|
|
|
|
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
(define (upgradeable? name current-version current-path)
|
|
|
|
|
;; Return #t if there's a version of package NAME newer than
|
|
|
|
|
;; CURRENT-VERSION, or if the newest available version is equal to
|
|
|
|
|
;; CURRENT-VERSION but would have an output path different than
|
|
|
|
|
;; CURRENT-PATH.
|
|
|
|
|
(match (vhash-assoc name (newest-available-packages))
|
|
|
|
|
((_ candidate-version pkg . rest)
|
|
|
|
|
(case (version-compare candidate-version current-version)
|
|
|
|
|
((>) #t)
|
|
|
|
|
((<) #f)
|
|
|
|
|
((=) (let ((candidate-path (derivation-path->output-path
|
|
|
|
|
(package-derivation (%store) pkg))))
|
|
|
|
|
(not (string=? current-path candidate-path))))))
|
|
|
|
|
(#f #f)))
|
|
|
|
|
|
2013-01-14 23:44:58 +01:00
|
|
|
|
(define (ensure-default-profile)
|
|
|
|
|
;; Ensure the default profile symlink and directory exist.
|
|
|
|
|
|
|
|
|
|
;; Create ~/.guix-profile if it doesn't exist yet.
|
|
|
|
|
(when (and %user-environment-directory
|
|
|
|
|
%current-profile
|
|
|
|
|
(not (false-if-exception
|
|
|
|
|
(lstat %user-environment-directory))))
|
|
|
|
|
(symlink %current-profile %user-environment-directory))
|
|
|
|
|
|
|
|
|
|
;; Attempt to create /…/profiles/per-user/$USER if needed.
|
|
|
|
|
(unless (directory-exists? %profile-directory)
|
|
|
|
|
(catch 'system-error
|
|
|
|
|
(lambda ()
|
|
|
|
|
(mkdir-p %profile-directory))
|
|
|
|
|
(lambda args
|
|
|
|
|
;; Often, we cannot create %PROFILE-DIRECTORY because its
|
|
|
|
|
;; parent directory is root-owned and we're running
|
|
|
|
|
;; unprivileged.
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "error: while creating directory `~a': ~a~%")
|
|
|
|
|
%profile-directory
|
|
|
|
|
(strerror (system-error-errno args)))
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "Please create the `~a' directory, with you as the owner.~%")
|
|
|
|
|
%profile-directory)
|
|
|
|
|
(exit 1)))))
|
|
|
|
|
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(define (process-actions opts)
|
|
|
|
|
;; Process any install/remove/upgrade action from OPTS.
|
2013-01-17 22:20:42 +01:00
|
|
|
|
|
|
|
|
|
(define dry-run? (assoc-ref opts 'dry-run?))
|
|
|
|
|
(define verbose? (assoc-ref opts 'verbose?))
|
|
|
|
|
(define profile (assoc-ref opts 'profile))
|
|
|
|
|
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(define (canonicalize-deps deps)
|
|
|
|
|
;; Remove duplicate entries from DEPS, a list of propagated inputs,
|
|
|
|
|
;; where each input is a name/path tuple.
|
|
|
|
|
(define (same? d1 d2)
|
|
|
|
|
(match d1
|
|
|
|
|
((_ path1)
|
|
|
|
|
(match d2
|
|
|
|
|
((_ path2)
|
|
|
|
|
(string=? path1 path2))))))
|
|
|
|
|
|
|
|
|
|
(delete-duplicates (map input->name+path deps) same?))
|
|
|
|
|
|
2013-01-17 22:20:42 +01:00
|
|
|
|
;; First roll back if asked to.
|
|
|
|
|
(if (and (assoc-ref opts 'roll-back?) (not dry-run?))
|
|
|
|
|
(begin
|
|
|
|
|
(roll-back profile)
|
|
|
|
|
(process-actions (alist-delete 'roll-back? opts)))
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
(let* ((installed (manifest-packages (profile-manifest profile)))
|
|
|
|
|
(upgrade-regexps (filter-map (match-lambda
|
|
|
|
|
(('upgrade . regexp)
|
|
|
|
|
(make-regexp regexp))
|
|
|
|
|
(_ #f))
|
|
|
|
|
opts))
|
|
|
|
|
(upgrade (if (null? upgrade-regexps)
|
|
|
|
|
'()
|
|
|
|
|
(let ((newest (find-newest-available-packages)))
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
((name version output path _)
|
|
|
|
|
(and (any (cut regexp-exec <> name)
|
|
|
|
|
upgrade-regexps)
|
|
|
|
|
(upgradeable? name version path)
|
|
|
|
|
(find-package name)))
|
|
|
|
|
(_ #f))
|
|
|
|
|
installed))))
|
|
|
|
|
(install (append
|
|
|
|
|
upgrade
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
(('install . (? store-path?))
|
|
|
|
|
#f)
|
|
|
|
|
(('install . package)
|
|
|
|
|
(find-package package))
|
|
|
|
|
(_ #f))
|
|
|
|
|
opts)))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(drv (filter-map (match-lambda
|
|
|
|
|
((name version sub-drv
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(? package? package)
|
|
|
|
|
(deps ...))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(package-derivation (%store) package))
|
|
|
|
|
(_ #f))
|
|
|
|
|
install))
|
|
|
|
|
(install* (append
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
(('install . (? store-path? path))
|
|
|
|
|
(let-values (((name version)
|
|
|
|
|
(package-name->name+version
|
|
|
|
|
(store-path-package-name
|
|
|
|
|
path))))
|
2013-02-06 23:01:04 +01:00
|
|
|
|
`(,name ,version #f ,path ())))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(_ #f))
|
|
|
|
|
opts)
|
|
|
|
|
(map (lambda (tuple drv)
|
|
|
|
|
(match tuple
|
2013-02-06 23:01:04 +01:00
|
|
|
|
((name version sub-drv _ (deps ...))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(let ((output-path
|
|
|
|
|
(derivation-path->output-path
|
|
|
|
|
drv sub-drv)))
|
2013-02-06 23:01:04 +01:00
|
|
|
|
`(,name ,version ,sub-drv ,output-path
|
|
|
|
|
,(canonicalize-deps deps))))))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
install drv)))
|
|
|
|
|
(remove (filter-map (match-lambda
|
|
|
|
|
(('remove . package)
|
|
|
|
|
package)
|
|
|
|
|
(_ #f))
|
|
|
|
|
opts))
|
|
|
|
|
(packages (append install*
|
|
|
|
|
(fold (lambda (package result)
|
|
|
|
|
(match package
|
|
|
|
|
((name _ ...)
|
|
|
|
|
(alist-delete name result))))
|
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages):
New exported procedure.
* guix-build.in (newest-available-packages, find-best-packages-by-name):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
* guix-package.in (%options): Add --upgrade/-u option.
(newest-available-packages, find-best-packages-by-name, upgradeable?):
New procedures.
(find-package): Use find-best-packages-by-name, to guarantee that
if a version number is not specified, only the newest versions will
be considered.
(process-actions): Implement upgrade option.
* doc/guix.texi (Invoking guix-package): In the description of --install,
mention that if no version number is specified, the newest available
version will be selected.
2013-02-12 07:24:21 +01:00
|
|
|
|
(fold alist-delete installed remove)
|
2013-01-17 22:20:42 +01:00
|
|
|
|
install*))))
|
|
|
|
|
|
|
|
|
|
(when (equal? profile %current-profile)
|
|
|
|
|
(ensure-default-profile))
|
|
|
|
|
|
|
|
|
|
(show-what-to-build drv dry-run?)
|
|
|
|
|
|
|
|
|
|
(or dry-run?
|
|
|
|
|
(and (build-derivations (%store) drv)
|
|
|
|
|
(let* ((prof-drv (profile-derivation (%store) packages))
|
|
|
|
|
(prof (derivation-path->output-path prof-drv))
|
|
|
|
|
(old-drv (profile-derivation
|
|
|
|
|
(%store) (manifest-packages
|
|
|
|
|
(profile-manifest profile))))
|
|
|
|
|
(old-prof (derivation-path->output-path old-drv))
|
2013-01-27 17:58:46 +01:00
|
|
|
|
(number (profile-number profile))
|
|
|
|
|
|
|
|
|
|
;; Always use NUMBER + 1 for the new profile,
|
|
|
|
|
;; possibly overwriting a "previous future
|
|
|
|
|
;; generation".
|
|
|
|
|
(name (format #f "~a-~a-link"
|
|
|
|
|
profile (+ 1 number))))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(if (string=? old-prof prof)
|
|
|
|
|
(when (or (pair? install) (pair? remove))
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "nothing to be done~%")))
|
|
|
|
|
(and (parameterize ((current-build-output-port
|
|
|
|
|
;; Output something when Guile
|
|
|
|
|
;; needs to be built.
|
|
|
|
|
(if (or verbose? (guile-missing?))
|
|
|
|
|
(current-error-port)
|
|
|
|
|
(%make-void-port "w"))))
|
|
|
|
|
(build-derivations (%store) (list prof-drv)))
|
|
|
|
|
(begin
|
2013-01-27 17:58:46 +01:00
|
|
|
|
(switch-symlinks name prof)
|
|
|
|
|
(switch-symlinks profile name))))))))))
|
2012-11-19 22:39:45 +01:00
|
|
|
|
|
|
|
|
|
(define (process-query opts)
|
|
|
|
|
;; Process any query specified by OPTS. Return #t when a query was
|
|
|
|
|
;; actually processed, #f otherwise.
|
|
|
|
|
(let ((profile (assoc-ref opts 'profile)))
|
|
|
|
|
(match (assoc-ref opts 'query)
|
|
|
|
|
(('list-installed regexp)
|
|
|
|
|
(let* ((regexp (and regexp (make-regexp regexp)))
|
|
|
|
|
(manifest (profile-manifest profile))
|
|
|
|
|
(installed (manifest-packages manifest)))
|
|
|
|
|
(for-each (match-lambda
|
2013-02-06 23:01:04 +01:00
|
|
|
|
((name version output path _)
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(when (or (not regexp)
|
|
|
|
|
(regexp-exec regexp name))
|
|
|
|
|
(format #t "~a\t~a\t~a\t~a~%"
|
|
|
|
|
name (or version "?") output path))))
|
2012-11-19 23:02:59 +01:00
|
|
|
|
installed)
|
|
|
|
|
#t))
|
2013-01-28 07:29:10 +01:00
|
|
|
|
|
2012-11-19 23:02:59 +01:00
|
|
|
|
(('list-available regexp)
|
|
|
|
|
(let* ((regexp (and regexp (make-regexp regexp)))
|
|
|
|
|
(available (fold-packages
|
|
|
|
|
(lambda (p r)
|
|
|
|
|
(let ((n (package-name p)))
|
|
|
|
|
(if regexp
|
|
|
|
|
(if (regexp-exec regexp n)
|
|
|
|
|
(cons p r)
|
|
|
|
|
r)
|
|
|
|
|
(cons p r))))
|
|
|
|
|
'())))
|
|
|
|
|
(for-each (lambda (p)
|
2013-01-09 19:26:37 +01:00
|
|
|
|
(format #t "~a\t~a\t~a\t~a~%"
|
2012-11-19 23:02:59 +01:00
|
|
|
|
(package-name p)
|
|
|
|
|
(package-version p)
|
2013-01-09 19:26:37 +01:00
|
|
|
|
(string-join (package-outputs p) ",")
|
2012-11-19 23:02:59 +01:00
|
|
|
|
(location->string (package-location p))))
|
|
|
|
|
(sort available
|
|
|
|
|
(lambda (p1 p2)
|
|
|
|
|
(string<? (package-name p1)
|
|
|
|
|
(package-name p2)))))
|
|
|
|
|
#t))
|
2013-01-28 07:29:10 +01:00
|
|
|
|
|
|
|
|
|
(('search regexp)
|
2013-02-01 12:52:35 +01:00
|
|
|
|
(let ((regexp (make-regexp regexp regexp/icase)))
|
2013-02-01 13:16:27 +01:00
|
|
|
|
(for-each (cute package->recutils <> (current-output-port))
|
2013-01-28 07:29:10 +01:00
|
|
|
|
(find-packages-by-description regexp))
|
|
|
|
|
#t))
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(_ #f))))
|
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(let ((opts (parse-options)))
|
2013-01-31 23:24:10 +01:00
|
|
|
|
(or (process-query opts)
|
|
|
|
|
(parameterize ((%store (open-connection)))
|
|
|
|
|
(with-error-handling
|
2013-01-15 22:39:03 +01:00
|
|
|
|
(parameterize ((%guile-for-build
|
|
|
|
|
(package-derivation (%store)
|
|
|
|
|
(if (assoc-ref opts 'bootstrap?)
|
|
|
|
|
%bootstrap-guile
|
|
|
|
|
guile-final))))
|
|
|
|
|
(process-actions opts)))))))
|