guix package: Rename generation-related procedures.

* guix/scripts/package.scm (profile-numbers): Rename to 'generation-numbers'.
  (previous-profile-number): Rename to 'previous-generation-number'.
  (profile-number): Rename to 'generation-number'.
  (roll-back): Rename 'previous-profile' to 'previous-generation'.
This commit is contained in:
Nikita Karetnikov 2013-09-12 17:31:53 +00:00
parent 7763c538ad
commit 1b0a8212d1

View file

@ -95,7 +95,7 @@ (define (profile-regexp profile)
(make-regexp (string-append "^" (regexp-quote (basename profile)) (make-regexp (string-append "^" (regexp-quote (basename profile))
"-([0-9]+)"))) "-([0-9]+)")))
(define (profile-numbers profile) (define (generation-numbers profile)
"Return the list of generation numbers of PROFILE, or '(0) if no "Return the list of generation numbers of PROFILE, or '(0) if no
former profiles were found." former profiles were found."
(define* (scandir name #:optional (select? (const #t)) (define* (scandir name #:optional (select? (const #t))
@ -144,7 +144,7 @@ (define (error name* stat errno result)
(cute regexp-exec (profile-regexp profile) <>)) (cute regexp-exec (profile-regexp profile) <>))
profiles)))) profiles))))
(define (previous-profile-number profile number) (define (previous-generation-number profile number)
"Return the number of the generation before generation NUMBER of "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 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\")." case when generations have been deleted (there are \"holes\")."
@ -153,7 +153,7 @@ (define (previous-profile-number profile number)
candidate candidate
highest)) highest))
0 0
(profile-numbers profile))) (generation-numbers profile)))
(define (profile-derivation store packages) (define (profile-derivation store packages)
"Return a derivation that builds a profile (a user environment) with "Return a derivation that builds a profile (a user environment) with
@ -205,7 +205,7 @@ (define ensure-valid-input
packages) packages)
#:modules '((guix build union)))) #:modules '((guix build union))))
(define (profile-number profile) (define (generation-number profile)
"Return PROFILE's number or 0. An absolute file name must be used." "Return PROFILE's number or 0. An absolute file name must be used."
(or (and=> (false-if-exception (regexp-exec (profile-regexp profile) (or (and=> (false-if-exception (regexp-exec (profile-regexp profile)
(basename (readlink profile)))) (basename (readlink profile))))
@ -214,17 +214,17 @@ (define (profile-number profile)
(define (roll-back profile) (define (roll-back profile)
"Roll back to the previous generation of PROFILE." "Roll back to the previous generation of PROFILE."
(let* ((number (profile-number profile)) (let* ((number (generation-number profile))
(previous-number (previous-profile-number profile number)) (previous-number (previous-generation-number profile number))
(previous-profile (format #f "~a-~a-link" (previous-generation (format #f "~a-~a-link"
profile previous-number)) profile previous-number))
(manifest (string-append previous-profile "/manifest"))) (manifest (string-append previous-generation "/manifest")))
(define (switch-link) (define (switch-link)
;; Atomically switch PROFILE to the previous profile. ;; Atomically switch PROFILE to the previous generation.
(format #t (_ "switching from generation ~a to ~a~%") (format #t (_ "switching from generation ~a to ~a~%")
number previous-number) number previous-number)
(switch-symlinks profile previous-profile)) (switch-symlinks profile previous-generation))
(cond ((not (file-exists? profile)) ; invalid profile (cond ((not (file-exists? profile)) ; invalid profile
(leave (_ "profile `~a' does not exist~%") (leave (_ "profile `~a' does not exist~%")
@ -233,7 +233,7 @@ (define (switch-link)
(format (current-error-port) (format (current-error-port)
(_ "nothing to do: already at the empty profile~%"))) (_ "nothing to do: already at the empty profile~%")))
((or (zero? previous-number) ; going to emptiness ((or (zero? previous-number) ; going to emptiness
(not (file-exists? previous-profile))) (not (file-exists? previous-generation)))
(let*-values (((drv-path drv) (let*-values (((drv-path drv)
(profile-derivation (%store) '())) (profile-derivation (%store) '()))
((prof) ((prof)
@ -242,7 +242,7 @@ (define (switch-link)
(when (not (build-derivations (%store) (list drv-path))) (when (not (build-derivations (%store) (list drv-path)))
(leave (_ "failed to build the empty profile~%"))) (leave (_ "failed to build the empty profile~%")))
(switch-symlinks previous-profile prof) (switch-symlinks previous-generation prof)
(switch-link))) (switch-link)))
(else (switch-link))))) ; anything else (else (switch-link))))) ; anything else
@ -846,7 +846,7 @@ (define (show-what-to-remove/install remove install dry-run?)
(%store) (manifest-packages (%store) (manifest-packages
(profile-manifest profile)))) (profile-manifest profile))))
(old-prof (derivation-path->output-path old-drv)) (old-prof (derivation-path->output-path old-drv))
(number (profile-number profile)) (number (generation-number profile))
;; Always use NUMBER + 1 for the new profile, ;; Always use NUMBER + 1 for the new profile,
;; possibly overwriting a "previous future ;; possibly overwriting a "previous future