2013-01-06 00:47:50 +01:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2014-01-04 22:42:42 +01:00
|
|
|
|
;;; Copyright © 2012, 2013, 2014 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)
|
Add (guix profiles).
* guix/scripts/package.scm (show-what-to-remove/install): New procedure,
moved from...
(guix-package): ... here.
(<manifest>, make-manifest, <manifest-entry>,
profile-manifest, manifest->sexp, sexp->manifest, read-manifest,
write-manifest, remove-manifest-entry, manifest-remove,
manifest-installed?, manifest=?, profile-regexp, generation-numbers,
previous-generation-number, profile-derivation, generation-number,
generation-file-name, generation-time, lower-input): Move to...
* guix/profiles.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
2013-11-01 16:31:45 +01:00
|
|
|
|
#:use-module (guix profiles)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#: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))
|
2013-07-12 22:59:33 +02:00
|
|
|
|
#:use-module ((guix ftp-client) #:select (ftp-open))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#: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)
|
2013-09-19 13:07:39 +02:00
|
|
|
|
#:use-module (srfi srfi-19)
|
2012-11-01 01:46:15 +01:00
|
|
|
|
#:use-module (srfi srfi-26)
|
|
|
|
|
#: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))
|
2013-03-05 20:30:27 +01:00
|
|
|
|
#:use-module (guix gnu-maintenance)
|
2013-12-22 01:08:21 +01:00
|
|
|
|
#:export (specification->package+output
|
|
|
|
|
guix-package))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
(define %store
|
2013-01-15 22:39:03 +01:00
|
|
|
|
(make-parameter #f))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
Add (guix profiles).
* guix/scripts/package.scm (show-what-to-remove/install): New procedure,
moved from...
(guix-package): ... here.
(<manifest>, make-manifest, <manifest-entry>,
profile-manifest, manifest->sexp, sexp->manifest, read-manifest,
write-manifest, remove-manifest-entry, manifest-remove,
manifest-installed?, manifest=?, profile-regexp, generation-numbers,
previous-generation-number, profile-derivation, generation-number,
generation-file-name, generation-time, lower-input): Move to...
* guix/profiles.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
2013-11-01 16:31:45 +01:00
|
|
|
|
;;; Profiles.
|
2012-11-01 01:46:15 +01:00
|
|
|
|
;;;
|
|
|
|
|
|
2013-10-30 17:31:05 +01:00
|
|
|
|
(define %user-profile-directory
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(and=> (getenv "HOME")
|
|
|
|
|
(cut string-append <> "/.guix-profile")))
|
|
|
|
|
|
|
|
|
|
(define %profile-directory
|
2014-01-08 21:12:55 +01:00
|
|
|
|
(string-append %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
|
|
|
|
|
2013-09-25 05:34:49 +02:00
|
|
|
|
(define (link-to-empty-profile generation)
|
|
|
|
|
"Link GENERATION, a string, to the empty profile."
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(let* ((drv (profile-derivation (%store) (manifest '())))
|
2013-09-25 05:34:49 +02:00
|
|
|
|
(prof (derivation->output-path drv "out")))
|
|
|
|
|
(when (not (build-derivations (%store) (list drv)))
|
|
|
|
|
(leave (_ "failed to build the empty profile~%")))
|
|
|
|
|
|
|
|
|
|
(switch-symlinks generation prof)))
|
|
|
|
|
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(define (switch-to-previous-generation profile)
|
|
|
|
|
"Atomically switch PROFILE to the previous generation."
|
|
|
|
|
(let* ((number (generation-number profile))
|
|
|
|
|
(previous-number (previous-generation-number profile number))
|
2013-10-30 22:08:35 +01:00
|
|
|
|
(previous-generation (generation-file-name profile previous-number)))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(format #t (_ "switching from generation ~a to ~a~%")
|
|
|
|
|
number previous-number)
|
|
|
|
|
(switch-symlinks profile previous-generation)))
|
|
|
|
|
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(define (roll-back profile)
|
|
|
|
|
"Roll back to the previous generation of PROFILE."
|
2013-09-12 19:31:53 +02:00
|
|
|
|
(let* ((number (generation-number profile))
|
|
|
|
|
(previous-number (previous-generation-number profile number))
|
2013-10-30 22:08:35 +01:00
|
|
|
|
(previous-generation (generation-file-name profile previous-number))
|
2013-09-12 19:31:53 +02:00
|
|
|
|
(manifest (string-append previous-generation "/manifest")))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(cond ((not (file-exists? profile)) ; invalid profile
|
|
|
|
|
(leave (_ "profile '~a' does not exist~%")
|
2013-04-11 22:30:06 +02:00
|
|
|
|
profile))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
((zero? number) ; empty profile
|
2013-04-12 18:07:17 +02:00
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "nothing to do: already at the empty profile~%")))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
((or (zero? previous-number) ; going to emptiness
|
2013-09-12 19:31:53 +02:00
|
|
|
|
(not (file-exists? previous-generation)))
|
2013-09-25 05:34:49 +02:00
|
|
|
|
(link-to-empty-profile previous-generation)
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(switch-to-previous-generation profile))
|
|
|
|
|
(else
|
|
|
|
|
(switch-to-previous-generation profile))))) ; anything else
|
2013-01-17 22:20:42 +01:00
|
|
|
|
|
2013-09-27 01:17:01 +02:00
|
|
|
|
(define* (matching-generations str #:optional (profile %current-profile)
|
|
|
|
|
#:key (duration-relation <=))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
"Return the list of available generations matching a pattern in STR. See
|
2013-09-27 01:17:01 +02:00
|
|
|
|
'string->generations' and 'string->duration' for the list of valid patterns.
|
|
|
|
|
When STR is a duration pattern, return all the generations whose ctime has
|
|
|
|
|
DURATION-RELATION with the current time."
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(define (valid-generations lst)
|
|
|
|
|
(define (valid-generation? n)
|
|
|
|
|
(any (cut = n <>) (generation-numbers profile)))
|
|
|
|
|
|
|
|
|
|
(fold-right (lambda (x acc)
|
|
|
|
|
(if (valid-generation? x)
|
|
|
|
|
(cons x acc)
|
|
|
|
|
acc))
|
|
|
|
|
'()
|
|
|
|
|
lst))
|
|
|
|
|
|
|
|
|
|
(define (filter-generations generations)
|
|
|
|
|
(match generations
|
|
|
|
|
(() '())
|
|
|
|
|
(('>= n)
|
|
|
|
|
(drop-while (cut > n <>)
|
|
|
|
|
(generation-numbers profile)))
|
|
|
|
|
(('<= n)
|
|
|
|
|
(valid-generations (iota n 1)))
|
|
|
|
|
((lst ..1)
|
|
|
|
|
(valid-generations lst))
|
|
|
|
|
(_ #f)))
|
|
|
|
|
|
|
|
|
|
(define (filter-by-duration duration)
|
|
|
|
|
(define (time-at-midnight time)
|
|
|
|
|
;; Return TIME at midnight by setting nanoseconds, seconds, minutes, and
|
|
|
|
|
;; hours to zeros.
|
|
|
|
|
(let ((d (time-utc->date time)))
|
|
|
|
|
(date->time-utc
|
|
|
|
|
(make-date 0 0 0 0
|
|
|
|
|
(date-day d) (date-month d)
|
|
|
|
|
(date-year d) (date-zone-offset d)))))
|
|
|
|
|
|
|
|
|
|
(define generation-ctime-alist
|
|
|
|
|
(map (lambda (number)
|
|
|
|
|
(cons number
|
|
|
|
|
(time-second
|
|
|
|
|
(time-at-midnight
|
|
|
|
|
(generation-time profile number)))))
|
|
|
|
|
(generation-numbers profile)))
|
|
|
|
|
|
|
|
|
|
(match duration
|
|
|
|
|
(#f #f)
|
|
|
|
|
(res
|
|
|
|
|
(let ((s (time-second
|
|
|
|
|
(subtract-duration (time-at-midnight (current-time))
|
|
|
|
|
duration))))
|
|
|
|
|
(delete #f (map (lambda (x)
|
2013-09-27 01:17:01 +02:00
|
|
|
|
(and (duration-relation s (cdr x))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(first x)))
|
|
|
|
|
generation-ctime-alist))))))
|
|
|
|
|
|
|
|
|
|
(cond ((string->generations str)
|
|
|
|
|
=>
|
|
|
|
|
filter-generations)
|
|
|
|
|
((string->duration str)
|
|
|
|
|
=>
|
|
|
|
|
filter-by-duration)
|
|
|
|
|
(else #f)))
|
|
|
|
|
|
Add (guix profiles).
* guix/scripts/package.scm (show-what-to-remove/install): New procedure,
moved from...
(guix-package): ... here.
(<manifest>, make-manifest, <manifest-entry>,
profile-manifest, manifest->sexp, sexp->manifest, read-manifest,
write-manifest, remove-manifest-entry, manifest-remove,
manifest-installed?, manifest=?, profile-regexp, generation-numbers,
previous-generation-number, profile-derivation, generation-number,
generation-file-name, generation-time, lower-input): Move to...
* guix/profiles.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
2013-11-01 16:31:45 +01:00
|
|
|
|
(define (show-what-to-remove/install remove install dry-run?)
|
|
|
|
|
"Given the manifest entries listed in REMOVE and INSTALL, display the
|
|
|
|
|
packages that will/would be installed and removed."
|
|
|
|
|
;; TODO: Report upgrades more clearly.
|
|
|
|
|
(match remove
|
2013-11-01 23:59:25 +01:00
|
|
|
|
((($ <manifest-entry> name version output path _) ..1)
|
Add (guix profiles).
* guix/scripts/package.scm (show-what-to-remove/install): New procedure,
moved from...
(guix-package): ... here.
(<manifest>, make-manifest, <manifest-entry>,
profile-manifest, manifest->sexp, sexp->manifest, read-manifest,
write-manifest, remove-manifest-entry, manifest-remove,
manifest-installed?, manifest=?, profile-regexp, generation-numbers,
previous-generation-number, profile-derivation, generation-number,
generation-file-name, generation-time, lower-input): Move to...
* guix/profiles.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
2013-11-01 16:31:45 +01:00
|
|
|
|
(let ((len (length name))
|
2013-11-01 23:59:25 +01:00
|
|
|
|
(remove (map (cut format #f " ~a-~a\t~a\t~a" <> <> <> <>)
|
|
|
|
|
name version output path)))
|
Add (guix profiles).
* guix/scripts/package.scm (show-what-to-remove/install): New procedure,
moved from...
(guix-package): ... here.
(<manifest>, make-manifest, <manifest-entry>,
profile-manifest, manifest->sexp, sexp->manifest, read-manifest,
write-manifest, remove-manifest-entry, manifest-remove,
manifest-installed?, manifest=?, profile-regexp, generation-numbers,
previous-generation-number, profile-derivation, generation-number,
generation-file-name, generation-time, lower-input): Move to...
* guix/profiles.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
2013-11-01 16:31:45 +01:00
|
|
|
|
(if dry-run?
|
|
|
|
|
(format (current-error-port)
|
2013-11-01 23:12:36 +01:00
|
|
|
|
(N_ "The following package would be removed:~%~{~a~%~}~%"
|
|
|
|
|
"The following packages would be removed:~%~{~a~%~}~%"
|
Add (guix profiles).
* guix/scripts/package.scm (show-what-to-remove/install): New procedure,
moved from...
(guix-package): ... here.
(<manifest>, make-manifest, <manifest-entry>,
profile-manifest, manifest->sexp, sexp->manifest, read-manifest,
write-manifest, remove-manifest-entry, manifest-remove,
manifest-installed?, manifest=?, profile-regexp, generation-numbers,
previous-generation-number, profile-derivation, generation-number,
generation-file-name, generation-time, lower-input): Move to...
* guix/profiles.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
2013-11-01 16:31:45 +01:00
|
|
|
|
len)
|
|
|
|
|
remove)
|
|
|
|
|
(format (current-error-port)
|
2013-11-01 23:12:36 +01:00
|
|
|
|
(N_ "The following package will be removed:~%~{~a~%~}~%"
|
|
|
|
|
"The following packages will be removed:~%~{~a~%~}~%"
|
Add (guix profiles).
* guix/scripts/package.scm (show-what-to-remove/install): New procedure,
moved from...
(guix-package): ... here.
(<manifest>, make-manifest, <manifest-entry>,
profile-manifest, manifest->sexp, sexp->manifest, read-manifest,
write-manifest, remove-manifest-entry, manifest-remove,
manifest-installed?, manifest=?, profile-regexp, generation-numbers,
previous-generation-number, profile-derivation, generation-number,
generation-file-name, generation-time, lower-input): Move to...
* guix/profiles.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
2013-11-01 16:31:45 +01:00
|
|
|
|
len)
|
|
|
|
|
remove))))
|
|
|
|
|
(_ #f))
|
|
|
|
|
(match install
|
|
|
|
|
((($ <manifest-entry> name version output path _) ..1)
|
|
|
|
|
(let ((len (length name))
|
|
|
|
|
(install (map (cut format #f " ~a-~a\t~a\t~a" <> <> <> <>)
|
|
|
|
|
name version output path)))
|
|
|
|
|
(if dry-run?
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(N_ "The following package would be installed:~%~{~a~%~}~%"
|
|
|
|
|
"The following packages would be installed:~%~{~a~%~}~%"
|
|
|
|
|
len)
|
|
|
|
|
install)
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(N_ "The following package will be installed:~%~{~a~%~}~%"
|
|
|
|
|
"The following packages will be installed:~%~{~a~%~}~%"
|
|
|
|
|
len)
|
|
|
|
|
install))))
|
|
|
|
|
(_ #f)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Package specifications.
|
|
|
|
|
;;;
|
|
|
|
|
|
2013-01-28 07:29:10 +01:00
|
|
|
|
(define (find-packages-by-description rx)
|
2013-10-15 22:59:50 +02:00
|
|
|
|
"Return the list of packages whose name, synopsis, or description matches
|
|
|
|
|
RX."
|
2013-01-28 07:29:10 +01:00
|
|
|
|
(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 <>))
|
|
|
|
|
|
2013-10-15 22:59:50 +02:00
|
|
|
|
(if (or (matches? (gettext (package-name package)))
|
|
|
|
|
(and=> (package-synopsis package)
|
2013-01-28 07:29:10 +01:00
|
|
|
|
(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
|
2013-05-10 22:46:19 +02:00
|
|
|
|
((name (? package? package))
|
2013-02-06 23:01:04 +01:00
|
|
|
|
(loop `(,name ,package "out")))
|
2013-05-10 22:46:19 +02:00
|
|
|
|
((name (? package? package) sub-drv)
|
|
|
|
|
`(,name ,(package-output (%store) package sub-drv)))
|
|
|
|
|
(_
|
|
|
|
|
input))))
|
2013-02-06 23:01:04 +01:00
|
|
|
|
|
2013-04-17 22:43:14 +02:00
|
|
|
|
(define %sigint-prompt
|
|
|
|
|
;; The prompt to jump to upon SIGINT.
|
|
|
|
|
(make-prompt-tag "interruptible"))
|
|
|
|
|
|
|
|
|
|
(define (call-with-sigint-handler thunk handler)
|
|
|
|
|
"Call THUNK and return its value. Upon SIGINT, call HANDLER with the signal
|
|
|
|
|
number in the context of the continuation of the call to this function, and
|
|
|
|
|
return its return value."
|
|
|
|
|
(call-with-prompt %sigint-prompt
|
|
|
|
|
(lambda ()
|
|
|
|
|
(sigaction SIGINT
|
|
|
|
|
(lambda (signum)
|
|
|
|
|
(sigaction SIGINT SIG_DFL)
|
|
|
|
|
(abort-to-prompt %sigint-prompt signum)))
|
2013-05-14 23:52:13 +02:00
|
|
|
|
(dynamic-wind
|
|
|
|
|
(const #t)
|
|
|
|
|
thunk
|
|
|
|
|
(cut sigaction SIGINT SIG_DFL)))
|
2013-04-17 22:43:14 +02:00
|
|
|
|
(lambda (k signum)
|
|
|
|
|
(handler signum))))
|
|
|
|
|
|
2013-03-05 20:30:27 +01:00
|
|
|
|
(define-syntax-rule (waiting exp fmt rest ...)
|
|
|
|
|
"Display the given message while EXP is being evaluated."
|
|
|
|
|
(let* ((message (format #f fmt rest ...))
|
|
|
|
|
(blank (make-string (string-length message) #\space)))
|
|
|
|
|
(display message (current-error-port))
|
|
|
|
|
(force-output (current-error-port))
|
2013-04-17 22:43:14 +02:00
|
|
|
|
(call-with-sigint-handler
|
|
|
|
|
(lambda ()
|
2013-05-14 23:51:36 +02:00
|
|
|
|
(dynamic-wind
|
|
|
|
|
(const #f)
|
|
|
|
|
(lambda () exp)
|
|
|
|
|
(lambda ()
|
|
|
|
|
;; Clear the line.
|
|
|
|
|
(display #\cr (current-error-port))
|
|
|
|
|
(display blank (current-error-port))
|
|
|
|
|
(display #\cr (current-error-port))
|
|
|
|
|
(force-output (current-error-port)))))
|
2013-04-17 22:43:14 +02:00
|
|
|
|
(lambda (signum)
|
|
|
|
|
(format (current-error-port) " interrupted by signal ~a~%" SIGINT)
|
|
|
|
|
#f))))
|
2013-03-05 20:30:27 +01:00
|
|
|
|
|
2014-01-04 22:42:42 +01:00
|
|
|
|
(define-syntax-rule (leave-on-EPIPE exp ...)
|
|
|
|
|
"Run EXP... in a context when EPIPE errors are caught and lead to 'exit'
|
|
|
|
|
with successful exit code. This is useful when writing to the standard output
|
|
|
|
|
may lead to EPIPE, because the standard output is piped through 'head' or
|
|
|
|
|
similar."
|
|
|
|
|
(catch 'system-error
|
|
|
|
|
(lambda ()
|
|
|
|
|
exp ...)
|
|
|
|
|
(lambda args
|
|
|
|
|
;; We really have to exit this brutally, otherwise Guile eventually
|
|
|
|
|
;; attempts to flush all the ports, leading to an uncaught EPIPE down
|
|
|
|
|
;; the path.
|
|
|
|
|
(if (= EPIPE (system-error-errno args))
|
|
|
|
|
(primitive-_exit 0)
|
|
|
|
|
(apply throw args)))))
|
|
|
|
|
|
2013-10-30 15:26:14 +01:00
|
|
|
|
(define* (specification->package+output spec #:optional (output "out"))
|
2013-12-22 01:08:21 +01:00
|
|
|
|
"Return the package and output specified by SPEC, or #f and #f; SPEC may
|
2013-10-30 15:26:14 +01:00
|
|
|
|
optionally contain a version number and an output name, as in these examples:
|
2013-10-29 22:03:02 +01:00
|
|
|
|
|
2013-10-30 15:26:14 +01:00
|
|
|
|
guile
|
|
|
|
|
guile-2.0.9
|
|
|
|
|
guile:debug
|
|
|
|
|
guile-2.0.9:debug
|
|
|
|
|
|
|
|
|
|
If SPEC does not specify a version number, return the preferred newest
|
|
|
|
|
version; if SPEC does not specify an output, return OUTPUT."
|
2013-10-29 22:03:02 +01:00
|
|
|
|
(define (ensure-output p sub-drv)
|
|
|
|
|
(if (member sub-drv (package-outputs p))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
sub-drv
|
2013-10-29 22:03:02 +01:00
|
|
|
|
(leave (_ "package `~a' lacks output `~a'~%")
|
|
|
|
|
(package-full-name p)
|
|
|
|
|
sub-drv)))
|
|
|
|
|
|
2013-11-01 16:57:48 +01:00
|
|
|
|
(let-values (((name version sub-drv)
|
2013-11-24 15:30:06 +01:00
|
|
|
|
(package-specification->name+version+output spec output)))
|
2013-10-29 22:03:02 +01:00
|
|
|
|
(match (find-best-packages-by-name name version)
|
|
|
|
|
((p)
|
2013-10-30 15:26:14 +01:00
|
|
|
|
(values p (ensure-output p sub-drv)))
|
2013-10-29 22:03:02 +01:00
|
|
|
|
((p p* ...)
|
|
|
|
|
(warning (_ "ambiguous package specification `~a'~%")
|
2013-10-30 15:26:14 +01:00
|
|
|
|
spec)
|
2013-10-29 22:03:02 +01:00
|
|
|
|
(warning (_ "choosing ~a from ~a~%")
|
|
|
|
|
(package-full-name p)
|
|
|
|
|
(location->string (package-location p)))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
(values p (ensure-output p sub-drv)))
|
2013-10-29 22:03:02 +01:00
|
|
|
|
(()
|
2013-10-30 15:26:14 +01:00
|
|
|
|
(leave (_ "~a: package not found~%") spec)))))
|
2013-10-29 22:03:02 +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."
|
2013-12-21 22:36:32 +01:00
|
|
|
|
(match (vhash-assoc name (find-newest-available-packages))
|
2013-10-29 22:03:02 +01:00
|
|
|
|
((_ candidate-version pkg . rest)
|
|
|
|
|
(case (version-compare candidate-version current-version)
|
|
|
|
|
((>) #t)
|
|
|
|
|
((<) #f)
|
|
|
|
|
((=) (let ((candidate-path (derivation->output-path
|
|
|
|
|
(package-derivation (%store) pkg))))
|
|
|
|
|
(not (string=? current-path candidate-path))))))
|
|
|
|
|
(#f #f)))
|
|
|
|
|
|
2013-07-12 22:59:33 +02:00
|
|
|
|
(define ftp-open*
|
|
|
|
|
;; Memoizing version of `ftp-open'. The goal is to avoid initiating a new
|
|
|
|
|
;; FTP connection for each package, esp. since most of them are to the same
|
|
|
|
|
;; server. This has a noticeable impact when doing "guix upgrade -u".
|
|
|
|
|
(memoize ftp-open))
|
|
|
|
|
|
2013-03-05 20:30:27 +01:00
|
|
|
|
(define (check-package-freshness package)
|
|
|
|
|
"Check whether PACKAGE has a newer version available upstream, and report
|
|
|
|
|
it."
|
|
|
|
|
;; TODO: Automatically inject the upstream version when desired.
|
2013-03-05 22:24:19 +01:00
|
|
|
|
|
|
|
|
|
(catch #t
|
|
|
|
|
(lambda ()
|
2013-03-16 00:59:19 +01:00
|
|
|
|
(when (false-if-exception (gnu-package? package))
|
2013-03-05 22:24:19 +01:00
|
|
|
|
(let ((name (package-name package))
|
|
|
|
|
(full-name (package-full-name package)))
|
2013-07-12 22:59:33 +02:00
|
|
|
|
(match (waiting (latest-release name
|
|
|
|
|
#:ftp-open ftp-open*
|
|
|
|
|
#:ftp-close (const #f))
|
2013-03-05 22:24:19 +01:00
|
|
|
|
(_ "looking for the latest release of GNU ~a...") name)
|
|
|
|
|
((latest-version . _)
|
|
|
|
|
(when (version>? latest-version full-name)
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "~a: note: using ~a \
|
2013-03-05 20:30:27 +01:00
|
|
|
|
but ~a is available upstream~%")
|
2013-03-05 22:24:19 +01:00
|
|
|
|
(location->string (package-location package))
|
|
|
|
|
full-name latest-version)))
|
|
|
|
|
(_ #t)))))
|
|
|
|
|
(lambda (key . args)
|
|
|
|
|
;; Silently ignore networking errors rather than preventing
|
|
|
|
|
;; installation.
|
|
|
|
|
(case key
|
|
|
|
|
((getaddrinfo-error ftp-error) #f)
|
|
|
|
|
(else (apply throw key args))))))
|
2013-03-05 20:30:27 +01:00
|
|
|
|
|
2013-10-29 22:03:02 +01:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Search paths.
|
|
|
|
|
;;;
|
|
|
|
|
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(define* (search-path-environment-variables entries profile
|
2013-04-28 23:05:57 +02:00
|
|
|
|
#:optional (getenv getenv))
|
|
|
|
|
"Return environment variable definitions that may be needed for the use of
|
2013-10-30 17:13:27 +01:00
|
|
|
|
ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the
|
|
|
|
|
current settings and report only settings not already effective."
|
2013-04-28 23:05:57 +02:00
|
|
|
|
|
2013-05-09 22:58:23 +02:00
|
|
|
|
;; Prefer ~/.guix-profile to the real profile directory name.
|
2013-10-30 17:31:05 +01:00
|
|
|
|
(let ((profile (if (and %user-profile-directory
|
2013-05-09 22:58:23 +02:00
|
|
|
|
(false-if-exception
|
2013-10-30 17:31:05 +01:00
|
|
|
|
(string=? (readlink %user-profile-directory)
|
2013-05-09 22:58:23 +02:00
|
|
|
|
profile)))
|
2013-10-30 17:31:05 +01:00
|
|
|
|
%user-profile-directory
|
2013-05-09 22:58:23 +02:00
|
|
|
|
profile)))
|
|
|
|
|
|
|
|
|
|
;; The search path info is not stored in the manifest. Thus, we infer the
|
|
|
|
|
;; search paths from same-named packages found in the distro.
|
|
|
|
|
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(define manifest-entry->package
|
2013-05-09 22:58:23 +02:00
|
|
|
|
(match-lambda
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(($ <manifest-entry> name version)
|
2013-05-09 22:58:23 +02:00
|
|
|
|
(match (append (find-packages-by-name name version)
|
|
|
|
|
(find-packages-by-name name))
|
|
|
|
|
((p _ ...) p)
|
|
|
|
|
(_ #f)))))
|
|
|
|
|
|
|
|
|
|
(define search-path-definition
|
|
|
|
|
(match-lambda
|
|
|
|
|
(($ <search-path-specification> variable directories separator)
|
|
|
|
|
(let ((values (or (and=> (getenv variable)
|
|
|
|
|
(cut string-tokenize* <> separator))
|
|
|
|
|
'()))
|
|
|
|
|
(directories (filter file-exists?
|
|
|
|
|
(map (cut string-append profile
|
|
|
|
|
"/" <>)
|
|
|
|
|
directories))))
|
|
|
|
|
(if (every (cut member <> values) directories)
|
|
|
|
|
#f
|
|
|
|
|
(format #f "export ~a=\"~a\""
|
|
|
|
|
variable
|
|
|
|
|
(string-join directories separator)))))))
|
|
|
|
|
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(let* ((packages (filter-map manifest-entry->package entries))
|
2013-05-09 22:58:23 +02:00
|
|
|
|
(search-paths (delete-duplicates
|
|
|
|
|
(append-map package-native-search-paths
|
|
|
|
|
packages))))
|
|
|
|
|
(filter-map search-path-definition search-paths))))
|
2013-04-28 23:05:57 +02:00
|
|
|
|
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(define (display-search-paths entries profile)
|
2013-04-28 23:05:57 +02:00
|
|
|
|
"Display the search path environment variables that may need to be set for
|
2013-10-30 17:13:27 +01:00
|
|
|
|
ENTRIES, a list of manifest entries, in the context of PROFILE."
|
|
|
|
|
(let ((settings (search-path-environment-variables entries profile)))
|
2013-04-28 23:05:57 +02:00
|
|
|
|
(unless (null? settings)
|
|
|
|
|
(format #t (_ "The following environment variable definitions may be needed:~%"))
|
2013-05-09 22:58:23 +02:00
|
|
|
|
(format #t "~{ ~a~%~}" settings))))
|
2013-04-28 23:05:57 +02:00
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Command-line options.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define %default-options
|
|
|
|
|
;; Alist of default option values.
|
2013-04-12 15:43:55 +02:00
|
|
|
|
`((profile . ,%current-profile)
|
2013-05-20 18:14:55 +02:00
|
|
|
|
(max-silent-time . 3600)
|
2013-04-12 15:43:55 +02:00
|
|
|
|
(substitutes? . #t)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
(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 (_ "
|
2013-03-01 21:12:32 +01:00
|
|
|
|
-e, --install-from-expression=EXP
|
|
|
|
|
install the package EXP evaluates to"))
|
|
|
|
|
(display (_ "
|
2012-11-01 01:46:15 +01:00
|
|
|
|
-r, --remove=PACKAGE remove PACKAGE"))
|
|
|
|
|
(display (_ "
|
2013-04-15 23:23:27 +02:00
|
|
|
|
-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"))
|
2013-04-28 23:05:57 +02:00
|
|
|
|
(display (_ "
|
|
|
|
|
--search-paths display needed environment variable definitions"))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(display (_ "
|
|
|
|
|
-l, --list-generations[=PATTERN]
|
|
|
|
|
list generations matching PATTERN"))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(display (_ "
|
|
|
|
|
-d, --delete-generations[=PATTERN]
|
|
|
|
|
delete generations matching PATTERN"))
|
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"))
|
2013-05-29 23:08:06 +02:00
|
|
|
|
(display (_ "
|
|
|
|
|
--fallback fall back to building when the substituter fails"))
|
2013-04-12 15:43:55 +02:00
|
|
|
|
(display (_ "
|
|
|
|
|
--no-substitutes build instead of resorting to pre-built substitutes"))
|
2013-05-20 18:14:55 +02:00
|
|
|
|
(display (_ "
|
|
|
|
|
--max-silent-time=SECONDS
|
|
|
|
|
mark the build as failed after SECONDS of silence"))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(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
|
|
|
|
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(option '(#\i "install") #f #t
|
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(let arg-handler ((arg arg) (result result))
|
|
|
|
|
(values (if arg
|
|
|
|
|
(alist-cons 'install arg result)
|
|
|
|
|
result)
|
|
|
|
|
arg-handler))))
|
2013-03-01 21:12:32 +01:00
|
|
|
|
(option '(#\e "install-from-expression") #t #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'install (read/eval-package-expression arg)
|
|
|
|
|
result)
|
|
|
|
|
#f)))
|
|
|
|
|
(option '(#\r "remove") #f #t
|
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(let arg-handler ((arg arg) (result result))
|
|
|
|
|
(values (if arg
|
|
|
|
|
(alist-cons 'remove arg result)
|
|
|
|
|
result)
|
|
|
|
|
arg-handler))))
|
2013-04-15 23:23:27 +02:00
|
|
|
|
(option '(#\u "upgrade") #f #t
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(let arg-handler ((arg arg) (result result))
|
|
|
|
|
(values (alist-cons 'upgrade arg
|
|
|
|
|
;; Delete any prior "upgrade all"
|
|
|
|
|
;; command, or else "--upgrade gcc"
|
|
|
|
|
;; would upgrade everything.
|
|
|
|
|
(delete '(upgrade . #f) result))
|
|
|
|
|
arg-handler))))
|
2013-01-17 22:20:42 +01:00
|
|
|
|
(option '("roll-back") #f #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'roll-back? #t result)
|
|
|
|
|
#f)))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(option '(#\l "list-generations") #f #t
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (cons `(query list-generations ,(or arg ""))
|
|
|
|
|
result)
|
|
|
|
|
#f)))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(option '(#\d "delete-generations") #f #t
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'delete-generations (or arg "")
|
|
|
|
|
result)
|
|
|
|
|
#f)))
|
2013-04-28 23:05:57 +02:00
|
|
|
|
(option '("search-paths") #f #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (cons `(query search-paths) result)
|
|
|
|
|
#f)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(option '(#\p "profile") #t #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'profile arg
|
|
|
|
|
(alist-delete 'profile result))
|
|
|
|
|
#f)))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
(option '(#\n "dry-run") #f #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'dry-run? #t result)
|
|
|
|
|
#f)))
|
2013-05-29 23:08:06 +02:00
|
|
|
|
(option '("fallback") #f #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'fallback? #t
|
|
|
|
|
(alist-delete 'fallback? result))
|
|
|
|
|
#f)))
|
2013-04-12 15:43:55 +02:00
|
|
|
|
(option '("no-substitutes") #f #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'substitutes? #f
|
|
|
|
|
(alist-delete 'substitutes? result))
|
|
|
|
|
#f)))
|
2013-05-20 18:14:55 +02:00
|
|
|
|
(option '("max-silent-time") #t #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'max-silent-time (string->number* arg)
|
|
|
|
|
result)
|
|
|
|
|
#f)))
|
2013-01-07 22:54:54 +01:00
|
|
|
|
(option '("bootstrap") #f #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'bootstrap? #t result)
|
|
|
|
|
#f)))
|
2012-12-12 14:59:16 +01:00
|
|
|
|
(option '("verbose") #f #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (alist-cons 'verbose? #t result)
|
|
|
|
|
#f)))
|
2013-01-28 07:29:10 +01:00
|
|
|
|
(option '(#\s "search") #t #f
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (cons `(query search ,(or arg ""))
|
|
|
|
|
result)
|
|
|
|
|
#f)))
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(option '(#\I "list-installed") #f #t
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (cons `(query list-installed ,(or arg ""))
|
|
|
|
|
result)
|
|
|
|
|
#f)))
|
2012-11-19 23:02:59 +01:00
|
|
|
|
(option '(#\A "list-available") #f #t
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
|
|
|
|
(values (cons `(query list-available ,(or arg ""))
|
|
|
|
|
result)
|
|
|
|
|
#f)))))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(define (options->installable opts manifest)
|
|
|
|
|
"Given MANIFEST, the current manifest, and OPTS, the result of 'args-fold',
|
2013-10-30 22:01:43 +01:00
|
|
|
|
return the new list of manifest entries."
|
|
|
|
|
(define (deduplicate deps)
|
|
|
|
|
;; Remove duplicate entries from DEPS, a list of propagated inputs, where
|
|
|
|
|
;; each input is a name/path tuple.
|
2013-10-30 15:26:14 +01:00
|
|
|
|
(define (same? d1 d2)
|
|
|
|
|
(match d1
|
|
|
|
|
((_ p1)
|
|
|
|
|
(match d2
|
|
|
|
|
((_ p2) (eq? p1 p2))
|
|
|
|
|
(_ #f)))
|
|
|
|
|
((_ p1 out1)
|
|
|
|
|
(match d2
|
|
|
|
|
((_ p2 out2)
|
|
|
|
|
(and (string=? out1 out2)
|
|
|
|
|
(eq? p1 p2)))
|
|
|
|
|
(_ #f)))))
|
|
|
|
|
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(delete-duplicates deps same?))
|
2013-10-30 17:13:27 +01:00
|
|
|
|
|
|
|
|
|
(define (package->manifest-entry p output)
|
|
|
|
|
;; Return a manifest entry for the OUTPUT of package P.
|
|
|
|
|
(check-package-freshness p)
|
2013-10-30 15:26:14 +01:00
|
|
|
|
;; When given a package via `-e', install the first of its
|
|
|
|
|
;; outputs (XXX).
|
|
|
|
|
(let* ((output (or output (car (package-outputs p))))
|
|
|
|
|
(path (package-output (%store) p output))
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(deps (deduplicate (package-transitive-propagated-inputs p))))
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(manifest-entry
|
|
|
|
|
(name (package-name p))
|
|
|
|
|
(version (package-version p))
|
|
|
|
|
(output output)
|
|
|
|
|
(path path)
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(dependencies (map input->name+path deps))
|
|
|
|
|
(inputs (cons (list (package-name p) p output)
|
|
|
|
|
deps)))))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
|
|
|
|
|
(define upgrade-regexps
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
(('upgrade . regexp)
|
|
|
|
|
(make-regexp (or regexp "")))
|
|
|
|
|
(_ #f))
|
|
|
|
|
opts))
|
|
|
|
|
|
|
|
|
|
(define packages-to-upgrade
|
|
|
|
|
(match upgrade-regexps
|
|
|
|
|
(()
|
|
|
|
|
'())
|
|
|
|
|
((_ ...)
|
|
|
|
|
(let ((newest (find-newest-available-packages)))
|
|
|
|
|
(filter-map (match-lambda
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(($ <manifest-entry> name version output path _)
|
2013-10-30 15:26:14 +01:00
|
|
|
|
(and (any (cut regexp-exec <> name)
|
|
|
|
|
upgrade-regexps)
|
|
|
|
|
(upgradeable? name version path)
|
|
|
|
|
(let ((output (or output "out")))
|
|
|
|
|
(call-with-values
|
|
|
|
|
(lambda ()
|
|
|
|
|
(specification->package+output name output))
|
|
|
|
|
list))))
|
|
|
|
|
(_ #f))
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(manifest-entries manifest))))))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
|
|
|
|
|
(define to-upgrade
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
((package output)
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(package->manifest-entry package output)))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
packages-to-upgrade))
|
|
|
|
|
|
|
|
|
|
(define packages-to-install
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
(('install . (? package? p))
|
|
|
|
|
(list p "out"))
|
|
|
|
|
(('install . (? string? spec))
|
|
|
|
|
(and (not (store-path? spec))
|
|
|
|
|
(let-values (((package output)
|
|
|
|
|
(specification->package+output spec)))
|
|
|
|
|
(and package (list package output)))))
|
|
|
|
|
(_ #f))
|
|
|
|
|
opts))
|
|
|
|
|
|
|
|
|
|
(define to-install
|
|
|
|
|
(append (map (match-lambda
|
|
|
|
|
((package output)
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(package->manifest-entry package output)))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
packages-to-install)
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
(('install . (? package?))
|
|
|
|
|
#f)
|
|
|
|
|
(('install . (? store-path? path))
|
|
|
|
|
(let-values (((name version)
|
|
|
|
|
(package-name->name+version
|
|
|
|
|
(store-path-package-name path))))
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(manifest-entry
|
|
|
|
|
(name name)
|
|
|
|
|
(version version)
|
|
|
|
|
(output #f)
|
|
|
|
|
(path path))))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
(_ #f))
|
|
|
|
|
opts)))
|
|
|
|
|
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(append to-upgrade to-install))
|
2013-10-30 15:26:14 +01:00
|
|
|
|
|
2013-11-01 17:12:15 +01:00
|
|
|
|
(define (options->removable options manifest)
|
2013-11-01 23:11:17 +01:00
|
|
|
|
"Given options, return the list of manifest patterns of packages to be
|
|
|
|
|
removed from MANIFEST."
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
(('remove . spec)
|
|
|
|
|
(call-with-values
|
|
|
|
|
(lambda ()
|
|
|
|
|
(package-specification->name+version+output spec))
|
|
|
|
|
(lambda (name version output)
|
|
|
|
|
(manifest-pattern
|
|
|
|
|
(name name)
|
|
|
|
|
(version version)
|
|
|
|
|
(output output)))))
|
|
|
|
|
(_ #f))
|
|
|
|
|
options))
|
2013-11-01 17:12:15 +01:00
|
|
|
|
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Entry point.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (guix-package . args)
|
|
|
|
|
(define (parse-options)
|
|
|
|
|
;; Return the alist of option values.
|
2013-04-27 16:46:39 +02:00
|
|
|
|
(args-fold* args %options
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (opt name arg result arg-handler)
|
2013-04-27 16:46:39 +02:00
|
|
|
|
(leave (_ "~A: unrecognized option~%") name))
|
2013-12-13 21:37:57 +01:00
|
|
|
|
(lambda (arg result arg-handler)
|
|
|
|
|
(if arg-handler
|
|
|
|
|
(arg-handler arg result)
|
|
|
|
|
(leave (_ "~A: extraneous argument~%") arg)))
|
|
|
|
|
%default-options
|
|
|
|
|
#f))
|
2012-11-01 01:46:15 +01:00
|
|
|
|
|
2013-01-07 23:58:24 +01:00
|
|
|
|
(define (guile-missing?)
|
|
|
|
|
;; Return #t if %GUILE-FOR-BUILD is not available yet.
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
(let ((out (derivation->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
|
|
|
|
|
2013-01-14 23:44:58 +01:00
|
|
|
|
(define (ensure-default-profile)
|
2013-05-16 20:04:13 +02:00
|
|
|
|
;; Ensure the default profile symlink and directory exist and are
|
|
|
|
|
;; writable.
|
|
|
|
|
|
|
|
|
|
(define (rtfm)
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "Try \"info '(guix) Invoking guix package'\" for \
|
|
|
|
|
more information.~%"))
|
|
|
|
|
(exit 1))
|
2013-01-14 23:44:58 +01:00
|
|
|
|
|
|
|
|
|
;; Create ~/.guix-profile if it doesn't exist yet.
|
2013-10-30 17:31:05 +01:00
|
|
|
|
(when (and %user-profile-directory
|
2013-01-14 23:44:58 +01:00
|
|
|
|
%current-profile
|
|
|
|
|
(not (false-if-exception
|
2013-10-30 17:31:05 +01:00
|
|
|
|
(lstat %user-profile-directory))))
|
|
|
|
|
(symlink %current-profile %user-profile-directory))
|
2013-01-14 23:44:58 +01:00
|
|
|
|
|
2013-05-16 20:04:13 +02:00
|
|
|
|
(let ((s (stat %profile-directory #f)))
|
|
|
|
|
;; Attempt to create /…/profiles/per-user/$USER if needed.
|
|
|
|
|
(unless (and s (eq? 'directory (stat:type s)))
|
|
|
|
|
(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)
|
|
|
|
|
(rtfm))))
|
|
|
|
|
|
|
|
|
|
;; Bail out if it's not owned by the user.
|
2013-05-24 23:14:19 +02:00
|
|
|
|
(unless (or (not s) (= (stat:uid s) (getuid)))
|
2013-05-16 20:04:13 +02:00
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "error: directory `~a' is not owned by you~%")
|
|
|
|
|
%profile-directory)
|
|
|
|
|
(format (current-error-port)
|
|
|
|
|
(_ "Please change the owner of `~a' to user ~s.~%")
|
|
|
|
|
%profile-directory (or (getenv "USER") (getuid)))
|
|
|
|
|
(rtfm))))
|
2013-01-14 23:44:58 +01:00
|
|
|
|
|
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-10-30 17:13:27 +01:00
|
|
|
|
(define (same-package? entry name output)
|
|
|
|
|
(match entry
|
|
|
|
|
(($ <manifest-entry> entry-name _ entry-output _ ...)
|
|
|
|
|
(and (equal? name entry-name)
|
|
|
|
|
(equal? output entry-output)))))
|
2013-07-15 23:33:17 +02:00
|
|
|
|
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(define current-generation-number
|
|
|
|
|
(generation-number profile))
|
|
|
|
|
|
|
|
|
|
(define (display-and-delete number)
|
2013-10-30 22:08:35 +01:00
|
|
|
|
(let ((generation (generation-file-name profile number)))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(unless (zero? number)
|
|
|
|
|
(format #t (_ "deleting ~a~%") generation)
|
|
|
|
|
(delete-file generation))))
|
|
|
|
|
|
|
|
|
|
(define (delete-generation number)
|
|
|
|
|
(let* ((previous-number (previous-generation-number profile number))
|
2013-10-30 22:08:35 +01:00
|
|
|
|
(previous-generation
|
|
|
|
|
(generation-file-name profile previous-number)))
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(cond ((zero? number)) ; do not delete generation 0
|
|
|
|
|
((and (= number current-generation-number)
|
|
|
|
|
(not (file-exists? previous-generation)))
|
|
|
|
|
(link-to-empty-profile previous-generation)
|
|
|
|
|
(switch-to-previous-generation profile)
|
|
|
|
|
(display-and-delete number))
|
|
|
|
|
((= number current-generation-number)
|
|
|
|
|
(roll-back profile)
|
|
|
|
|
(display-and-delete number))
|
|
|
|
|
(else
|
|
|
|
|
(display-and-delete number)))))
|
|
|
|
|
|
2013-01-17 22:20:42 +01:00
|
|
|
|
;; First roll back if asked to.
|
2013-09-26 04:36:24 +02:00
|
|
|
|
(cond ((and (assoc-ref opts 'roll-back?) (not dry-run?))
|
|
|
|
|
(begin
|
|
|
|
|
(roll-back profile)
|
|
|
|
|
(process-actions (alist-delete 'roll-back? opts))))
|
|
|
|
|
((and (assoc-ref opts 'delete-generations)
|
|
|
|
|
(not dry-run?))
|
|
|
|
|
(filter-map
|
|
|
|
|
(match-lambda
|
|
|
|
|
(('delete-generations . pattern)
|
|
|
|
|
(cond ((not (file-exists? profile)) ; XXX: race condition
|
|
|
|
|
(leave (_ "profile '~a' does not exist~%")
|
|
|
|
|
profile))
|
|
|
|
|
((string-null? pattern)
|
|
|
|
|
(let ((numbers (generation-numbers profile)))
|
|
|
|
|
(if (equal? numbers '(0))
|
|
|
|
|
(exit 0)
|
|
|
|
|
(for-each display-and-delete
|
|
|
|
|
(delete current-generation-number
|
|
|
|
|
numbers)))))
|
|
|
|
|
;; Do not delete the zeroth generation.
|
|
|
|
|
((equal? 0 (string->number pattern))
|
|
|
|
|
(exit 0))
|
2013-09-27 01:17:01 +02:00
|
|
|
|
|
|
|
|
|
;; If PATTERN is a duration, match generations that are
|
|
|
|
|
;; older than the specified duration.
|
|
|
|
|
((matching-generations pattern profile
|
|
|
|
|
#:duration-relation >)
|
2013-09-26 04:36:24 +02:00
|
|
|
|
=>
|
|
|
|
|
(lambda (numbers)
|
|
|
|
|
(if (null-list? numbers)
|
|
|
|
|
(exit 1)
|
|
|
|
|
(for-each delete-generation numbers))))
|
|
|
|
|
(else
|
|
|
|
|
(leave (_ "invalid syntax: ~a~%")
|
|
|
|
|
pattern)))
|
|
|
|
|
|
|
|
|
|
(process-actions
|
|
|
|
|
(alist-delete 'delete-generations opts)))
|
|
|
|
|
(_ #f))
|
|
|
|
|
opts))
|
|
|
|
|
(else
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(let* ((manifest (profile-manifest profile))
|
2013-11-01 17:12:15 +01:00
|
|
|
|
(install (options->installable opts manifest))
|
|
|
|
|
(remove (options->removable opts manifest))
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(entries
|
2013-11-01 17:12:15 +01:00
|
|
|
|
(append install
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(fold (lambda (package result)
|
|
|
|
|
(match package
|
|
|
|
|
(($ <manifest-entry> name _ out _ ...)
|
|
|
|
|
(filter (negate
|
|
|
|
|
(cut same-package? <>
|
|
|
|
|
name out))
|
|
|
|
|
result))))
|
|
|
|
|
(manifest-entries
|
|
|
|
|
(manifest-remove manifest remove))
|
2013-11-01 17:12:15 +01:00
|
|
|
|
install)))
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(new (make-manifest entries)))
|
|
|
|
|
|
|
|
|
|
(when (equal? profile %current-profile)
|
|
|
|
|
(ensure-default-profile))
|
|
|
|
|
|
|
|
|
|
(if (manifest=? new manifest)
|
|
|
|
|
(format (current-error-port) (_ "nothing to be done~%"))
|
2013-11-01 23:11:17 +01:00
|
|
|
|
(let ((prof-drv (profile-derivation (%store) new))
|
|
|
|
|
(remove (manifest-matching-entries manifest remove)))
|
2013-11-01 17:12:15 +01:00
|
|
|
|
(show-what-to-remove/install remove install dry-run?)
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(show-what-to-build (%store) (list prof-drv)
|
|
|
|
|
#:use-substitutes?
|
|
|
|
|
(assoc-ref opts 'substitutes?)
|
|
|
|
|
#:dry-run? dry-run?)
|
|
|
|
|
|
|
|
|
|
(or dry-run?
|
2013-10-30 22:08:35 +01:00
|
|
|
|
(let* ((prof (derivation->output-path prof-drv))
|
|
|
|
|
(number (generation-number profile))
|
2013-10-30 22:01:43 +01:00
|
|
|
|
|
|
|
|
|
;; Always use NUMBER + 1 for the new profile,
|
|
|
|
|
;; possibly overwriting a "previous future
|
|
|
|
|
;; generation".
|
2013-10-30 22:08:35 +01:00
|
|
|
|
(name (generation-file-name profile
|
|
|
|
|
(+ 1 number))))
|
2013-10-30 22:01:43 +01:00
|
|
|
|
(and (build-derivations (%store) (list prof-drv))
|
|
|
|
|
(let ((count (length entries)))
|
|
|
|
|
(switch-symlinks name prof)
|
|
|
|
|
(switch-symlinks profile name)
|
|
|
|
|
(format #t (N_ "~a package in profile~%"
|
|
|
|
|
"~a packages in profile~%"
|
|
|
|
|
count)
|
|
|
|
|
count)
|
|
|
|
|
(display-search-paths entries
|
|
|
|
|
profile)))))))))))
|
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)
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(('list-generations pattern)
|
|
|
|
|
(define (list-generation number)
|
2013-09-25 00:18:09 +02:00
|
|
|
|
(unless (zero? number)
|
2013-09-25 03:55:27 +02:00
|
|
|
|
(let ((header (format #f (_ "Generation ~a\t~a") number
|
|
|
|
|
(date->string
|
|
|
|
|
(time-utc->date
|
|
|
|
|
(generation-time profile number))
|
|
|
|
|
"~b ~d ~Y ~T")))
|
|
|
|
|
(current (generation-number profile)))
|
|
|
|
|
(if (= number current)
|
|
|
|
|
(format #t (_ "~a\t(current)~%") header)
|
|
|
|
|
(format #t "~a~%" header)))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(for-each (match-lambda
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(($ <manifest-entry> name version output location _)
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(format #t " ~a\t~a\t~a\t~a~%"
|
|
|
|
|
name version output location)))
|
2013-09-22 21:50:11 +02:00
|
|
|
|
|
|
|
|
|
;; Show most recently installed packages last.
|
|
|
|
|
(reverse
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(manifest-entries
|
2013-09-22 21:50:11 +02:00
|
|
|
|
(profile-manifest
|
2013-10-30 22:08:35 +01:00
|
|
|
|
(generation-file-name profile number)))))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(newline)))
|
|
|
|
|
|
|
|
|
|
(cond ((not (file-exists? profile)) ; XXX: race condition
|
|
|
|
|
(leave (_ "profile '~a' does not exist~%")
|
|
|
|
|
profile))
|
|
|
|
|
((string-null? pattern)
|
2013-09-25 00:11:16 +02:00
|
|
|
|
(let ((numbers (generation-numbers profile)))
|
2014-01-04 22:42:42 +01:00
|
|
|
|
(leave-on-EPIPE
|
|
|
|
|
(if (equal? numbers '(0))
|
|
|
|
|
(exit 0)
|
|
|
|
|
(for-each list-generation numbers)))))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
((matching-generations pattern profile)
|
|
|
|
|
=>
|
2013-09-25 00:11:16 +02:00
|
|
|
|
(lambda (numbers)
|
|
|
|
|
(if (null-list? numbers)
|
|
|
|
|
(exit 1)
|
2014-01-04 22:42:42 +01:00
|
|
|
|
(leave-on-EPIPE
|
|
|
|
|
(for-each list-generation numbers)))))
|
2013-09-19 13:07:39 +02:00
|
|
|
|
(else
|
|
|
|
|
(leave (_ "invalid syntax: ~a~%")
|
|
|
|
|
pattern)))
|
|
|
|
|
#t)
|
|
|
|
|
|
2012-11-19 22:39:45 +01:00
|
|
|
|
(('list-installed regexp)
|
|
|
|
|
(let* ((regexp (and regexp (make-regexp regexp)))
|
|
|
|
|
(manifest (profile-manifest profile))
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(installed (manifest-entries manifest)))
|
2014-01-04 22:42:42 +01:00
|
|
|
|
(leave-on-EPIPE
|
|
|
|
|
(for-each (match-lambda
|
|
|
|
|
(($ <manifest-entry> name version output path _)
|
|
|
|
|
(when (or (not regexp)
|
|
|
|
|
(regexp-exec regexp name))
|
|
|
|
|
(format #t "~a\t~a\t~a\t~a~%"
|
|
|
|
|
name (or version "?") output path))))
|
|
|
|
|
|
|
|
|
|
;; Show most recently installed packages last.
|
|
|
|
|
(reverse installed)))
|
2012-11-19 23:02:59 +01:00
|
|
|
|
#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))))
|
|
|
|
|
'())))
|
2014-01-04 22:42:42 +01:00
|
|
|
|
(leave-on-EPIPE
|
|
|
|
|
(for-each (lambda (p)
|
|
|
|
|
(format #t "~a\t~a\t~a\t~a~%"
|
|
|
|
|
(package-name p)
|
|
|
|
|
(package-version p)
|
|
|
|
|
(string-join (package-outputs p) ",")
|
|
|
|
|
(location->string (package-location p))))
|
|
|
|
|
(sort available
|
|
|
|
|
(lambda (p1 p2)
|
|
|
|
|
(string<? (package-name p1)
|
|
|
|
|
(package-name p2))))))
|
2012-11-19 23:02:59 +01:00
|
|
|
|
#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)))
|
2014-01-13 18:51:07 +01:00
|
|
|
|
(leave-on-EPIPE
|
|
|
|
|
(for-each (cute package->recutils <> (current-output-port))
|
|
|
|
|
(find-packages-by-description regexp)))
|
2013-01-28 07:29:10 +01:00
|
|
|
|
#t))
|
2013-04-28 23:05:57 +02:00
|
|
|
|
|
|
|
|
|
(('search-paths)
|
|
|
|
|
(let* ((manifest (profile-manifest profile))
|
2013-10-30 17:13:27 +01:00
|
|
|
|
(entries (manifest-entries manifest))
|
|
|
|
|
(packages (map manifest-entry-name entries))
|
|
|
|
|
(settings (search-path-environment-variables entries profile
|
2013-04-28 23:05:57 +02:00
|
|
|
|
(const #f))))
|
|
|
|
|
(format #t "~{~a~%~}" settings)
|
|
|
|
|
#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)
|
2013-03-07 19:29:12 +01:00
|
|
|
|
(with-error-handling
|
|
|
|
|
(parameterize ((%store (open-connection)))
|
2013-04-12 15:43:55 +02:00
|
|
|
|
(set-build-options (%store)
|
2013-10-30 22:01:43 +01:00
|
|
|
|
#:print-build-trace #f
|
2013-05-29 23:08:06 +02:00
|
|
|
|
#:fallback? (assoc-ref opts 'fallback?)
|
2013-04-12 15:43:55 +02:00
|
|
|
|
#:use-substitutes?
|
2013-05-20 18:14:55 +02:00
|
|
|
|
(assoc-ref opts 'substitutes?)
|
|
|
|
|
#:max-silent-time
|
|
|
|
|
(assoc-ref opts 'max-silent-time))
|
2013-04-12 15:43:55 +02:00
|
|
|
|
|
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)))))))
|