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: Tue, 26 Feb 2013 05:43:31 -0500	[thread overview]
Message-ID: <87hakzwdzu.fsf@karetnikov.org> (raw)
In-Reply-To: <874nh4ju7b.fsf@gnu.org> ("Ludovic Courtès"'s message of "(unknown date)")


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

I'm attaching a patch.

It's a separate file; if I add these lines

   #:use-module (guix packages)
   #:use-module (guix store)

to 'guix/build/utils.scm', they will raise the following error on
'make'.

Backtrace:
In ice-9/eval.scm:
 400: 19 [eval # ()]
In ice-9/boot-9.scm:
2681: 18 [define-module* (guix utils) #:filename ...]
2656: 17 [resolve-imports (((guix config)) ((guix packages)) ((guix store)) ...)]
2594: 16 [resolve-interface (guix packages) #:select ...]
2519: 15 [#<procedure 8fee7a0 at ice-9/boot-9.scm:2507:4 (name #:optional autoload version #:key ensure)> # ...]
2786: 14 [try-module-autoload (guix packages) #f]
2131: 13 [save-module-excursion #<procedure 92a4eb8 at ice-9/boot-9.scm:2787:17 ()>]
2797: 12 [#<procedure 92a4eb8 at ice-9/boot-9.scm:2787:17 ()>]
In unknown file:
   ?: 11 [primitive-load-path "guix/packages" #f]
In guix/packages.scm:
  19: 10 [#<procedure 92cece0 ()>]
In ice-9/boot-9.scm:
2681: 9 [define-module* (guix packages) #:filename ...]
2656: 8 [resolve-imports (((guix utils)) ((guix store)) ((guix base32)) ...)]
2594: 7 [resolve-interface (guix derivations) #:select ...]
2519: 6 [#<procedure 8fee7a0 at ice-9/boot-9.scm:2507:4 (name #:optional autoload version #:key ensure)> # ...]
2786: 5 [try-module-autoload (guix derivations) #f]
2131: 4 [save-module-excursion #<procedure 93f87c8 at ice-9/boot-9.scm:2787:17 ()>]
2797: 3 [#<procedure 93f87c8 at ice-9/boot-9.scm:2787:17 ()>]
In unknown file:
   ?: 2 [primitive-load-path "guix/derivations" #f]
In guix/derivations.scm:
 317: 1 [#<procedure 9439920 ()>]
In ice-9/boot-9.scm:
 106: 0 [#<procedure 913a8c0 at ice-9/boot-9.scm:97:6 (thrown-k . args)> unbound-variable ...]

ice-9/boot-9.scm:106:20: In procedure #<procedure 913a8c0 at ice-9/boot-9.scm:97:6 (thrown-k . args)>:
ice-9/boot-9.scm:106:20: In procedure module-lookup: Unbound variable: memoize
make[2]: *** [guix/utils.go] Error 1
make[2]: Leaving directory `/home/guix-savannah'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/guix-savannah'
make: *** [all] Error 2

I don't think that 'store-location' is really needed.  I added it
because I hadn't found a procedure that can return something like
'/nix/store/*-wget-1.14/bin/wget'.

Also, 'bin-location' and 'chmod' are not safe.  It can be solved with
'file-exists?', but I decided not to use it because I want to rewrite
the whole thing.  Any suggestions?

Example:

scheme@(guile-user)> ,use (gnu packages wget) (gnu packages gawk)
scheme@(guile-user)> ,use (wrap-program)
scheme@(guile-user)> (wrap-program wget #t "PATH" (store-location gawk "out" "/bin"))

#!/bin/sh
export PATH="/nix/store/l5gkkxbjrlhddpxyxl6glhyczvh0gggw-gawk-4.0.0/bin:$PATH"
exec ./.wget-real "$@"


[-- Attachment #1.2: wrap-program.scm --]
[-- Type: text/plain, Size: 2122 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;;
;;; 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 <http://www.gnu.org/licenses/>.

(define-module (wrap-program)
  #:use-module (guix packages)
  #:use-module (guix store)
  #:use-module (srfi srfi-26)
  #:export (store-location
            wrap-program))

(define (store-location package output rest)
  "Return a PACKAGE-related location."
  (string-append (package-output (open-connection) package output)
                 rest))

(define (wrap-program program prefix? variable var-dir)
  "Copy PROGRAM to .PROGRAM-real and make PROGRAM a wrapper."
  (let* ((bin-location (store-location program "out"
                                       (string-append "/bin"))) ; not safe
         (program-name (package-name program))
         (old (string-append bin-location "/" program-name))
         (new (string-append bin-location "/." program-name "-real"))
         (tmp (string-append bin-location "/." program-name "-tmp")))

    (define (change-variable)
      ;; Prepend VAR-DIR to VARIABLE or return VAR-DIR.
      (if prefix?
          (string-append var-dir ":$" variable)
          var-dir))

    (copy-file old new)

    (call-with-output-file
        tmp
      (cut format <> "#!/bin/sh~%export ~a=\"~a\"~%exec ./~a \"$@\"~%"
           variable (change-variable) (basename new)))

    (chmod tmp #o755)
    (rename-file tmp old)))

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

  reply	other threads:[~2013-02-26 11:43 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 [this message]
2013-02-26 16:51               ` Mark H Weaver
2013-02-26 19:14               ` Ludovic Courtès
2013-02-28 20:53                 ` Nikita Karetnikov
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=87hakzwdzu.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.