From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Marusich Subject: bug#26271: 'guix system' does not support common build option '--root' Date: Thu, 06 Apr 2017 00:05:49 -0700 Message-ID: <87wpayf22a.fsf@gmail.com> References: <871stjfhfk.fsf@gmail.com> <87y3vrm6zi.fsf@gnu.org> <87inmu3j12.fsf@gmail.com> <87zifwaafz.fsf@garuda.i-did-not-set--mail-host-address--so-tickle-me> <87zifvn9g8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cw1Va-0003FL-6b for bug-guix@gnu.org; Thu, 06 Apr 2017 03:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cw1VW-0001Ff-Uf for bug-guix@gnu.org; Thu, 06 Apr 2017 03:07:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36172) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cw1VW-0001FW-R0 for bug-guix@gnu.org; Thu, 06 Apr 2017 03:07:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cw1VW-0002Rh-HH for bug-guix@gnu.org; Thu, 06 Apr 2017 03:07:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87zifvn9g8.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 04 Apr 2017 23:34:31 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 26271@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> From ccf03e4bb5d5c2d3a47efdf64e36a7d903bfb2c5 Mon Sep 17 00:00:00 2001 >> From: Chris Marusich >> Date: Mon, 3 Apr 2017 23:47:22 -0700 >> Subject: [PATCH 1/2] build: Export register-root procedure. >> >> * guix/scripts/build.scm: Export register-root procedure. > > Applied. Thank you! >> From e96c877459555f4cf868fb5fe4579183f6a773d5 Mon Sep 17 00:00:00 2001 >> From: Chris Marusich >> Date: Mon, 3 Apr 2017 23:49:22 -0700 >> Subject: [PATCH 2/2] system: Support the --root option in 'guix system'. >> >> Fixes . >> >> * guix/scripts/system.scm (perform-action): Add parameters 'store' and >> 'gc-root'. Update docstring. >> (perform-action) [gc-root]: Add an indirect GC root using store. >> (%options): Add 'root'. >> (process-action): Pass 'store' and 'root' to perform-action. > > [...] > >> -(define* (perform-action action os >> +(define* (perform-action store action os >> #:key grub? dry-run? derivations-only? >> use-substitutes? device target >> image-size full-boot? >> - (mappings '())) > > > [...] > >> ;; All we had to do was to build SYS. >> - (return (derivation->output-path sys)))))))) >> + (return (let ((output-path (derivation->output-path sys))) >> + (if gc-root >> + (register-root store (list output-path) gc-r= oot) >> + output-path))))))))) > > =E2=80=98perform-action=E2=80=99 is a monadic procedure; IOW, the =E2=80= =98store=E2=80=99 parameter is > already threaded into it. Thus, instead of adding an explicit =E2=80=98s= tore=E2=80=99 > parameter, which must =E2=80=9Clift=E2=80=9D =E2=80=98register-root=E2=80= =99 in the store monad: > > (define register-root* > (store-lift register-root)) > > and then use it like a normal monadic procedure: > > (let ((output (derivation->output-path sys))) > (mbegin %store-monad > (mwhen gc-root > (register-root* (list output) gc-root)) > (return output))) > > Could you change this patch along these lines? Thank you for reminding me that we can do it this way! I've updated the patch and verified that it still works. > Also please make sure to mention =E2=80=98--root=E2=80=99 in =E2=80=98sho= w-help=E2=80=99 and in > guix.texi. In the attached patch series, I've mentioned '--root' in 'show-help'. However, since there is already a link in the '(guix) Invoking guix system)' section to the section which describes the common build options ((guix) Common Build Options), I decided not to duplicate the documentation for '--root' in that section. If you still think we should mention '--root' in '(guix) Invoking guix system)', let me know and I will submit another small patch to add it. Now we can generate system images without fear of the reaper! The garbage reaper, that is :-) =2D-=20 Chris --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-build-Add-and-export-procedure-register-root.patch Content-Transfer-Encoding: quoted-printable From=208b768570b26d9a44ea140b0cd29383d32d37a0df Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Tue, 4 Apr 2017 20:24:54 -0700 Subject: [PATCH 1/2] build: Add and export procedure 'register-root*'. * guix/scripts/build.scm (register-root*): Add and export it. =2D-- guix/scripts/build.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index ba47b1232..6bb1f72eb 100644 =2D-- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -52,7 +52,8 @@ show-transformation-options-help =20 guix-build =2D register-root)) + register-root + register-root*)) =20 (define %default-log-urls ;; Default base URLs for build logs. @@ -123,6 +124,9 @@ found. Return #f if no build log was found." (leave (_ "failed to create GC root `~a': ~a~%") root (strerror (system-error-errno args))))))) =20 +(define register-root* + (store-lift register-root)) + (define (package-with-source store p uri) "Return a package based on P but with its source taken from URI. Extract the new package's version number from URI." =2D-=20 2.12.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-system-Support-the-root-option-in-guix-system.patch Content-Transfer-Encoding: quoted-printable From=20430fdb321f3401d5a498f002291ae520d47f1dcf Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Mon, 3 Apr 2017 23:49:22 -0700 Subject: [PATCH 2/2] system: Support the --root option in 'guix system'. Fixes . * guix/scripts/system.scm (perform-action): Add #:gc-root parameter and hon= or it. (show-help): Document the --root option. (%options): Add 'root'. (process-action): Pass 'root' option to perform-action as #:gc-root. =2D-- guix/scripts/system.scm | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 144a7fd37..d867465dd 100644 =2D-- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -593,7 +593,8 @@ PATTERN, a string. When PATTERN is #f, display all the= system generations." #:key grub? dry-run? derivations-only? use-substitutes? device target image-size full-boot? =2D (mappings '())) + (mappings '()) + (gc-root #f)) "Perform ACTION for OS. GRUB? specifies whether to install GRUB; DEVICE= is the target devices for GRUB; TARGET is the target root directory; IMAGE-SI= ZE is the size of the image to be built, for the 'vm-image' and 'disk-image' @@ -601,7 +602,10 @@ actions. FULL-BOOT? is used for the 'vm' action; it d= etermines whether to boot directly to the kernel or to the bootloader. =20 When DERIVATIONS-ONLY? is true, print the derivation file name(s) without =2Dbuilding anything." +building anything. + +When GC-ROOT is a path, also make that path an indirect root of the build +output when building a system derivation, such as a disk image." (define println (cut format #t "~a~%" <>)) =20 @@ -665,8 +669,11 @@ building anything." #:grub.cfg (derivation->output-path grub.cfg) #:device device)) (else =2D ;; All we had to do was to build SYS. =2D (return (derivation->output-path sys)))))))) + ;; All we had to do was to build SYS and maybe register an + ;; indirect GC root. + (mwhen gc-root + (register-root* (list (derivation->output-path sys)) + gc-root)))))))) =20 (define (export-extension-graph os port) "Export the service extension graph of OS to PORT." @@ -741,6 +748,10 @@ Some ACTIONS support additional ARGS.\n")) (display (_ " --share=3DSPEC for 'vm', share host file system according to S= PEC")) (display (_ " + -r, --root=3DFILE for 'vm', 'vm-image', 'disk-image', 'container', + and 'build', make FILE a symlink to the result, a= nd + register it as a garbage collector root.")) + (display (_ " --expose=3DSPEC for 'vm', expose host file system according to = SPEC")) (display (_ " --full-boot for 'vm', make a full boot sequence")) @@ -797,6 +808,9 @@ Some ACTIONS support additional ARGS.\n")) (lambda (opt name arg result) (alist-cons 'system arg (alist-delete 'system result eq?)))) + (option '(#\r "root") #t #f + (lambda (opt name arg result) + (alist-cons 'gc-root arg result))) %standard-build-options)) =20 (define %default-options @@ -863,7 +877,8 @@ resulting from command-line parsing." (_ #f)) opts) #:grub? grub? =2D #:target target #:device device)))) + #:target target #:device device + #:gc-root (assoc-ref opts 'gc-root))))) #:system system)))) =20 (define (process-command command args opts) =2D-=20 2.12.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAljl6M0ACgkQ3UCaFdgi Rp1q9Q//c1c0a2a4q6+/2Yk3IO5OXUy/maX6SUACTx2JNrZAL0488FDwQrvvdbbT iv8WCLnaEaJfJYQitM5kQ3HcfjXdY6Lcjg5ItZfo0lMkyT7ASq/3C6yjnurIm85Y mYzDgRHQcb120v8A4vr7fJypFdBumY6DHD1JhtX0KMqlw076TnKHHf9gv3g2qxjr apEYMIL6qYNzEj70AU+8JdfFhvmXBy/V94jIR8DToxP4Wqzysn5rCyJEhOkgRdnR kItYqx6plovX9neCmdje29VZjRy6D7qnthBj5/kgQBOGuqrvbVOIMH0KZ+7SfaMg B+px1o5VkhN2YovnBsE5PG41lucY6RCG6TMwYqv9MSNQuTMPVsXNSahRuiY/A5D2 pyIiKfhWLVHUhDhSe5SfqGaca7txWWc2oUwfO3+Qo9oHKK5GPtKeZu43nYZem1KN lgzOZ1r2cIVCIhfiMAkl4gW+/YMYAO1qvHqljI7VQNwDnI7gN+ev4TRHXcyxcxrC w9fmLdRe5dHOtn7NVZPGQR2+Vha5RkxuNGg0AvDJumYo4G6loKB3fgfpIQD/s9lx xKz2aJ8oEWscBJPPbULPIMxrlifUUuqnF5TiAX2HSOMKl9uu3sQC3WFUsjtBQ+pC 1u7I1jvAIMKS83dZ9il512lEDPh7AVroaJgN2x+uHvrt0jkc0jE= =4e7a -----END PGP SIGNATURE----- --==-=-=--