From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Introducing =?utf-8?B?4oCYZ3VpeCBwYWNr4oCZ?= Date: Fri, 10 Mar 2017 22:50:48 +0100 Message-ID: <87d1dodcnb.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]:44585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmSR7-00006L-Go for guix-devel@gnu.org; Fri, 10 Mar 2017 16:50:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmSR3-0004fX-8R for guix-devel@gnu.org; Fri, 10 Mar 2017 16:50:57 -0500 List-Id: "Development of GNU Guix and the GNU System distribution." 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" To: Andy Wingo , Ricardo Wurmus Cc: guix-devel --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Guix! I had it on my to-do list and Andy said he=E2=80=99d like to have something= like that to publish Guile 2.2 binaries: the =E2=80=98guix pack=E2=80=99 command= below is a generalization of the code that builds the Guix binary tarball=C2=B9. It creates a bundle of the closure of the given packages, with a profile containing all the packages. Examples: =2D-8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix pack guile-next /gnu/store/c2brwnrx0066lvf1d9hg82lvb1wkmd78-tarball.tar.lz $ ./pre-inst-env guix pack guile-next guix /gnu/store/kc6bxqwrf9z2vvxwndhw8s39s39h5mz6-tarball.tar.lz $ tar tvf /gnu/store/kc6bxqwrf9z2vvxwndhw8s39s39h5mz6-tarball.tar.lz|grep /= bin/gui[lx] =2Dr-xr-xr-x root/root 2974 1970-01-01 01:00 ./gnu/store/060piiiz4nmb5= 1jc3wk01bgikajrnfjd-guile-2.0.13/bin/guild =2Dr-xr-xr-x root/root 13472 1970-01-01 01:00 ./gnu/store/060piiiz4nmb5= 1jc3wk01bgikajrnfjd-guile-2.0.13/bin/guile =2Dr-xr-xr-x root/root 7008 1970-01-01 01:00 ./gnu/store/060piiiz4nmb5= 1jc3wk01bgikajrnfjd-guile-2.0.13/bin/guile-config =2Dr-xr-xr-x root/root 3050 1970-01-01 01:00 ./gnu/store/060piiiz4nmb5= 1jc3wk01bgikajrnfjd-guile-2.0.13/bin/guile-snarf lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/060piiiz4nmb51j= c3wk01bgikajrnfjd-guile-2.0.13/bin/guile-tools -> guild =2Dr-xr-xr-x root/root 2978 1970-01-01 01:00 ./gnu/store/62hqgi4cac0f7= 0v1ycsvv985fl3l1hzr-guile-next-2.1.7/bin/guild =2Dr-xr-xr-x root/root 12784 1970-01-01 01:00 ./gnu/store/62hqgi4cac0f7= 0v1ycsvv985fl3l1hzr-guile-next-2.1.7/bin/guile =2Dr-xr-xr-x root/root 7022 1970-01-01 01:00 ./gnu/store/62hqgi4cac0f7= 0v1ycsvv985fl3l1hzr-guile-next-2.1.7/bin/guile-config =2Dr-xr-xr-x root/root 3072 1970-01-01 01:00 ./gnu/store/62hqgi4cac0f7= 0v1ycsvv985fl3l1hzr-guile-next-2.1.7/bin/guile-snarf lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/62hqgi4cac0f70v= 1ycsvv985fl3l1hzr-guile-next-2.1.7/bin/guile-tools -> guild =2Dr-xr-xr-x root/root 744 1970-01-01 01:00 ./gnu/store/6xlybn33znrp4= nyvy39wbrwjrl8l9qnd-guix-0.12.0-5.1162/bin/guix =2Dr-xr-xr-x root/root 933120 1970-01-01 01:00 ./gnu/store/6xlybn33znrp4= nyvy39wbrwjrl8l9qnd-guix-0.12.0-5.1162/bin/guix-daemon lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/ynafk7v924xil99= 3dqbx4mxxnm9ifsi6-profile/bin/guild -> /gnu/store/62hqgi4cac0f70v1ycsvv985f= l3l1hzr-guile-next-2.1.7/bin/guild lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/ynafk7v924xil99= 3dqbx4mxxnm9ifsi6-profile/bin/guile -> /gnu/store/62hqgi4cac0f70v1ycsvv985f= l3l1hzr-guile-next-2.1.7/bin/guile lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/ynafk7v924xil99= 3dqbx4mxxnm9ifsi6-profile/bin/guile-config -> /gnu/store/62hqgi4cac0f70v1yc= svv985fl3l1hzr-guile-next-2.1.7/bin/guile-config lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/ynafk7v924xil99= 3dqbx4mxxnm9ifsi6-profile/bin/guile-snarf -> /gnu/store/62hqgi4cac0f70v1ycs= vv985fl3l1hzr-guile-next-2.1.7/bin/guile-snarf lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/ynafk7v924xil99= 3dqbx4mxxnm9ifsi6-profile/bin/guile-tools -> /gnu/store/62hqgi4cac0f70v1ycs= vv985fl3l1hzr-guile-next-2.1.7/bin/guile-tools lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/ynafk7v924xil99= 3dqbx4mxxnm9ifsi6-profile/bin/guix -> /gnu/store/6xlybn33znrp4nyvy39wbrwjrl= 8l9qnd-guix-0.12.0-5.1162/bin/guix lrwxrwxrwx root/root 0 1970-01-01 01:00 ./gnu/store/ynafk7v924xil99= 3dqbx4mxxnm9ifsi6-profile/bin/guix-daemon -> /gnu/store/6xlybn33znrp4nyvy39= wbrwjrl8l9qnd-guix-0.12.0-5.1162/bin/guix-daemon =2D-8<---------------cut here---------------end--------------->8--- Andy, does this correspond to what you have in mind? I=E2=80=99d like to move support for Docker (currently in =E2=80=98guix arc= hive=E2=80=99) to this new command because I think it=E2=80=99s more appropriate: =E2=80=98gu= ix archive=E2=80=99 is supposed to be rather low-level so it would not create a profile, for instance. Ricardo, WDYT? If there are no objections, I=E2=80=99d like to commit it soonish. Thanks! Ludo=E2=80=99. =C2=B9 https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/install.s= cm#n52 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline; filename=pack.scm Content-Transfer-Encoding: quoted-printable Content-Description: guix pack ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015, 2017 Ludovic Court=C3=A8s ;;; ;;; 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 . (define-module (guix scripts pack) #:use-module (guix scripts) #:use-module (guix ui) #:use-module (guix gexp) #:use-module (guix utils) #:use-module (guix store) #:use-module (guix grafts) #:use-module (guix monads) #:use-module (guix profiles) #:use-module (guix derivations) #:use-module (guix scripts build) #:use-module (gnu packages) #:autoload (gnu packages compression) (lzip) #:autoload (gnu packages base) (tar) #:autoload (gnu packages package-management) (guix) #:use-module (srfi srfi-1) #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:export (guix-pack)) (define* (self-contained-tarball name profile #:key deduplicate?) "Return a self-contained tarball containing a store initialized with the closure of PROFILE, a derivation. The tarball contains /gnu/store, /var/gu= ix, and PROFILE is available as /root/.guix-profile." (define build (with-imported-modules '((guix build utils) (guix build store-copy) (gnu build install)) #~(begin (use-modules (guix build utils) (gnu build install)) (define %root "root") ;; We need Guix here for 'guix-register'. (setenv "PATH" (string-append #$guix "/sbin:" #$tar "/bin:" #$lzip "/bin= ")) ;; Note: there is not much to gain here with deduplication and ;; there is the overhead of the '.links' directory, so turn it ;; off. (populate-single-profile-directory %root #:profile #$profile #:closure "profile" #:deduplicate? #f) ;; Create the tarball. Use GNU format so there's no file name ;; length limitation. (with-directory-excursion %root (zero? (system* "tar" "--lzip" "--format=3Dgnu" ;; Avoid non-determinism in the archive. Use ;; mtime =3D 1, not zero, because that is what = the ;; daemon does for files in the store (see the ;; 'mtimeStore' constant in local-store.cc.) "--sort=3Dname" "--mtime=3D@1" ;for files in /var/guix "--owner=3Droot:0" "--group=3Droot:0" "--check-links" "-cvf" #$output ;; Avoid adding / and /var to the tarball, so ;; that the ownership and permissions of those ;; directories will not be overwritten when ;; extracting the archive. Do not include /root ;; because the root account might have a ;; different home directory. "./var/guix" (string-append "." (%store-directory)))))))) (gexp->derivation name build #:references-graphs `(("profile" ,profile)))) ;;; ;;; Command-line options. ;;; (define %default-options ;; Alist of default option values. `((system . ,(%current-system)) (substitutes? . #t) (graft? . #t) (max-silent-time . 3600) (verbosity . 0))) (define %options ;; Specifications of the command-line options. (cons* (option '(#\h "help") #f #f (lambda args (show-help) (exit 0))) (option '(#\V "version") #f #f (lambda args (show-version-and-exit "guix pack"))) (option '(#\n "dry-run") #f #f (lambda (opt name arg result) (alist-cons 'dry-run? #t (alist-cons 'graft? #f result))= )) %standard-build-options)) (define (show-help) (display (_ "Usage: guix pack [OPTION]... PACKAGE... Create a bundle of PACKAGE.\n")) (show-build-options-help) (newline) (display (_ " -h, --help display this help and exit")) (display (_ " -V, --version display version information and exit")) (newline) (show-bug-report-information)) ;;; ;;; Entry point. ;;; (define (guix-pack . args) (define opts (parse-command-line args %options (list %default-options))) (with-error-handling (parameterize ((%graft? (assoc-ref opts 'graft?))) (let* ((dry-run? (assoc-ref opts 'dry-run?)) (specs (filter-map (match-lambda (('argument . name) name) (x #f)) opts)) (packages (map (lambda (spec) (call-with-values (lambda () (specification->package+output spec)) list)) specs))) (with-store store (run-with-store store (mlet* %store-monad ((profile (profile-derivation (packages->manifest packages))) (drv (self-contained-tarball "tarball.tar.= lz" profile))) (mbegin %store-monad (show-what-to-build* (list drv) #:use-substitutes? (assoc-ref opts 'substitutes?) #:dry-run? dry-run?) (munless dry-run? (built-derivations (list drv)) (return (format #t "~a~%" (derivation->output-path drv)))))))))))) --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEPORkVYqE/cadtAz7CQsRmT2a67UFAljDH7gACgkQCQsRmT2a 67X0SBAAr5NDpSdG0+zsTEH6v5gKFKnFwHwg+VfL+EnFkxZUO0UCbCwxmzMk2pQ5 yX9D64Zik/aGUFvqR848GSL8YPX+ijgYJ6LLyoK11gvcMayuIDeMGobwuJZ6TsEl q9i4wu44DR3H9J9eHCkBty0mit9U8niXo+BO1CEXjYk5xiuonLV9+I/q9cbQGVEy hyQ76T+tUIJpe3MlITCq5oKZSzx+CaZUlqRDnn/3Gpa36u7zZ+CL3RSOazaoSa3W 570ukmDb9hgwzsKcTOB65AoMJR+3wSpyAWcnvlqHjq3aG5HjnLu023Eo8Axqvlxm oWIDxj0U4gAP3FIUnLgjna+IbJhxYzeBuZXlNaydnnZzmgIDbokz4M/QstbV5p1p dKgKZHfAyTw7uLkMWkkglemMER3pIkYedu5hoBK+Tzg/U+uRtBO8VI3IJfhZknQv TA2B1o8QbVc/3owJBzoMjjZq4WuET0kNEiGk6gDvDVGC4J4weFKBi48fUp2i3qTt DaWAiHSFKq3XsuwTjT/P3aF9mqabiv1u+nU8Ejz7skjtLaxxT+x8KABvEgLyXc7U nnscHs0WBZwS1XaR+EAxcfSqmG7SH7epV2H3x2KD6nu4WGqV0QsaEaFp6Bl/Cs6/ wuafu9fvZ3Df+GZP3Dm4JiW6j3Lvb/Hy5RBlE5yqjka87+CJQ+s= =PKhS -----END PGP SIGNATURE----- --==-=-=--