all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nikita Karetnikov <nikita@karetnikov.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: bug-guix@gnu.org
Subject: Re: Toward 0.2
Date: Thu, 28 Feb 2013 15:53:12 -0500	[thread overview]
Message-ID: <87ehg0rwfd.fsf@karetnikov.org> (raw)
In-Reply-To: <87wqtu3n0z.fsf@gnu.org> ("Ludovic Courtès"'s message of "(unknown date)")


[-- Attachment #1.1: Type: text/plain, Size: 824 bytes --]

> Remember that (guix build ...) modules must not use Guix modules other
> than (guix build ...).  This is a convention to distinguish between code
> for the “builder stratum”, and code for the “host stratum”.

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=$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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-utils-Add-wrap-program.patch --]
[-- Type: text/x-diff, Size: 2491 bytes --]

From 0c84fdb879c78a129c9d77bcdf9a5e3135825ad9 Mon Sep 17 00:00:00 2001
From: Nikita Karetnikov <nikita@karetnikov.org>
Date: Thu, 28 Feb 2013 20:27:36 +0000
Subject: [PATCH] utils: Add 'wrap-program'.

* guix/build/utils.scm (wrap-program): New procedure.
---
 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
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -49,7 +49,8 @@
             patch-shebang
             patch-makefile-SHELL
             fold-port-matches
-            remove-store-references))
+            remove-store-references
+            wrap-program))
 
 \f
 ;;;
@@ -605,6 +606,44 @@ known as `nuke-refs' in Nixpkgs."
                              (put-u8 out (char->integer char))
                              result))))))
 
+(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 '= rest)
+            (format #f "export ~a=\"~a\""
+                    var (separate rest sep)))
+
+           ((var sep 'prefix rest)
+            (format #f "export ~a=\"~a~a${~a~a+~a}$~a\""
+                    var (separate rest sep) sep var sep sep var))
+
+           ((var sep 'suffix rest)
+            (format #f "export ~a=\"$~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)
-- 
1.7.5.4


[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

  reply	other threads:[~2013-02-28 20:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-17 15:10 Toward 0.2 Ludovic Courtès
2013-02-18  1:58 ` Nikita Karetnikov
2013-02-18 10:26   ` Ludovic Courtès
2013-02-20  0:39     ` Nikita Karetnikov
2013-02-20 11:28       ` Ludovic Courtès
2013-02-21 17:36         ` Nikita Karetnikov
2013-02-22 14:31           ` Ludovic Courtès
2013-02-26 10:43             ` Nikita Karetnikov
2013-02-26 16:51               ` Mark H Weaver
2013-02-26 19:14               ` Ludovic Courtès
2013-02-28 20:53                 ` Nikita Karetnikov [this message]
2013-03-01  9:15                   ` Ludovic Courtès
2013-03-01 15:01                     ` Nikita Karetnikov
2013-03-01 17:28                       ` Ludovic Courtès
2013-03-02 20:17                         ` Nikita Karetnikov
2013-03-02 21:30                           ` Ludovic Courtès
2013-03-03 12:52                             ` [PATCH] utils: Add 'wrap-program'. (was: Toward 0.2) Nikita Karetnikov
2013-03-03 21:29                               ` [PATCH] utils: Add 'wrap-program' Ludovic Courtès
2013-03-03 23:11                                 ` Nikita Karetnikov
2013-03-04 10:08                                   ` Ludovic Courtès
2013-02-20  9:00 ` Toward 0.2 Andreas Enge
2013-04-15 21:59 ` Ludovic Courtès
2013-04-29 21:32   ` Ludovic Courtès
2013-05-11 20:41   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ehg0rwfd.fsf@karetnikov.org \
    --to=nikita@karetnikov.org \
    --cc=bug-guix@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.