From 7584f822bf076f4fc8aef9c1f4d48c179fe15fc3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 5 Jan 2013 16:02:32 +0100 Subject: utils: Add `which'. * guix/build/utils.scm (which): New procedure. * distro/packages/lsh.scm (lsh): Use `which' instead of `search-path'. * distro/packages/perl.scm (perl): Likewise. * distro/packages/attr.scm (attr): Likewise. --- distro/packages/attr.scm | 9 +++------ distro/packages/lsh.scm | 5 ++--- distro/packages/perl.scm | 10 ++++------ guix/build/utils.scm | 8 ++++++++ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/distro/packages/attr.scm b/distro/packages/attr.scm index ad2cd3987a..c61f4d7031 100644 --- a/distro/packages/attr.scm +++ b/distro/packages/attr.scm @@ -56,12 +56,9 @@ (define-public attr 'check (lambda _ ;; Use the right shell. - (let ((bash (search-path (search-path-as-string->list - (getenv "PATH")) - "bash"))) - (substitute* "test/run" - (("/bin/sh") - (string-append bash "/bin/bash")))) + (substitute* "test/run" + (("/bin/sh") + (which "bash"))) (system* "make" "tests" "-C" "test") diff --git a/distro/packages/lsh.scm b/distro/packages/lsh.scm index aa74c77b60..8f44967726 100644 --- a/distro/packages/lsh.scm +++ b/distro/packages/lsh.scm @@ -1,5 +1,5 @@ ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- -;;; Copyright (C) 2012 Ludovic Courtès +;;; Copyright (C) 2012, 2013 Ludovic Courtès ;;; ;;; This file is part of Guix. ;;; @@ -114,8 +114,7 @@ (define-public lsh (substitute* "src/testsuite/login-auth-test" (("/bin/cat") ;; Use the right path to `cat'. - (search-path (search-path-as-string->list (getenv "PATH")) - "cat")))) + (which "cat")))) %standard-phases))) (home-page "http://www.lysator.liu.se/~nisse/lsh/") (synopsis diff --git a/distro/packages/perl.scm b/distro/packages/perl.scm index 26b25b154d..c4bfb6b260 100644 --- a/distro/packages/perl.scm +++ b/distro/packages/perl.scm @@ -1,5 +1,5 @@ ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- -;;; Copyright (C) 2012 Ludovic Courtès +;;; Copyright (C) 2012, 2013 Ludovic Courtès ;;; ;;; This file is part of Guix. ;;; @@ -46,13 +46,11 @@ (define-public perl 'configure (lambda* (#:key inputs outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out")) - (libc (assoc-ref inputs "libc")) - (pwd (search-path (search-path-as-string->list - (getenv "PATH")) - "pwd"))) + (libc (assoc-ref inputs "libc"))) ;; Use the right path for `pwd'. (substitute* "dist/Cwd/Cwd.pm" - (("/bin/pwd") pwd)) + (("/bin/pwd") + (which "pwd"))) (zero? (system* "./Configure" diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 5729cdbf04..f365b0db05 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -36,6 +36,8 @@ (define-module (guix build utils) set-path-environment-variable search-path-as-string->list list->search-path-as-string + which + alist-cons-before alist-cons-after alist-replace @@ -214,6 +216,12 @@ (define* (set-path-environment-variable env-var sub-directories input-dirs (format #t "environment variable `~a' set to `~a'~%" env-var value))) +(define (which program) + "Return the complete file name for PROGRAM as found in $PATH, or #f if +PROGRAM could not be found." + (search-path (search-path-as-string->list (getenv "PATH")) + program)) + ;;; ;;; Phases. -- cgit v1.2.3