Nikita Karetnikov <nik...@karetnikov.org> skribis: > Is there a way to compose the following part somehow to prevent a > possible race condition? > > (rename-file prog prog-real) > > (with-output-to-file prog (lambda () > (format #t > "#!~a~%~a~%exec ~a~%" > (which "bash") > (string-join (map export-variable > vars) > "\n") > (canonicalize-path prog-real)))) > (chmod prog #o755)))
If you’re really concerned, you could do (pseudocode): cp prog prog-real echo wrapper code > prog.tmp chmod +x prog.tmp rename prog.tmp prog I wouldn’t bother, though, because it will be used in contexts where there’s no risk of ‘prog’ being used while we’re fiddling with it (single-threaded, after ‘make install’). > From 6bd8c169c320ffe9dd13a85a6f63a60b8508bc3c Mon Sep 17 00:00:00 2001 > From: Nikita Karetnikov <nik...@karetnikov.org> > Date: Sat, 2 Mar 2013 20:08:39 +0000 > Subject: [PATCH] utils: Add 'wrap-program'. > > * guix/build/utils.scm (wrap-program): New procedure. > --- > guix/build/utils.scm | 40 +++++++++++++++++++++++++++++++++++++++- > 1 files changed, 39 insertions(+), 1 deletions(-) Looks good to me. > +(define* (wrap-program prog #:rest vars) > + "Rename PROG to .PROG-real and make PROG a wrapper." Can you just expound the docstring before pushing? Thanks! Ludo’.