From fac83351ddfbce79caebd0c471310e112781bfdc Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Mon, 1 Aug 2011 09:48:52 -0700
Subject: [PATCH] Set paths in srun wrapper for cray aprun command

Set the absolute pathnames for the salloc and srun commands in the
srun wrapper for the aprun command (used only on Cray systems).
Fix for bug 774375.
---
 contribs/cray/Makefile.am |  4 ++--
 contribs/cray/Makefile.in |  4 ++--
 contribs/cray/srun.pl     |  4 ++--
 doc/html/cray.shtml       | 12 +++++++-----
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/contribs/cray/Makefile.am b/contribs/cray/Makefile.am
index 8b105967d22..9176ff93559 100644
--- a/contribs/cray/Makefile.am
+++ b/contribs/cray/Makefile.am
@@ -24,8 +24,8 @@ install-binSCRIPTS: $(bin_SCRIPTS)
 	@$(NORMAL_INSTALL)
 	test -z "$(DESTDIR)$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
 	@list='$(bin_SCRIPTS)'; for p in $$list; do \
-	   echo "sed 's%use lib .*%use lib qw(${_perldir});%' $(top_srcdir)/contribs/cray/$$p.pl > $(DESTDIR)$(bindir)/$$p"; \
-	   sed "s%use lib .*%use lib qw(${_perldir});%" $(top_srcdir)/contribs/cray/$$p.pl >$(DESTDIR)$(bindir)/$$p; \
+	   echo "sed 's%use lib .*%use lib qw(${_perldir});%' $(top_srcdir)/contribs/cray/$$p.pl | sed 's%BINDIR%@bindir@%' > $(DESTDIR)$(bindir)/$$p"; \
+	         sed "s%use lib .*%use lib qw(${_perldir});%" $(top_srcdir)/contribs/cray/$$p.pl | sed "s%BINDIR%@bindir@%" > $(DESTDIR)$(bindir)/$$p; \
 	   chmod 755 $(DESTDIR)$(bindir)/$$p;\
 	done
 
diff --git a/contribs/cray/Makefile.in b/contribs/cray/Makefile.in
index 18e4ca0dacc..73102d3a997 100644
--- a/contribs/cray/Makefile.in
+++ b/contribs/cray/Makefile.in
@@ -513,8 +513,8 @@ install-binSCRIPTS: $(bin_SCRIPTS)
 	@$(NORMAL_INSTALL)
 	test -z "$(DESTDIR)$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
 	@list='$(bin_SCRIPTS)'; for p in $$list; do \
-	   echo "sed 's%use lib .*%use lib qw(${_perldir});%' $(top_srcdir)/contribs/cray/$$p.pl > $(DESTDIR)$(bindir)/$$p"; \
-	   sed "s%use lib .*%use lib qw(${_perldir});%" $(top_srcdir)/contribs/cray/$$p.pl >$(DESTDIR)$(bindir)/$$p; \
+	   echo "sed 's%use lib .*%use lib qw(${_perldir});%' $(top_srcdir)/contribs/cray/$$p.pl | sed 's%BINDIR%@bindir@%' > $(DESTDIR)$(bindir)/$$p"; \
+	         sed "s%use lib .*%use lib qw(${_perldir});%" $(top_srcdir)/contribs/cray/$$p.pl | sed "s%BINDIR%@bindir@%" > $(DESTDIR)$(bindir)/$$p; \
 	   chmod 755 $(DESTDIR)$(bindir)/$$p;\
 	done
 
diff --git a/contribs/cray/srun.pl b/contribs/cray/srun.pl
index b34226cc6a8..582e925b7f3 100755
--- a/contribs/cray/srun.pl
+++ b/contribs/cray/srun.pl
@@ -142,8 +142,8 @@ my (	$account,
 );
 
 my $aprun  = "aprun";
-my $salloc = "salloc";
-my $srun   = "srun";
+my $salloc = "BINDIR/salloc";
+my $srun   = "BINDIR/srun";
 
 my $have_job;
 $aprun_line_buf = 1;
diff --git a/doc/html/cray.shtml b/doc/html/cray.shtml
index b538747c55b..b10b5515e29 100644
--- a/doc/html/cray.shtml
+++ b/doc/html/cray.shtml
@@ -613,10 +613,12 @@ login: # /etc/init.d/slurm start
 
 <h3>Srun wrapper configuration</h3>
 
-<p>The <i>srun</i> wrapper to <i>aprun</i> may require modification to run
-at each site. Explicitly setting the <i>$aprun</i>, <i>$salloc</i> and
-<i>$srun</i> variables to the absolute pathnames of those executable files
-is recommended. In order to debug <i>srun</i>, uncomment the line</p>
+<p>The <i>srun</i> wrapper to <i>aprun</i> might require modification to run
+as desired. Specifically the <i>$aprun</i> variable could be set to the
+absolute pathname of that executable file. Without that modification, the
+<i>aprun</i> command executed will depend upon the user's search path.</p>
+
+<p>In order to debug the <i>srun</i> wrapper, uncomment the line</p>
 <pre>
 print "comment=$command\n"
 </pre>
@@ -631,6 +633,6 @@ allocation.</p>
 
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 28 July 2011</p></td>
+<p style="text-align:center;">Last modified 1 August 2011</p></td>
 
 <!--#include virtual="footer.txt"-->
-- 
GitLab