From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Karetnikov Subject: Re: Toward 0.2 Date: Thu, 28 Feb 2013 15:53:12 -0500 Message-ID: <87ehg0rwfd.fsf@karetnikov.org> References: <877gm7f01v.fsf@gnu.org> <87obfigz7g.fsf@karetnikov.org> <87y5el6hph.fsf@gnu.org> <87fw0rom1n.fsf@karetnikov.org> <87ehgbql5w.fsf@gnu.org> <87hal5ftyu.fsf@karetnikov.org> <874nh4ju7b.fsf@gnu.org> <87hakzwdzu.fsf@karetnikov.org> <87wqtu3n0z.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBATY-0006PV-Qk for bug-guix@gnu.org; Thu, 28 Feb 2013 15:53:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBATW-0000vB-6O for bug-guix@gnu.org; Thu, 28 Feb 2013 15:53:12 -0500 In-Reply-To: <87wqtu3n0z.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "(unknown date)") 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-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: bug-guix@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > Remember that (guix build ...) modules must not use Guix modules other > than (guix build ...). This is a convention to distinguish between code > for the =E2=80=9Cbuilder stratum=E2=80=9D, and code for the =E2=80=9Chost= stratum=E2=80=9D. OK. But how can I get the location of a package? The needed procedure (i.e., 'package-output') is in the host code. > (define* (wrap-program file #:rest variables) > ...) Why do you want to use '#:rest' here? The purpose of 'wrap-program' is to export some variables. > export CERT_PATH=3D$CERT_PATH${CERT_PATH:+:}:/nix/.../share/certs Could you explain the "$CERT_PATH${CERT_PATH:+:}" part? > Perhaps the separator string could be optional. Is it possible to make it optional without creating a separate clause? I'm attaching a patch. It lacks the 'rename-file' part. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-utils-Add-wrap-program.patch Content-Transfer-Encoding: quoted-printable From=200c84fdb879c78a129c9d77bcdf9a5e3135825ad9 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Thu, 28 Feb 2013 20:27:36 +0000 Subject: [PATCH] utils: Add 'wrap-program'. * guix/build/utils.scm (wrap-program): New procedure. =2D-- guix/build/utils.scm | 41 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 6921e31..63012f0 100644 =2D-- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -49,7 +49,8 @@ patch-shebang patch-makefile-SHELL fold-port-matches =2D remove-store-references)) + remove-store-references + wrap-program)) =20 ;;; @@ -605,6 +606,44 @@ known as `nuke-refs' in Nixpkgs." (put-u8 out (char->integer char)) result)))))) =20 +(define (wrap-program prog varlst) + "Copy PROG to .PROG-real and make PROG a wrapper." + (define (export-envvar lst) + ;; Return a string that exports an environment variable. + (define (separate lst delim) + ;; Return a string of directories separated by DELIM. + (fold-right (lambda (x acc) + (if (string-null? acc) + x + (string-append x delim acc))) + "" + lst)) + + ;; TODO: Make SEP optional. + (match lst + ((var sep '=3D rest) + (format #f "export ~a=3D\"~a\"" + var (separate rest sep))) + + ((var sep 'prefix rest) + (format #f "export ~a=3D\"~a~a${~a~a+~a}$~a\"" + var (separate rest sep) sep var sep sep var)) + + ((var sep 'suffix rest) + (format #f "export ~a=3D\"$~a${~a~a+~a}~a~a\"" + var var var sep sep sep (separate rest sep))))) + + ;; XXX: Use an absolute filename; remove '-real'. + (format #f "#!~a~%~aexec ./.~a-real~%" + (which "bash") + + (fold-right (lambda (x acc) + (string-append x "\n" acc)) + "" + (map export-envvar varlst)) + + prog)) ; XXX: use a real program instead + ;;; Local Variables: ;;; eval: (put 'call-with-output-file/atomic 'scheme-indent-function 1) ;;; eval: (put 'with-throw-handler 'scheme-indent-function 1) =2D-=20 1.7.5.4 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJRL8QaAAoJEM+IQzI9IQ38wNcP/1qiCDpGLQbUD5CvfdgvoePK WBSjVlP3BxUzysW5JIFLRbGsjmHs0j1Ev8CRvDfY9gcJ5yiPFi42IUZBX4ZDzp5B /9bH2u7FtewQdbyM2YSJi536UIA9BNh8CisDLfdcCdleE5i960lIq2QKYNa48njr F3dSJliVsBFWCaWyqg5XLIb9MiuhVucAo5tnN6BanyrovRJJo6FGSpdXjZqW9+BK auCoTBs5frAQmskv4ygKimxEpHJJ1QYbXDUAdayxOrjfEkkonXUO6dU5df/FRQP2 JlJlVjhL13sDWkMkMZohGh6sgiyZ4Q/Ie/b17cm4GeRGIlIklbbHLijFLkfX3rE+ lWnpGi3gYv1Jk4RcriM6/5GTWp0NzndoOODBeXX5qeZJqiaIlPnVCn95oQq0/wfC xh4ph2SFZnGOZDD0v001xRNcSjXPI1EKrBsgQuynXoG/KLMPdSaPUYyRVX0FRQPK fD1iJyopj377qjS69sJkTbMjzfmRk6qm+xiLsJsoVTNZF4RvLGisHE3JcPn5Z6M6 ZSmGQ2magn3kz6OtP+34rmoIXA4mVs/WsGvpeq/eEH2KHH3hWpj6pVocSPmIlpn6 CIdfe18Pz5D7HCsa+kMjLzLUSkdO274Ucc8p3cHMI+WOsXrCSsYtLv56Qufx2ndj lQ95wgkFzRDTEsb+uwEg =JIyU -----END PGP SIGNATURE----- --==-=-=--