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
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2016-02-12 19:12:18 +01:00
|
|
|
|
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
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
|
|
|
|
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
2014-08-13 22:03:53 +02:00
|
|
|
|
;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
|
2015-03-03 08:09:30 +01:00
|
|
|
|
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
|
2015-05-27 14:58:27 +02:00
|
|
|
|
;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
|
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
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; 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.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; 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
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (guix profiles)
|
2016-03-31 15:47:18 +02:00
|
|
|
|
#:use-module ((guix utils) #:hide (package-name->name+version))
|
|
|
|
|
#:use-module ((guix build utils)
|
|
|
|
|
#:select (package-name->name+version))
|
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 records)
|
|
|
|
|
#:use-module (guix packages)
|
Move search path specifications to (guix search-paths).
* guix/packages.scm (<search-path-specification>,
search-path-specification->sexp, sexp->search-path-specification):
Move to...
* guix/search-paths.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
* guix/build-system/cmake.scm, guix/build-system/glib-or-gtk.scm,
guix/build-system/gnu.scm, guix/build-system/haskell.scm,
guix/build-system/perl.scm, guix/build-system/python.scm,
guix/build-system/ruby.scm, guix/build-system/waf.scm,
guix/profiles.scm, guix/scripts/package.scm: Use it.
2015-05-04 22:11:37 +02:00
|
|
|
|
#:use-module (guix derivations)
|
|
|
|
|
#:use-module (guix search-paths)
|
2014-07-26 22:08:10 +02:00
|
|
|
|
#:use-module (guix gexp)
|
2014-08-23 18:41:14 +02:00
|
|
|
|
#:use-module (guix monads)
|
monads: Move '%store-monad' and related procedures where they belong.
This turns (guix monads) into a generic module for monads, and moves the
store monad and related monadic procedures in their corresponding
module.
* guix/monads.scm (store-return, store-bind, %store-monad, store-lift,
text-file, interned-file, package-file, package->derivation,
package->cross-derivation, origin->derivation, imported-modules,
compiled, modules, built-derivations, run-with-store): Move to...
* guix/store.scm (store-return, store-bind, %store-monad, store-lift,
text-file, interned-file): ... here.
(%guile-for-build): New variable.
(run-with-store): Moved from monads.scm. Remove default value for
#:guile-for-build.
* guix/packages.scm (default-guile): Export.
(set-guile-for-build): New procedure.
(package-file, package->derivation, package->cross-derivation,
origin->derivation): Moved from monads.scm.
* guix/derivations.scm (%guile-for-build): Remove.
(imported-modules): Rename to...
(%imported-modules): ... this.
(compiled-modules): Rename to...
(%compiled-modules): ... this.
(built-derivations, imported-modules, compiled-modules): New
procedures.
* gnu/services/avahi.scm, gnu/services/base.scm, gnu/services/dbus.scm,
gnu/services/dmd.scm, gnu/services/networking.scm,
gnu/services/ssh.scm, gnu/services/xorg.scm, gnu/system/install.scm,
gnu/system/linux-initrd.scm, gnu/system/shadow.scm, guix/download.scm,
guix/gexp.scm, guix/git-download.scm, guix/profiles.scm,
guix/svn-download.scm, tests/monads.scm: Adjust imports accordingly.
* guix/monad-repl.scm (default-guile-derivation): New procedure.
(store-monad-language, run-in-store): Use it.
* build-aux/hydra/gnu-system.scm (qemu-jobs): Add explicit
'set-guile-for-build' call.
* guix/scripts/archive.scm (derivation-from-expression): Likewise.
* guix/scripts/build.scm (options/resolve-packages): Likewise.
* guix/scripts/environment.scm (guix-environment): Likewise.
* guix/scripts/system.scm (guix-system): Likewise.
* doc/guix.texi (The Store Monad): Adjust module names accordingly.
2015-01-14 13:34:52 +01:00
|
|
|
|
#:use-module (guix store)
|
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 (ice-9 match)
|
|
|
|
|
#:use-module (ice-9 regex)
|
|
|
|
|
#:use-module (ice-9 ftw)
|
2014-08-13 22:03:53 +02:00
|
|
|
|
#:use-module (ice-9 format)
|
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 (srfi srfi-1)
|
|
|
|
|
#:use-module (srfi srfi-9)
|
2014-08-30 21:52:32 +02:00
|
|
|
|
#:use-module (srfi srfi-11)
|
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 (srfi srfi-19)
|
|
|
|
|
#:use-module (srfi srfi-26)
|
2014-10-08 15:29:01 +02:00
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
|
#:use-module (srfi srfi-35)
|
|
|
|
|
#:export (&profile-error
|
|
|
|
|
profile-error?
|
|
|
|
|
profile-error-profile
|
|
|
|
|
&profile-not-found-error
|
|
|
|
|
profile-not-found-error?
|
|
|
|
|
&missing-generation-error
|
|
|
|
|
missing-generation-error?
|
|
|
|
|
missing-generation-error-generation
|
|
|
|
|
|
|
|
|
|
manifest make-manifest
|
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
|
|
|
|
manifest?
|
|
|
|
|
manifest-entries
|
|
|
|
|
|
|
|
|
|
<manifest-entry> ; FIXME: eventually make it internal
|
|
|
|
|
manifest-entry
|
|
|
|
|
manifest-entry?
|
|
|
|
|
manifest-entry-name
|
|
|
|
|
manifest-entry-version
|
|
|
|
|
manifest-entry-output
|
2014-07-26 22:08:10 +02:00
|
|
|
|
manifest-entry-item
|
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
|
|
|
|
manifest-entry-dependencies
|
2015-05-02 23:55:24 +02:00
|
|
|
|
manifest-entry-search-paths
|
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
|
|
|
|
|
2013-11-01 23:11:17 +01:00
|
|
|
|
manifest-pattern
|
|
|
|
|
manifest-pattern?
|
|
|
|
|
|
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
|
|
|
|
manifest-remove
|
2014-08-12 10:32:16 +02:00
|
|
|
|
manifest-add
|
2014-09-02 21:12:59 +02:00
|
|
|
|
manifest-lookup
|
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
|
|
|
|
manifest-installed?
|
2013-11-01 23:11:17 +01:00
|
|
|
|
manifest-matching-entries
|
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
|
|
|
|
|
2014-08-13 22:03:53 +02:00
|
|
|
|
manifest-transaction
|
|
|
|
|
manifest-transaction?
|
|
|
|
|
manifest-transaction-install
|
|
|
|
|
manifest-transaction-remove
|
|
|
|
|
manifest-perform-transaction
|
2014-08-30 21:52:32 +02:00
|
|
|
|
manifest-transaction-effects
|
2014-08-13 22:03:53 +02: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
|
|
|
|
profile-manifest
|
2014-07-26 22:54:40 +02:00
|
|
|
|
package->manifest-entry
|
2015-05-18 13:51:56 +02:00
|
|
|
|
packages->manifest
|
2015-04-15 22:44:51 +02:00
|
|
|
|
%default-profile-hooks
|
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
|
|
|
|
profile-derivation
|
2015-10-26 23:01:06 +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
|
|
|
|
generation-number
|
|
|
|
|
generation-numbers
|
2014-09-21 12:24:09 +02:00
|
|
|
|
profile-generations
|
2014-10-10 15:56:59 +02:00
|
|
|
|
relative-generation
|
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
|
|
|
|
previous-generation-number
|
|
|
|
|
generation-time
|
2015-10-26 23:01:06 +01:00
|
|
|
|
generation-file-name
|
|
|
|
|
switch-to-generation
|
|
|
|
|
roll-back
|
|
|
|
|
delete-generation))
|
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
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;;
|
|
|
|
|
;;; Tools to create and manipulate profiles---i.e., the representation of a
|
|
|
|
|
;;; set of installed packages.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2014-10-08 15:29:01 +02:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Condition types.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-condition-type &profile-error &error
|
|
|
|
|
profile-error?
|
|
|
|
|
(profile profile-error-profile))
|
|
|
|
|
|
|
|
|
|
(define-condition-type &profile-not-found-error &profile-error
|
|
|
|
|
profile-not-found-error?)
|
|
|
|
|
|
|
|
|
|
(define-condition-type &missing-generation-error &profile-error
|
|
|
|
|
missing-generation-error?
|
|
|
|
|
(generation missing-generation-error-generation))
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Manifests.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-record-type <manifest>
|
|
|
|
|
(manifest entries)
|
|
|
|
|
manifest?
|
|
|
|
|
(entries manifest-entries)) ; list of <manifest-entry>
|
|
|
|
|
|
|
|
|
|
;; Convenient alias, to avoid name clashes.
|
|
|
|
|
(define make-manifest manifest)
|
|
|
|
|
|
|
|
|
|
(define-record-type* <manifest-entry> manifest-entry
|
|
|
|
|
make-manifest-entry
|
|
|
|
|
manifest-entry?
|
|
|
|
|
(name manifest-entry-name) ; string
|
|
|
|
|
(version manifest-entry-version) ; string
|
|
|
|
|
(output manifest-entry-output ; string
|
|
|
|
|
(default "out"))
|
2014-07-26 22:08:10 +02:00
|
|
|
|
(item manifest-entry-item) ; package | store path
|
2014-07-26 22:21:43 +02:00
|
|
|
|
(dependencies manifest-entry-dependencies ; (store path | package)*
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(default '()))
|
|
|
|
|
(search-paths manifest-entry-search-paths ; search-path-specification*
|
2014-07-26 22:21:43 +02:00
|
|
|
|
(default '())))
|
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
|
|
|
|
|
2013-11-01 23:11:17 +01:00
|
|
|
|
(define-record-type* <manifest-pattern> manifest-pattern
|
|
|
|
|
make-manifest-pattern
|
|
|
|
|
manifest-pattern?
|
|
|
|
|
(name manifest-pattern-name) ; string
|
|
|
|
|
(version manifest-pattern-version ; string | #f
|
|
|
|
|
(default #f))
|
|
|
|
|
(output manifest-pattern-output ; string | #f
|
|
|
|
|
(default "out")))
|
|
|
|
|
|
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 (profile-manifest profile)
|
|
|
|
|
"Return the PROFILE's manifest."
|
|
|
|
|
(let ((file (string-append profile "/manifest")))
|
|
|
|
|
(if (file-exists? file)
|
|
|
|
|
(call-with-input-file file read-manifest)
|
|
|
|
|
(manifest '()))))
|
|
|
|
|
|
2014-07-26 22:54:40 +02:00
|
|
|
|
(define* (package->manifest-entry package #:optional output)
|
|
|
|
|
"Return a manifest entry for the OUTPUT of package PACKAGE. When OUTPUT is
|
|
|
|
|
omitted or #f, use the first output of PACKAGE."
|
|
|
|
|
(let ((deps (map (match-lambda
|
|
|
|
|
((label package)
|
2015-03-15 21:51:34 +01:00
|
|
|
|
(gexp-input package))
|
2014-07-26 22:54:40 +02:00
|
|
|
|
((label package output)
|
2015-03-15 21:51:34 +01:00
|
|
|
|
(gexp-input package output)))
|
2014-07-26 22:54:40 +02:00
|
|
|
|
(package-transitive-propagated-inputs package))))
|
|
|
|
|
(manifest-entry
|
|
|
|
|
(name (package-name package))
|
|
|
|
|
(version (package-version package))
|
|
|
|
|
(output (or output (car (package-outputs package))))
|
|
|
|
|
(item package)
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(dependencies (delete-duplicates deps))
|
2015-12-20 14:42:56 +01:00
|
|
|
|
(search-paths (package-transitive-native-search-paths package)))))
|
2014-07-26 22:54:40 +02:00
|
|
|
|
|
2015-05-18 13:51:56 +02:00
|
|
|
|
(define (packages->manifest packages)
|
|
|
|
|
"Return a list of manifest entries, one for each item listed in PACKAGES.
|
|
|
|
|
Elements of PACKAGES can be either package objects or package/string tuples
|
|
|
|
|
denoting a specific output of a package."
|
|
|
|
|
(manifest
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
((package output)
|
|
|
|
|
(package->manifest-entry package output))
|
|
|
|
|
(package
|
|
|
|
|
(package->manifest-entry package)))
|
|
|
|
|
packages)))
|
|
|
|
|
|
2014-07-26 22:08:10 +02:00
|
|
|
|
(define (manifest->gexp manifest)
|
|
|
|
|
"Return a representation of MANIFEST as a gexp."
|
|
|
|
|
(define (entry->gexp entry)
|
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
|
|
|
|
(match entry
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(($ <manifest-entry> name version output (? string? path)
|
|
|
|
|
(deps ...) (search-paths ...))
|
|
|
|
|
#~(#$name #$version #$output #$path
|
|
|
|
|
(propagated-inputs #$deps)
|
|
|
|
|
(search-paths #$(map search-path-specification->sexp
|
|
|
|
|
search-paths))))
|
|
|
|
|
(($ <manifest-entry> name version output (? package? package)
|
|
|
|
|
(deps ...) (search-paths ...))
|
2014-07-26 22:08:10 +02:00
|
|
|
|
#~(#$name #$version #$output
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(ungexp package (or output "out"))
|
|
|
|
|
(propagated-inputs #$deps)
|
|
|
|
|
(search-paths #$(map search-path-specification->sexp
|
|
|
|
|
search-paths))))))
|
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
|
|
|
|
|
|
|
|
|
(match manifest
|
|
|
|
|
(($ <manifest> (entries ...))
|
2015-05-02 23:55:24 +02:00
|
|
|
|
#~(manifest (version 2)
|
2014-07-26 22:08:10 +02:00
|
|
|
|
(packages #$(map entry->gexp entries))))))
|
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
|
|
|
|
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(define (find-package name version)
|
|
|
|
|
"Return a package from the distro matching NAME and possibly VERSION. This
|
|
|
|
|
procedure is here for backward-compatibility and will eventually vanish."
|
|
|
|
|
(define find-best-packages-by-name ;break abstractions
|
|
|
|
|
(module-ref (resolve-interface '(gnu packages))
|
|
|
|
|
'find-best-packages-by-name))
|
|
|
|
|
|
|
|
|
|
;; Use 'find-best-packages-by-name' and not 'find-packages-by-name'; the
|
|
|
|
|
;; former traverses the module tree only once and then allows for efficient
|
|
|
|
|
;; access via a vhash.
|
|
|
|
|
(match (find-best-packages-by-name name version)
|
|
|
|
|
((p _ ...) p)
|
|
|
|
|
(_
|
|
|
|
|
(match (find-best-packages-by-name name #f)
|
|
|
|
|
((p _ ...) p)
|
|
|
|
|
(_ #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 (sexp->manifest sexp)
|
|
|
|
|
"Parse SEXP as a manifest."
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(define (infer-search-paths name version)
|
|
|
|
|
;; Infer the search path specifications for NAME-VERSION by looking up a
|
|
|
|
|
;; same-named package in the distro. Useful for the old manifest formats
|
|
|
|
|
;; that did not store search path info.
|
|
|
|
|
(let ((package (find-package name version)))
|
|
|
|
|
(if package
|
|
|
|
|
(package-native-search-paths package)
|
|
|
|
|
'())))
|
|
|
|
|
|
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
|
|
|
|
(match sexp
|
|
|
|
|
(('manifest ('version 0)
|
|
|
|
|
('packages ((name version output path) ...)))
|
|
|
|
|
(manifest
|
|
|
|
|
(map (lambda (name version output path)
|
|
|
|
|
(manifest-entry
|
|
|
|
|
(name name)
|
|
|
|
|
(version version)
|
|
|
|
|
(output output)
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(item path)
|
|
|
|
|
(search-paths (infer-search-paths name version))))
|
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
|
|
|
|
name version output path)))
|
|
|
|
|
|
|
|
|
|
;; Version 1 adds a list of propagated inputs to the
|
|
|
|
|
;; name/version/output/path tuples.
|
|
|
|
|
(('manifest ('version 1)
|
|
|
|
|
('packages ((name version output path deps) ...)))
|
|
|
|
|
(manifest
|
|
|
|
|
(map (lambda (name version output path deps)
|
2014-08-12 22:09:42 +02:00
|
|
|
|
;; Up to Guix 0.7 included, dependencies were listed as ("gmp"
|
|
|
|
|
;; "/gnu/store/...-gmp") for instance. Discard the 'label' in
|
|
|
|
|
;; such lists.
|
|
|
|
|
(let ((deps (match deps
|
|
|
|
|
(((labels directories) ...)
|
|
|
|
|
directories)
|
|
|
|
|
((directories ...)
|
|
|
|
|
directories))))
|
|
|
|
|
(manifest-entry
|
|
|
|
|
(name name)
|
|
|
|
|
(version version)
|
|
|
|
|
(output output)
|
|
|
|
|
(item path)
|
2015-05-02 23:55:24 +02:00
|
|
|
|
(dependencies deps)
|
|
|
|
|
(search-paths (infer-search-paths name version)))))
|
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
|
|
|
|
name version output path deps)))
|
|
|
|
|
|
2015-05-02 23:55:24 +02:00
|
|
|
|
;; Version 2 adds search paths and is slightly more verbose.
|
|
|
|
|
(('manifest ('version 2 minor-version ...)
|
|
|
|
|
('packages ((name version output path
|
|
|
|
|
('propagated-inputs deps)
|
|
|
|
|
('search-paths search-paths)
|
|
|
|
|
extra-stuff ...)
|
|
|
|
|
...)))
|
|
|
|
|
(manifest
|
|
|
|
|
(map (lambda (name version output path deps search-paths)
|
|
|
|
|
(manifest-entry
|
|
|
|
|
(name name)
|
|
|
|
|
(version version)
|
|
|
|
|
(output output)
|
|
|
|
|
(item path)
|
|
|
|
|
(dependencies deps)
|
|
|
|
|
(search-paths (map sexp->search-path-specification
|
|
|
|
|
search-paths))))
|
|
|
|
|
name version output path deps search-paths)))
|
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
|
|
|
|
(_
|
2015-05-04 22:41:31 +02:00
|
|
|
|
(raise (condition
|
|
|
|
|
(&message (message "unsupported manifest format")))))))
|
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 (read-manifest port)
|
|
|
|
|
"Return the packages listed in MANIFEST."
|
|
|
|
|
(sexp->manifest (read port)))
|
|
|
|
|
|
2013-11-01 23:11:17 +01:00
|
|
|
|
(define (entry-predicate pattern)
|
|
|
|
|
"Return a procedure that returns #t when passed a manifest entry that
|
|
|
|
|
matches NAME/OUTPUT/VERSION. OUTPUT and VERSION may be #f, in which case they
|
|
|
|
|
are ignored."
|
|
|
|
|
(match pattern
|
|
|
|
|
(($ <manifest-pattern> name version output)
|
|
|
|
|
(match-lambda
|
|
|
|
|
(($ <manifest-entry> entry-name entry-version entry-output)
|
|
|
|
|
(and (string=? entry-name name)
|
|
|
|
|
(or (not entry-output) (not output)
|
|
|
|
|
(string=? entry-output output))
|
|
|
|
|
(or (not version)
|
|
|
|
|
(string=? entry-version version))))))))
|
|
|
|
|
|
|
|
|
|
(define (manifest-remove manifest patterns)
|
|
|
|
|
"Remove entries for each of PATTERNS from MANIFEST. Each item in PATTERNS
|
|
|
|
|
must be a manifest-pattern."
|
|
|
|
|
(define (remove-entry pattern lst)
|
|
|
|
|
(remove (entry-predicate pattern) lst))
|
|
|
|
|
|
|
|
|
|
(make-manifest (fold remove-entry
|
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
|
|
|
|
(manifest-entries manifest)
|
2013-11-01 23:11:17 +01:00
|
|
|
|
patterns)))
|
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
|
|
|
|
|
2014-08-12 10:32:16 +02:00
|
|
|
|
(define (manifest-add manifest entries)
|
|
|
|
|
"Add a list of manifest ENTRIES to MANIFEST and return new manifest.
|
|
|
|
|
Remove MANIFEST entries that have the same name and output as ENTRIES."
|
|
|
|
|
(define (same-entry? entry name output)
|
|
|
|
|
(match entry
|
|
|
|
|
(($ <manifest-entry> entry-name _ entry-output _ ...)
|
|
|
|
|
(and (equal? name entry-name)
|
|
|
|
|
(equal? output entry-output)))))
|
|
|
|
|
|
|
|
|
|
(make-manifest
|
|
|
|
|
(append entries
|
|
|
|
|
(fold (lambda (entry result)
|
|
|
|
|
(match entry
|
|
|
|
|
(($ <manifest-entry> name _ out _ ...)
|
|
|
|
|
(filter (negate (cut same-entry? <> name out))
|
|
|
|
|
result))))
|
|
|
|
|
(manifest-entries manifest)
|
|
|
|
|
entries))))
|
|
|
|
|
|
2014-09-02 21:12:59 +02:00
|
|
|
|
(define (manifest-lookup manifest pattern)
|
|
|
|
|
"Return the first item of MANIFEST that matches PATTERN, or #f if there is
|
|
|
|
|
no match.."
|
|
|
|
|
(find (entry-predicate pattern)
|
|
|
|
|
(manifest-entries manifest)))
|
|
|
|
|
|
2013-11-01 23:11:17 +01:00
|
|
|
|
(define (manifest-installed? manifest pattern)
|
|
|
|
|
"Return #t if MANIFEST has an entry matching PATTERN (a manifest-pattern),
|
|
|
|
|
#f otherwise."
|
2014-09-02 21:12:59 +02:00
|
|
|
|
(->bool (manifest-lookup manifest pattern)))
|
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
|
|
|
|
|
2013-11-01 23:11:17 +01:00
|
|
|
|
(define (manifest-matching-entries manifest patterns)
|
|
|
|
|
"Return all the entries of MANIFEST that match one of the PATTERNS."
|
|
|
|
|
(define predicates
|
|
|
|
|
(map entry-predicate patterns))
|
|
|
|
|
|
|
|
|
|
(define (matches? entry)
|
|
|
|
|
(any (lambda (pred)
|
|
|
|
|
(pred entry))
|
|
|
|
|
predicates))
|
|
|
|
|
|
|
|
|
|
(filter matches? (manifest-entries manifest)))
|
|
|
|
|
|
2014-08-13 22:03:53 +02:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Manifest transactions.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-record-type* <manifest-transaction> manifest-transaction
|
|
|
|
|
make-manifest-transaction
|
|
|
|
|
manifest-transaction?
|
|
|
|
|
(install manifest-transaction-install ; list of <manifest-entry>
|
|
|
|
|
(default '()))
|
|
|
|
|
(remove manifest-transaction-remove ; list of <manifest-pattern>
|
|
|
|
|
(default '())))
|
|
|
|
|
|
2014-08-30 21:52:32 +02:00
|
|
|
|
(define (manifest-transaction-effects manifest transaction)
|
2015-02-08 18:52:00 +01:00
|
|
|
|
"Compute the effect of applying TRANSACTION to MANIFEST. Return 4 values:
|
|
|
|
|
the list of packages that would be removed, installed, upgraded, or downgraded
|
|
|
|
|
when applying TRANSACTION to MANIFEST. Upgrades are represented as pairs
|
|
|
|
|
where the head is the entry being upgraded and the tail is the entry that will
|
|
|
|
|
replace it."
|
2014-08-30 21:52:32 +02:00
|
|
|
|
(define (manifest-entry->pattern entry)
|
|
|
|
|
(manifest-pattern
|
|
|
|
|
(name (manifest-entry-name entry))
|
|
|
|
|
(output (manifest-entry-output entry))))
|
|
|
|
|
|
2015-02-08 18:52:00 +01:00
|
|
|
|
(let loop ((input (manifest-transaction-install transaction))
|
|
|
|
|
(install '())
|
|
|
|
|
(upgrade '())
|
|
|
|
|
(downgrade '()))
|
2014-08-30 21:52:32 +02:00
|
|
|
|
(match input
|
|
|
|
|
(()
|
|
|
|
|
(let ((remove (manifest-transaction-remove transaction)))
|
|
|
|
|
(values (manifest-matching-entries manifest remove)
|
2015-02-08 18:52:00 +01:00
|
|
|
|
(reverse install) (reverse upgrade) (reverse downgrade))))
|
2014-08-30 21:52:32 +02:00
|
|
|
|
((entry rest ...)
|
|
|
|
|
;; Check whether installing ENTRY corresponds to the installation of a
|
|
|
|
|
;; new package or to an upgrade.
|
|
|
|
|
|
|
|
|
|
;; XXX: When the exact same output directory is installed, we're not
|
|
|
|
|
;; really upgrading anything. Add a check for that case.
|
|
|
|
|
(let* ((pattern (manifest-entry->pattern entry))
|
2015-02-08 18:52:00 +01:00
|
|
|
|
(previous (manifest-lookup manifest pattern))
|
|
|
|
|
(newer? (and previous
|
2015-02-09 17:18:48 +01:00
|
|
|
|
(version>=? (manifest-entry-version entry)
|
|
|
|
|
(manifest-entry-version previous)))))
|
2014-08-30 21:52:32 +02:00
|
|
|
|
(loop rest
|
2014-09-02 21:12:59 +02:00
|
|
|
|
(if previous install (cons entry install))
|
2015-02-08 18:52:00 +01:00
|
|
|
|
(if (and previous newer?)
|
2014-09-02 21:12:59 +02:00
|
|
|
|
(alist-cons previous entry upgrade)
|
2015-02-08 18:52:00 +01:00
|
|
|
|
upgrade)
|
|
|
|
|
(if (and previous (not newer?))
|
|
|
|
|
(alist-cons previous entry downgrade)
|
|
|
|
|
downgrade)))))))
|
2014-08-30 21:52:32 +02:00
|
|
|
|
|
2014-08-13 22:03:53 +02:00
|
|
|
|
(define (manifest-perform-transaction manifest transaction)
|
|
|
|
|
"Perform TRANSACTION on MANIFEST and return new manifest."
|
|
|
|
|
(let ((install (manifest-transaction-install transaction))
|
|
|
|
|
(remove (manifest-transaction-remove transaction)))
|
|
|
|
|
(manifest-add (manifest-remove manifest remove)
|
|
|
|
|
install)))
|
|
|
|
|
|
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.
|
|
|
|
|
;;;
|
|
|
|
|
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(define (manifest-inputs manifest)
|
2015-03-15 21:51:34 +01:00
|
|
|
|
"Return a list of <gexp-input> objects for MANIFEST."
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(append-map (match-lambda
|
2015-03-15 21:51:34 +01:00
|
|
|
|
(($ <manifest-entry> name version output thing deps)
|
|
|
|
|
;; THING may be a package or a file name. In the latter case,
|
|
|
|
|
;; assume it's already valid. Ditto for DEPS.
|
|
|
|
|
(cons (gexp-input thing output) deps)))
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(manifest-entries manifest)))
|
|
|
|
|
|
2016-04-30 08:52:30 +02:00
|
|
|
|
(define (manifest-lookup-package manifest name)
|
|
|
|
|
"Return as a monadic value the first package or store path referenced by
|
|
|
|
|
MANIFEST that named NAME, or #f if not found."
|
|
|
|
|
;; Return as a monadic value the package or store path referenced by the
|
|
|
|
|
;; manifest ENTRY, or #f if not referenced.
|
|
|
|
|
(define (entry-lookup-package entry)
|
|
|
|
|
(define (find-among-inputs inputs)
|
|
|
|
|
(find (lambda (input)
|
|
|
|
|
(and (package? input)
|
|
|
|
|
(equal? name (package-name input))))
|
|
|
|
|
inputs))
|
|
|
|
|
(define (find-among-store-items items)
|
|
|
|
|
(find (lambda (item)
|
|
|
|
|
(equal? name (package-name->name+version
|
|
|
|
|
(store-path-package-name item))))
|
|
|
|
|
items))
|
|
|
|
|
|
|
|
|
|
;; TODO: Factorize.
|
|
|
|
|
(define references*
|
|
|
|
|
(store-lift references))
|
|
|
|
|
|
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(match (manifest-entry-item entry)
|
|
|
|
|
((? package? package)
|
|
|
|
|
(match (package-transitive-inputs package)
|
|
|
|
|
(((labels inputs . _) ...)
|
|
|
|
|
(return (find-among-inputs inputs)))))
|
|
|
|
|
((? string? item)
|
|
|
|
|
(mlet %store-monad ((refs (references* item)))
|
|
|
|
|
(return (find-among-store-items refs)))))))
|
|
|
|
|
|
|
|
|
|
(anym %store-monad
|
|
|
|
|
entry-lookup-package (manifest-entries manifest)))
|
|
|
|
|
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(define (info-dir-file manifest)
|
|
|
|
|
"Return a derivation that builds the 'dir' file for all the entries of
|
|
|
|
|
MANIFEST."
|
2014-08-27 11:00:11 +02:00
|
|
|
|
(define texinfo ;lazy reference
|
|
|
|
|
(module-ref (resolve-interface '(gnu packages texinfo)) 'texinfo))
|
|
|
|
|
(define gzip ;lazy reference
|
|
|
|
|
(module-ref (resolve-interface '(gnu packages compression)) 'gzip))
|
|
|
|
|
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(define build
|
2014-07-26 22:08:10 +02:00
|
|
|
|
#~(begin
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(use-modules (guix build utils)
|
|
|
|
|
(srfi srfi-1) (srfi srfi-26)
|
|
|
|
|
(ice-9 ftw))
|
|
|
|
|
|
|
|
|
|
(define (info-file? file)
|
|
|
|
|
(or (string-suffix? ".info" file)
|
|
|
|
|
(string-suffix? ".info.gz" file)))
|
|
|
|
|
|
|
|
|
|
(define (info-files top)
|
|
|
|
|
(let ((infodir (string-append top "/share/info")))
|
|
|
|
|
(map (cut string-append infodir "/" <>)
|
2014-08-25 10:27:20 +02:00
|
|
|
|
(or (scandir infodir info-file?) '()))))
|
2014-08-23 18:41:14 +02:00
|
|
|
|
|
|
|
|
|
(define (install-info info)
|
2014-08-27 11:00:11 +02:00
|
|
|
|
(setenv "PATH" (string-append #+gzip "/bin")) ;for info.gz files
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(zero?
|
2015-12-14 19:24:22 +01:00
|
|
|
|
(system* (string-append #+texinfo "/bin/install-info") "--silent"
|
2014-08-23 18:41:14 +02:00
|
|
|
|
info (string-append #$output "/share/info/dir"))))
|
|
|
|
|
|
|
|
|
|
(mkdir-p (string-append #$output "/share/info"))
|
|
|
|
|
(every install-info
|
|
|
|
|
(append-map info-files
|
|
|
|
|
'#$(manifest-inputs manifest)))))
|
|
|
|
|
|
2015-04-15 22:44:51 +02:00
|
|
|
|
(gexp->derivation "info-dir" build
|
2015-09-24 22:13:11 +02:00
|
|
|
|
#:modules '((guix build utils))
|
|
|
|
|
#:local-build? #t
|
|
|
|
|
#:substitutable? #f))
|
2014-08-23 18:41:14 +02:00
|
|
|
|
|
2015-04-04 22:51:13 +02:00
|
|
|
|
(define (ghc-package-cache-file manifest)
|
|
|
|
|
"Return a derivation that builds the GHC 'package.cache' file for all the
|
2015-04-15 22:44:51 +02:00
|
|
|
|
entries of MANIFEST, or #f if MANIFEST does not have any GHC packages."
|
2015-04-04 22:51:13 +02:00
|
|
|
|
(define ghc ;lazy reference
|
|
|
|
|
(module-ref (resolve-interface '(gnu packages haskell)) 'ghc))
|
|
|
|
|
|
|
|
|
|
(define build
|
2015-05-18 13:51:56 +02:00
|
|
|
|
#~(begin
|
2015-04-04 22:51:13 +02:00
|
|
|
|
(use-modules (guix build utils)
|
|
|
|
|
(srfi srfi-1) (srfi srfi-26)
|
|
|
|
|
(ice-9 ftw))
|
|
|
|
|
|
|
|
|
|
(define ghc-name-version
|
|
|
|
|
(let* ((base (basename #+ghc)))
|
|
|
|
|
(string-drop base
|
|
|
|
|
(+ 1 (string-index base #\-)))))
|
2015-05-18 13:51:56 +02:00
|
|
|
|
|
2015-04-04 22:51:13 +02:00
|
|
|
|
(define db-subdir
|
|
|
|
|
(string-append "lib/" ghc-name-version "/package.conf.d"))
|
|
|
|
|
|
|
|
|
|
(define db-dir
|
|
|
|
|
(string-append #$output "/" db-subdir))
|
2015-05-18 13:51:56 +02:00
|
|
|
|
|
2015-04-04 22:51:13 +02:00
|
|
|
|
(define (conf-files top)
|
2015-06-06 13:38:58 +02:00
|
|
|
|
(let ((db (string-append top "/" db-subdir)))
|
|
|
|
|
(if (file-exists? db)
|
|
|
|
|
(find-files db "\\.conf$")
|
|
|
|
|
'())))
|
2015-04-04 22:51:13 +02:00
|
|
|
|
|
|
|
|
|
(define (copy-conf-file conf)
|
|
|
|
|
(let ((base (basename conf)))
|
|
|
|
|
(copy-file conf (string-append db-dir "/" base))))
|
2015-05-18 13:51:56 +02:00
|
|
|
|
|
2015-04-04 22:51:13 +02:00
|
|
|
|
(system* (string-append #+ghc "/bin/ghc-pkg") "init" db-dir)
|
|
|
|
|
(for-each copy-conf-file
|
|
|
|
|
(append-map conf-files
|
2015-06-06 13:43:19 +02:00
|
|
|
|
(delete-duplicates
|
|
|
|
|
'#$(manifest-inputs manifest))))
|
2015-04-04 22:51:13 +02:00
|
|
|
|
(let ((success
|
|
|
|
|
(zero?
|
|
|
|
|
(system* (string-append #+ghc "/bin/ghc-pkg") "recache"
|
|
|
|
|
(string-append "--package-db=" db-dir)))))
|
|
|
|
|
(for-each delete-file (find-files db-dir "\\.conf$"))
|
|
|
|
|
success)))
|
|
|
|
|
|
2015-05-26 23:38:27 +02:00
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
;; Don't depend on GHC when there's nothing to do.
|
|
|
|
|
(if (any (cut string-prefix? "ghc" <>)
|
|
|
|
|
(map manifest-entry-name (manifest-entries manifest)))
|
|
|
|
|
(gexp->derivation "ghc-package-cache" build
|
|
|
|
|
#:modules '((guix build utils))
|
2015-09-24 22:13:11 +02:00
|
|
|
|
#:local-build? #t
|
|
|
|
|
#:substitutable? #f)
|
2015-05-26 23:38:27 +02:00
|
|
|
|
(return #f))))
|
2015-04-04 22:51:13 +02:00
|
|
|
|
|
2015-03-03 08:09:30 +01:00
|
|
|
|
(define (ca-certificate-bundle manifest)
|
|
|
|
|
"Return a derivation that builds a single-file bundle containing the CA
|
|
|
|
|
certificates in the /etc/ssl/certs sub-directories of the packages in
|
|
|
|
|
MANIFEST. Single-file bundles are required by programs such as Git and Lynx."
|
|
|
|
|
;; See <http://lists.gnu.org/archive/html/guix-devel/2015-02/msg00429.html>
|
|
|
|
|
;; for a discussion.
|
|
|
|
|
|
|
|
|
|
(define glibc-utf8-locales ;lazy reference
|
|
|
|
|
(module-ref (resolve-interface '(gnu packages base)) 'glibc-utf8-locales))
|
|
|
|
|
|
|
|
|
|
(define build
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils)
|
|
|
|
|
(rnrs io ports)
|
|
|
|
|
(srfi srfi-1)
|
|
|
|
|
(srfi srfi-26)
|
2015-04-20 10:20:17 +02:00
|
|
|
|
(ice-9 ftw)
|
|
|
|
|
(ice-9 match))
|
2015-03-03 08:09:30 +01:00
|
|
|
|
|
|
|
|
|
(define (pem-file? file)
|
|
|
|
|
(string-suffix? ".pem" file))
|
|
|
|
|
|
|
|
|
|
(define (ca-files top)
|
|
|
|
|
(let ((cert-dir (string-append top "/etc/ssl/certs")))
|
|
|
|
|
(map (cut string-append cert-dir "/" <>)
|
|
|
|
|
(or (scandir cert-dir pem-file?) '()))))
|
|
|
|
|
|
|
|
|
|
(define (concatenate-files files result)
|
|
|
|
|
"Make RESULT the concatenation of all of FILES."
|
|
|
|
|
(define (dump file port)
|
|
|
|
|
(display (call-with-input-file file get-string-all)
|
|
|
|
|
port)
|
|
|
|
|
(newline port)) ;required, see <https://bugs.debian.org/635570>
|
|
|
|
|
|
|
|
|
|
(call-with-output-file result
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(for-each (cut dump <> port) files))))
|
|
|
|
|
|
|
|
|
|
;; Some file names in the NSS certificates are UTF-8 encoded so
|
|
|
|
|
;; install a UTF-8 locale.
|
2015-10-03 18:02:30 +02:00
|
|
|
|
(setenv "LOCPATH"
|
|
|
|
|
(string-append #+glibc-utf8-locales "/lib/locale/"
|
|
|
|
|
#+(package-version glibc-utf8-locales)))
|
2015-10-03 20:12:59 +02:00
|
|
|
|
(setlocale LC_ALL "en_US.utf8")
|
2015-03-03 08:09:30 +01:00
|
|
|
|
|
2015-04-20 10:20:17 +02:00
|
|
|
|
(match (append-map ca-files '#$(manifest-inputs manifest))
|
|
|
|
|
(()
|
|
|
|
|
;; Since there are no CA files, just create an empty directory. Do
|
|
|
|
|
;; not create the etc/ssl/certs sub-directory, since that would
|
|
|
|
|
;; wrongfully lead to a message about 'SSL_CERT_DIR' needing to be
|
|
|
|
|
;; defined.
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
#t)
|
|
|
|
|
((ca-files ...)
|
|
|
|
|
(let ((result (string-append #$output "/etc/ssl/certs")))
|
|
|
|
|
(mkdir-p result)
|
|
|
|
|
(concatenate-files ca-files
|
|
|
|
|
(string-append result
|
|
|
|
|
"/ca-certificates.crt"))
|
|
|
|
|
#t)))))
|
2015-03-03 08:09:30 +01:00
|
|
|
|
|
2015-04-15 22:44:51 +02:00
|
|
|
|
(gexp->derivation "ca-certificate-bundle" build
|
|
|
|
|
#:modules '((guix build utils))
|
2015-09-24 22:13:11 +02:00
|
|
|
|
#:local-build? #t
|
|
|
|
|
#:substitutable? #f))
|
2015-04-15 22:44:51 +02:00
|
|
|
|
|
2015-05-27 14:58:27 +02:00
|
|
|
|
(define (gtk-icon-themes manifest)
|
|
|
|
|
"Return a derivation that unions all icon themes from manifest entries and
|
|
|
|
|
creates the GTK+ 'icon-theme.cache' file for each theme."
|
2016-04-30 08:52:30 +02:00
|
|
|
|
(mlet %store-monad ((gtk+ (manifest-lookup-package manifest "gtk+")))
|
2015-05-27 14:58:27 +02:00
|
|
|
|
(define build
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils)
|
|
|
|
|
(guix build union)
|
2015-05-27 22:36:52 +02:00
|
|
|
|
(guix build profiles)
|
2015-05-27 14:58:27 +02:00
|
|
|
|
(srfi srfi-26)
|
|
|
|
|
(ice-9 ftw))
|
2015-05-27 22:36:52 +02:00
|
|
|
|
|
2015-05-27 14:58:27 +02:00
|
|
|
|
(let* ((destdir (string-append #$output "/share/icons"))
|
|
|
|
|
(icondirs (filter file-exists?
|
|
|
|
|
(map (cut string-append <> "/share/icons")
|
|
|
|
|
'#$(manifest-inputs manifest))))
|
|
|
|
|
(update-icon-cache (string-append
|
|
|
|
|
#+gtk+ "/bin/gtk-update-icon-cache")))
|
|
|
|
|
|
|
|
|
|
;; Union all the icons.
|
|
|
|
|
(mkdir-p (string-append #$output "/share"))
|
2015-12-04 15:53:31 +01:00
|
|
|
|
(union-build destdir icondirs
|
|
|
|
|
#:log-port (%make-void-port "w"))
|
2015-05-27 22:36:52 +02:00
|
|
|
|
|
2015-05-27 14:58:27 +02:00
|
|
|
|
;; Update the 'icon-theme.cache' file for each icon theme.
|
|
|
|
|
(for-each
|
|
|
|
|
(lambda (theme)
|
2015-05-28 14:38:50 +02:00
|
|
|
|
(let ((dir (string-append destdir "/" theme)))
|
|
|
|
|
;; Occasionally DESTDIR contains plain files, such as
|
|
|
|
|
;; "abiword_48.png". Ignore these.
|
|
|
|
|
(when (file-is-directory? dir)
|
|
|
|
|
(ensure-writable-directory dir)
|
2015-12-04 15:57:03 +01:00
|
|
|
|
(system* update-icon-cache "-t" dir "--quiet"))))
|
2015-05-27 14:58:27 +02:00
|
|
|
|
(scandir destdir (negate (cut member <> '("." ".."))))))))
|
|
|
|
|
|
|
|
|
|
;; Don't run the hook when there's nothing to do.
|
|
|
|
|
(if gtk+
|
|
|
|
|
(gexp->derivation "gtk-icon-themes" build
|
|
|
|
|
#:modules '((guix build utils)
|
|
|
|
|
(guix build union)
|
|
|
|
|
(guix build profiles)
|
|
|
|
|
(guix search-paths)
|
|
|
|
|
(guix records))
|
2015-09-24 22:13:11 +02:00
|
|
|
|
#:local-build? #t
|
|
|
|
|
#:substitutable? #f)
|
2015-05-27 14:58:27 +02:00
|
|
|
|
(return #f))))
|
|
|
|
|
|
2016-02-04 08:33:07 +01:00
|
|
|
|
(define (xdg-desktop-database manifest)
|
|
|
|
|
"Return a derivation that builds the @file{mimeinfo.cache} database from
|
|
|
|
|
desktop files. It's used to query what applications can handle a given
|
|
|
|
|
MIME type."
|
2016-04-30 08:52:30 +02:00
|
|
|
|
(mlet %store-monad ((desktop-file-utils
|
|
|
|
|
(manifest-lookup-package
|
|
|
|
|
manifest "desktop-file-utils")))
|
|
|
|
|
(define build
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (srfi srfi-26)
|
|
|
|
|
(guix build utils)
|
|
|
|
|
(guix build union))
|
|
|
|
|
(let* ((destdir (string-append #$output "/share/applications"))
|
|
|
|
|
(appdirs (filter file-exists?
|
|
|
|
|
(map (cut string-append <>
|
|
|
|
|
"/share/applications")
|
|
|
|
|
'#$(manifest-inputs manifest))))
|
|
|
|
|
(update-desktop-database (string-append
|
|
|
|
|
#+desktop-file-utils
|
|
|
|
|
"/bin/update-desktop-database")))
|
|
|
|
|
(mkdir-p (string-append #$output "/share"))
|
|
|
|
|
(union-build destdir appdirs
|
|
|
|
|
#:log-port (%make-void-port "w"))
|
|
|
|
|
(zero? (system* update-desktop-database destdir)))))
|
2016-02-04 08:33:07 +01:00
|
|
|
|
|
2016-04-30 08:52:30 +02:00
|
|
|
|
;; Don't run the hook when 'desktop-file-utils' is not referenced.
|
|
|
|
|
(if desktop-file-utils
|
|
|
|
|
(gexp->derivation "xdg-desktop-database" build
|
|
|
|
|
#:modules '((guix build utils)
|
|
|
|
|
(guix build union))
|
|
|
|
|
#:local-build? #t
|
|
|
|
|
#:substitutable? #f)
|
|
|
|
|
(return #f))))
|
2016-02-04 08:33:07 +01:00
|
|
|
|
|
2016-02-04 08:35:03 +01:00
|
|
|
|
(define (xdg-mime-database manifest)
|
|
|
|
|
"Return a derivation that builds the @file{mime.cache} database from manifest
|
|
|
|
|
entries. It's used to query the MIME type of a given file."
|
2016-04-30 08:52:30 +02:00
|
|
|
|
(mlet %store-monad ((shared-mime-info
|
|
|
|
|
(manifest-lookup-package
|
|
|
|
|
manifest "shared-mime-info")))
|
|
|
|
|
(define build
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (srfi srfi-26)
|
|
|
|
|
(guix build utils)
|
|
|
|
|
(guix build union))
|
|
|
|
|
(let* ((datadir (string-append #$output "/share"))
|
|
|
|
|
(destdir (string-append datadir "/mime"))
|
|
|
|
|
(mimedirs (filter file-exists?
|
|
|
|
|
(map (cut string-append <>
|
|
|
|
|
"/share/mime")
|
|
|
|
|
'#$(manifest-inputs manifest))))
|
|
|
|
|
(update-mime-database (string-append
|
|
|
|
|
#+shared-mime-info
|
|
|
|
|
"/bin/update-mime-database")))
|
|
|
|
|
(mkdir-p datadir)
|
|
|
|
|
(union-build destdir mimedirs
|
|
|
|
|
#:log-port (%make-void-port "w"))
|
|
|
|
|
(setenv "XDG_DATA_HOME" datadir)
|
|
|
|
|
(zero? (system* update-mime-database destdir)))))
|
|
|
|
|
|
|
|
|
|
;; Don't run the hook when 'shared-mime-info' is referenced.
|
|
|
|
|
(if shared-mime-info
|
|
|
|
|
(gexp->derivation "xdg-mime-database" build
|
|
|
|
|
#:modules '((guix build utils)
|
|
|
|
|
(guix build union))
|
|
|
|
|
#:local-build? #t
|
|
|
|
|
#:substitutable? #f)
|
|
|
|
|
(return #f))))
|
2016-02-04 08:35:03 +01:00
|
|
|
|
|
2015-04-15 22:44:51 +02:00
|
|
|
|
(define %default-profile-hooks
|
|
|
|
|
;; This is the list of derivation-returning procedures that are called by
|
|
|
|
|
;; default when making a non-empty profile.
|
|
|
|
|
(list info-dir-file
|
|
|
|
|
ghc-package-cache-file
|
2015-05-27 14:58:27 +02:00
|
|
|
|
ca-certificate-bundle
|
2016-02-04 08:33:07 +01:00
|
|
|
|
gtk-icon-themes
|
2016-02-04 08:35:03 +01:00
|
|
|
|
xdg-desktop-database
|
|
|
|
|
xdg-mime-database))
|
2015-03-03 08:09:30 +01:00
|
|
|
|
|
|
|
|
|
(define* (profile-derivation manifest
|
|
|
|
|
#:key
|
2016-02-12 19:12:18 +01:00
|
|
|
|
(hooks %default-profile-hooks)
|
|
|
|
|
system)
|
2014-08-23 18:41:14 +02:00
|
|
|
|
"Return a derivation that builds a profile (aka. 'user environment') with
|
2015-04-15 22:44:51 +02:00
|
|
|
|
the given MANIFEST. The profile includes additional derivations returned by
|
|
|
|
|
the monadic procedures listed in HOOKS--such as an Info 'dir' file, etc."
|
2016-02-12 19:12:18 +01:00
|
|
|
|
(mlet %store-monad ((system (if system
|
|
|
|
|
(return system)
|
|
|
|
|
(current-system)))
|
|
|
|
|
(extras (if (null? (manifest-entries manifest))
|
2015-04-15 22:44:51 +02:00
|
|
|
|
(return '())
|
|
|
|
|
(sequence %store-monad
|
2015-05-26 23:38:27 +02:00
|
|
|
|
(map (lambda (hook)
|
|
|
|
|
(hook manifest))
|
|
|
|
|
hooks)))))
|
2014-08-23 18:41:14 +02:00
|
|
|
|
(define inputs
|
2015-05-27 15:03:21 +02:00
|
|
|
|
(append (filter-map (lambda (drv)
|
|
|
|
|
(and (derivation? drv)
|
|
|
|
|
(gexp-input drv)))
|
2015-05-26 23:38:27 +02:00
|
|
|
|
extras)
|
2015-03-03 08:09:30 +01:00
|
|
|
|
(manifest-inputs manifest)))
|
2014-08-23 18:41:14 +02:00
|
|
|
|
|
|
|
|
|
(define builder
|
|
|
|
|
#~(begin
|
2015-05-06 17:08:00 +02:00
|
|
|
|
(use-modules (guix build profiles)
|
2015-08-20 19:12:36 +02:00
|
|
|
|
(guix search-paths)
|
|
|
|
|
(srfi srfi-1))
|
2014-08-23 18:41:14 +02:00
|
|
|
|
|
|
|
|
|
(setvbuf (current-output-port) _IOLBF)
|
|
|
|
|
(setvbuf (current-error-port) _IOLBF)
|
|
|
|
|
|
2015-05-06 17:08:00 +02:00
|
|
|
|
(define search-paths
|
|
|
|
|
;; Search paths of MANIFEST's packages, converted back to their
|
|
|
|
|
;; record form.
|
|
|
|
|
(map sexp->search-path-specification
|
2015-08-20 19:12:36 +02:00
|
|
|
|
(delete-duplicates
|
|
|
|
|
'#$(map search-path-specification->sexp
|
|
|
|
|
(append-map manifest-entry-search-paths
|
|
|
|
|
(manifest-entries manifest))))))
|
2015-05-06 17:08:00 +02:00
|
|
|
|
|
2015-05-06 14:14:58 +02:00
|
|
|
|
(build-profile #$output '#$inputs
|
2015-05-06 17:08:00 +02:00
|
|
|
|
#:manifest '#$(manifest->gexp manifest)
|
|
|
|
|
#:search-paths search-paths)))
|
2014-08-23 18:41:14 +02:00
|
|
|
|
|
|
|
|
|
(gexp->derivation "profile" builder
|
2016-06-05 00:04:05 +02:00
|
|
|
|
#:system system
|
2015-05-06 17:08:00 +02:00
|
|
|
|
#:modules '((guix build profiles)
|
|
|
|
|
(guix build union)
|
|
|
|
|
(guix build utils)
|
|
|
|
|
(guix search-paths)
|
|
|
|
|
(guix records))
|
2015-09-24 22:13:11 +02:00
|
|
|
|
|
|
|
|
|
;; Not worth offloading.
|
|
|
|
|
#:local-build? #t
|
|
|
|
|
|
|
|
|
|
;; Disable substitution because it would trigger a
|
|
|
|
|
;; connection to the substitute server, which is likely
|
|
|
|
|
;; to have no substitute to offer.
|
|
|
|
|
#:substitutable? #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 (profile-regexp profile)
|
|
|
|
|
"Return a regular expression that matches PROFILE's name and number."
|
|
|
|
|
(make-regexp (string-append "^" (regexp-quote (basename profile))
|
|
|
|
|
"-([0-9]+)")))
|
|
|
|
|
|
|
|
|
|
(define (generation-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))
|
|
|
|
|
|
|
|
|
|
(define (generation-numbers profile)
|
|
|
|
|
"Return the sorted list of generation numbers of PROFILE, or '(0) if no
|
|
|
|
|
former profiles were found."
|
|
|
|
|
(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)
|
|
|
|
|
(cute regexp-exec (profile-regexp profile) <>))
|
|
|
|
|
(#f ; no profile directory
|
|
|
|
|
'(0))
|
|
|
|
|
(() ; no profiles
|
|
|
|
|
'(0))
|
|
|
|
|
((profiles ...) ; former profiles around
|
|
|
|
|
(sort (map (compose string->number
|
|
|
|
|
(cut match:substring <> 1)
|
|
|
|
|
(cute regexp-exec (profile-regexp profile) <>))
|
|
|
|
|
profiles)
|
|
|
|
|
<))))
|
|
|
|
|
|
2014-09-21 12:24:09 +02:00
|
|
|
|
(define (profile-generations profile)
|
|
|
|
|
"Return a list of PROFILE's generations."
|
|
|
|
|
(let ((generations (generation-numbers profile)))
|
|
|
|
|
(if (equal? generations '(0))
|
|
|
|
|
'()
|
|
|
|
|
generations)))
|
|
|
|
|
|
2014-10-10 15:56:59 +02:00
|
|
|
|
(define* (relative-generation profile shift #:optional
|
|
|
|
|
(current (generation-number profile)))
|
|
|
|
|
"Return PROFILE's generation shifted from the CURRENT generation by SHIFT.
|
|
|
|
|
SHIFT is a positive or negative number.
|
|
|
|
|
Return #f if there is no such generation."
|
|
|
|
|
(let* ((abs-shift (abs shift))
|
|
|
|
|
(numbers (profile-generations profile))
|
|
|
|
|
(from-current (memq current
|
|
|
|
|
(if (negative? shift)
|
|
|
|
|
(reverse numbers)
|
|
|
|
|
numbers))))
|
|
|
|
|
(and from-current
|
|
|
|
|
(< abs-shift (length from-current))
|
|
|
|
|
(list-ref from-current abs-shift))))
|
|
|
|
|
|
|
|
|
|
(define* (previous-generation-number profile #:optional
|
|
|
|
|
(number (generation-number profile)))
|
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
|
|
|
|
"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\")."
|
2014-10-10 15:56:59 +02:00
|
|
|
|
(or (relative-generation profile -1 number)
|
|
|
|
|
0))
|
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 (generation-file-name profile generation)
|
|
|
|
|
"Return the file name for PROFILE's GENERATION."
|
|
|
|
|
(format #f "~a-~a-link" profile generation))
|
|
|
|
|
|
|
|
|
|
(define (generation-time profile number)
|
|
|
|
|
"Return the creation time of a generation in the UTC format."
|
|
|
|
|
(make-time time-utc 0
|
|
|
|
|
(stat:ctime (stat (generation-file-name profile number)))))
|
|
|
|
|
|
2015-10-26 23:01:06 +01:00
|
|
|
|
(define (link-to-empty-profile store generation)
|
|
|
|
|
"Link GENERATION, a string, to the empty profile. An error is raised if
|
|
|
|
|
that fails."
|
|
|
|
|
(let* ((drv (run-with-store store
|
|
|
|
|
(profile-derivation (manifest '()))))
|
|
|
|
|
(prof (derivation->output-path drv "out")))
|
|
|
|
|
(build-derivations store (list drv))
|
|
|
|
|
(switch-symlinks generation prof)))
|
|
|
|
|
|
|
|
|
|
(define (switch-to-generation profile number)
|
|
|
|
|
"Atomically switch PROFILE to the generation NUMBER. Return the number of
|
|
|
|
|
the generation that was current before switching."
|
|
|
|
|
(let ((current (generation-number profile))
|
|
|
|
|
(generation (generation-file-name profile number)))
|
|
|
|
|
(cond ((not (file-exists? profile))
|
|
|
|
|
(raise (condition (&profile-not-found-error
|
|
|
|
|
(profile profile)))))
|
|
|
|
|
((not (file-exists? generation))
|
|
|
|
|
(raise (condition (&missing-generation-error
|
|
|
|
|
(profile profile)
|
|
|
|
|
(generation number)))))
|
|
|
|
|
(else
|
|
|
|
|
(switch-symlinks profile generation)
|
|
|
|
|
current))))
|
|
|
|
|
|
|
|
|
|
(define (switch-to-previous-generation profile)
|
|
|
|
|
"Atomically switch PROFILE to the previous generation. Return the former
|
|
|
|
|
generation number and the current one."
|
|
|
|
|
(let ((previous (previous-generation-number profile)))
|
|
|
|
|
(values (switch-to-generation profile previous)
|
|
|
|
|
previous)))
|
|
|
|
|
|
|
|
|
|
(define (roll-back store profile)
|
|
|
|
|
"Roll back to the previous generation of PROFILE. Return the number of the
|
|
|
|
|
generation that was current before switching and the new generation number."
|
|
|
|
|
(let* ((number (generation-number profile))
|
|
|
|
|
(previous-number (previous-generation-number profile number))
|
|
|
|
|
(previous-generation (generation-file-name profile previous-number)))
|
|
|
|
|
(cond ((not (file-exists? profile)) ;invalid profile
|
|
|
|
|
(raise (condition (&profile-not-found-error
|
|
|
|
|
(profile profile)))))
|
|
|
|
|
((zero? number) ;empty profile
|
|
|
|
|
(values number number))
|
|
|
|
|
((or (zero? previous-number) ;going to emptiness
|
|
|
|
|
(not (file-exists? previous-generation)))
|
|
|
|
|
(link-to-empty-profile store previous-generation)
|
|
|
|
|
(switch-to-previous-generation profile))
|
|
|
|
|
(else ;anything else
|
|
|
|
|
(switch-to-previous-generation profile)))))
|
|
|
|
|
|
|
|
|
|
(define (delete-generation store profile number)
|
|
|
|
|
"Delete generation with NUMBER from PROFILE. Return the file name of the
|
|
|
|
|
generation that has been deleted, or #f if nothing was done (for instance
|
|
|
|
|
because the NUMBER is zero.)"
|
|
|
|
|
(define (delete-and-return)
|
|
|
|
|
(let ((generation (generation-file-name profile number)))
|
|
|
|
|
(delete-file generation)
|
|
|
|
|
generation))
|
|
|
|
|
|
|
|
|
|
(let* ((current-number (generation-number profile))
|
|
|
|
|
(previous-number (previous-generation-number profile number))
|
|
|
|
|
(previous-generation (generation-file-name profile previous-number)))
|
|
|
|
|
(cond ((zero? number) #f) ;do not delete generation 0
|
|
|
|
|
((and (= number current-number)
|
|
|
|
|
(not (file-exists? previous-generation)))
|
|
|
|
|
(link-to-empty-profile store previous-generation)
|
|
|
|
|
(switch-to-previous-generation profile)
|
|
|
|
|
(delete-and-return))
|
|
|
|
|
((= number current-number)
|
|
|
|
|
(roll-back store profile)
|
|
|
|
|
(delete-and-return))
|
|
|
|
|
(else
|
|
|
|
|
(delete-and-return)))))
|
|
|
|
|
|
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.scm ends here
|