From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Karetnikov Subject: [PATCH] guix package: Rename generation-related procedures. Date: Thu, 12 Sep 2013 21:35:01 +0400 Message-ID: <87zjrikkoq.fsf@karetnikov.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKAit-0003tZ-PW for guix-devel@gnu.org; Thu, 12 Sep 2013 13:30:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKAio-0007AW-Fp for guix-devel@gnu.org; Thu, 12 Sep 2013 13:30:31 -0400 Received: from [2a01:7e00::f03c:91ff:fedf:181] (port=50827 helo=cooksoni.karetnikov.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKAio-0007AM-5h for guix-devel@gnu.org; Thu, 12 Sep 2013 13:30:26 -0400 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Can I push this patch to =E2=80=98master=E2=80=99? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-guix-package-Rename-generation-related-procedures.patch Content-Transfer-Encoding: quoted-printable From=20adb7b8383bd6748d12a0b782ab0f67b0b3e2995a Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Thu, 12 Sep 2013 17:31:53 +0000 Subject: [PATCH] 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'. =2D-- guix/scripts/package.scm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 5c3947d..1393ca3 100644 =2D-- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -95,7 +95,7 @@ (make-regexp (string-append "^" (regexp-quote (basename profile)) "-([0-9]+)"))) =20 =2D(define (profile-numbers profile) +(define (generation-numbers profile) "Return the list of generation numbers of PROFILE, or '(0) if no former profiles were found." (define* (scandir name #:optional (select? (const #t)) @@ -144,7 +144,7 @@ former profiles were found." (cute regexp-exec (profile-regexp profile) <>)) profiles)))) =20 =2D(define (previous-profile-number profile number) +(define (previous-generation-number profile number) "Return the number of the generation before generation NUMBER of PROFILE, or 0 if none exists. It could be NUMBER - 1, but it's not the case when generations have been deleted (there are \"holes\")." @@ -153,7 +153,7 @@ case when generations have been deleted (there are \"ho= les\")." candidate highest)) 0 =2D (profile-numbers profile))) + (generation-numbers profile))) =20 (define (profile-derivation store packages) "Return a derivation that builds a profile (a user environment) with @@ -205,7 +205,7 @@ all of PACKAGES, a list of name/version/output/path/dep= s tuples." packages) #:modules '((guix build union)))) =20 =2D(define (profile-number profile) +(define (generation-number profile) "Return PROFILE's number or 0. An absolute file name must be used." (or (and=3D> (false-if-exception (regexp-exec (profile-regexp profile) (basename (readlink profile)= ))) @@ -214,17 +214,17 @@ all of PACKAGES, a list of name/version/output/path/d= eps tuples." =20 (define (roll-back profile) "Roll back to the previous generation of PROFILE." =2D (let* ((number (profile-number profile)) =2D (previous-number (previous-profile-number profile number)) =2D (previous-profile (format #f "~a-~a-link" =2D profile previous-number)) =2D (manifest (string-append previous-profile "/manifest"))) + (let* ((number (generation-number profile)) + (previous-number (previous-generation-number profile number)) + (previous-generation (format #f "~a-~a-link" + profile previous-number)) + (manifest (string-append previous-generation "/manifes= t"))) =20 (define (switch-link) =2D ;; Atomically switch PROFILE to the previous profile. + ;; Atomically switch PROFILE to the previous generation. (format #t (_ "switching from generation ~a to ~a~%") number previous-number) =2D (switch-symlinks profile previous-profile)) + (switch-symlinks profile previous-generation)) =20 (cond ((not (file-exists? profile)) ; invalid profile (leave (_ "profile `~a' does not exist~%") @@ -233,7 +233,7 @@ all of PACKAGES, a list of name/version/output/path/dep= s tuples." (format (current-error-port) (_ "nothing to do: already at the empty profile~%"))) ((or (zero? previous-number) ; going to emptiness =2D (not (file-exists? previous-profile))) + (not (file-exists? previous-generation))) (let*-values (((drv-path drv) (profile-derivation (%store) '())) ((prof) @@ -242,7 +242,7 @@ all of PACKAGES, a list of name/version/output/path/dep= s tuples." (when (not (build-derivations (%store) (list drv-path))) (leave (_ "failed to build the empty profile~%"))) =20 =2D (switch-symlinks previous-profile prof) + (switch-symlinks previous-generation prof) (switch-link))) (else (switch-link))))) ; anything else =20 @@ -846,7 +846,7 @@ more information.~%")) (%store) (manifest-packages (profile-manifest profile))= )) (old-prof (derivation-path->output-path old-drv)) =2D (number (profile-number profile)) + (number (generation-number profile)) =20 ;; Always use NUMBER + 1 for the new profile, ;; possibly overwriting a "previous future =2D-=20 1.7.9.5 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJSMftIAAoJEM+IQzI9IQ38LlIP/RBJ/sExohiHMaA6NjhBfKYv foOfPSNct8Mws1guMn2Bbw8+L6biaC6jb5ljx4RklrNqk40lc1O+gJJ0U6Xu4L81 gZ8woiwfujXRhvO5soK1qQhsG6UOT+Z0Y0Q+ipeCChBB+zI4qFNBJqXVkSPMEuAT 85UFLVebZTXw5GvbV5amI0wNHt9OEuKOQlofW6F2QBdIUe3o40FDtXJRjgmlTfjP kYiE2+XZur7dD3TOgaYFBUHfGuL708CLJxvRWoRlw4qTClCyLJa1B+lqIzzwRYgf jGwuO/EXcqS7e3huk88TXPqX03ToU2Ep1cxYnkSLJpLbY0PFDsZ1Oc7UB4WEUJbd PucgW/6lt0KkoPPvZYTK4an6mu63Rzpf6VXtAUMXl1/1MfpySbaL8LvpGs5W8v2S hBAEUGMuu+7nyGE9h69v80+bAX9N+UBKLNikbv3n6Qnp3KhyOOVYG8b2W8MbzvRq 4rXJ5u3bgoGCAKtPvQICHrnmb3fCQyAiaJWmil8ZzQYp+YcmvpCsOosgPSeJFbwn NlB6IF+CQPcphb34dmJVP/bwFSI2Ak1G95tkl+Zp1c+TY4Z40+HnJSBu99OrZ+YV WKruMok4DR1ptCsvxv6RJv6akmoPflmp0Y1PNRBpqVphdM3dtwsx8ao32IOPvO75 p/KLfPtyM8XYUXlu9XxK =hz8n -----END PGP SIGNATURE----- --==-=-=--