[OMPI users] problems with profile.d scripts generated using openmpi.spec

2007-04-03 Thread Marcin Dulak

Hi,

I found that the /etc/profile.d/openmpi-1.2.sh and 
/etc/profile.d/openmpi-1.2.csh generated using openmpi.spec are incorrect.
The contents of the generated (see the details of the generation process 
at the very end of my email) scripts is the following:

---
/etc/profile.d/openmpi-1.2.sh
---
# NOTE: This is an automatically-generated file!  (generated by the
# Open MPI RPM).  Any changes made here will be lost a) if the RPM is
# uninstalled, or b) if the RPM is upgraded or uninstalled.

CHANGED=0
if test -z ""; then
   PATH=${PATH}:/opt/openmpi/1.2/bin/
   CHANGED=1
fi
if test -z ""; then
   LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/openmpi/1.2/lib
   CHANGED=1
fi
if test -z ""; then
   MANPATH=${MANPATH}:/opt/openmpi/1.2/man
   CHANGED=1
fi
if test "" = "1"; then
   export PATH LD_LIBRARY_PATH MANPATH
fi
---
/etc/profile.d/openmpi-1.2.csh
---
# NOTE: This is an automatically-generated file!  (generated by the
# Open MPI RPM).  Any changes made here will be lost a) if the RPM is
# uninstalled, or b) if the RPM is upgraded or uninstalled.

if ("") then
   setenv PATH ${PATH}:/opt/openmpi/1.2/bin/
endif
if ("1LD_LIBRARY_PATH") then
   if ("") then
   setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/opt/openmpi/1.2/lib
   endif
endif
if ("1MANPATH") then
   if ("") then
   setenv MANPATH ${MANPATH}:/opt/openmpi/1.2/man
   endif
endif
---
The sh one is incorrect in the line
if test "" = "1"; then
which should be
if test "$CHANGED" = "1"; then

The csh one is incorrect in several places,
like 1LD_LIBRARY_PATH (comming from the missing backslash in openmpi.spec),
and the whole logic of csh seems to be incorrect as well (e.g. nothing 
happens if LD_LIBRARY_PATH

is not set in the shell running the rpmbuild process!).
By the way, the dependence of the openmpi.spec file of the current 
contents of the PATH etc. variables
is risky (when compiling, installing and uninstalling openmpi rpm 
several times)
and I think that the user should be warned in some way by the script to 
remove traces

of openmpi related variables from the shell running rpmbuild.

I attach a patch to the original 1.2 openmpi.spec file, which should fix 
these problems.

I find the possibility of installation of openmpi to /opt/ very useful
and I hope that my comments help to improve it.

Marcin



Details of the rpm generation process:
I created the rpm of openmpi-1.2 using the provided buildrpm.sh and 
openmpi.spec files

(I use:
RPM version 4.3.3,
GNU bash, version 3.00.15(1)-release (i686-redhat-linux-gnu)).
Here are my settings from buildrpm.sh script:

specfile="openmpi.spec"
rpmbuild_options="--define 'mflags -j4'"
configure_options="--with-tm=/usr/local FC=pgf90 F77=pgf90 CC=pgcc 
CXX=pgCC CFLAGS=-Msignextend CXXFLAGS=-Msignextend 
--with-wrapper-cflags=-Msignextend --with-wrapper-cxxflags=-Msignextend 
FFLAGS=-Msignextend FCFLAGS=-Msignextend 
--with-wrapper-fflags=-Msignextend --with-wrapper-fcflags=-Msignextend"
rpmbuild_options=${rpmbuild_options}" --define 'install_in_opt 1' 
--define 'install_profile_d_scripts 1' --define 'install_modulefile 0'"





Re: [OMPI users] problems with profile.d scripts generated using openmpi.spec

2007-04-04 Thread Marcin Dulak

Thank you for the links.
I tried the  Revision 14205 
 of  openmpi.spec 
and it works for me only after some changes:

- in the mpivars-1.2.csh script part,
- and related to the line 330 in the original (14205 
) openmpi.spec:


eval "set %{configure_options}"

which will fail, if configure_options starts with --, in which case it 
will be interpreted as an option to set.

I attach the patch file.

Marcin
--- openmpi.spec	2007-04-04 09:34:12.397722000 +0200
+++ openmpi-fixed.spec	2007-04-04 10:25:26.648442000 +0200
@@ -327,7 +327,8 @@

 if test "$using_gcc" = "1"; then
 # Do wretched things to find a CC=* token
-eval "set %{configure_options}"
+# Remove starting --*, as it is interpreted as an option to set
+eval "set `echo %{configure_options} | sed 's/--*//'`"
 compiler=
 while test "$1" != "" -a "$compiler" = ""; do
  case "$1" in
@@ -449,7 +450,7 @@

 # LD_LIBRARY_PATH
 if ("1" == "\$?LD_LIBRARY_PATH") then
-if ("\$LD_LIBRARY_PATH" =~ "'*%{_libdir}*'") then
+if ("\$LD_LIBRARY_PATH" !~ *%{_libdir}*) then
 setenv LD_LIBRARY_PATH %{_libdir}:\${LD_LIBRARY_PATH}
 endif
 else
@@ -458,11 +459,11 @@

 # MANPATH
 if ("1" == "\$?MANPATH") then
-if ("\$MANPATH" =~ '*%{_mandir}*'") then
+if ("\$MANPATH" !~ *%{_mandir}*) then
 setenv MANPATH %{_mandir}:\${MANPATH}
 endif
 else
-setenv MANPATH %{_mandir}:
+setenv MANPATH %{_mandir}
 endif
 EOF
 %endif


Re: [OMPI users] problems with profile.d scripts generated using openmpi.spec

2007-04-04 Thread Marcin Dulak

Thank your for comments.
1) I'am using
GNU bash, version 3.00.15(1)-release (i686-redhat-linux-gnu)
To see the problem with the original

eval "set %{configure_options}"

I start the configure_options with -- in buildrpm.sh, like this:

configure_options="--with-tm=/usr/local FC=pgf90 F77=pgf90 CC=pgcc CXX=pgCC 
CFLAGS=-Msignextend CXXFLAGS=-Msignextend --with-wrapper-cflags=-Msignextend 
--with-wrapper-cxxflags=-Msignextend FFLAGS=-Msignextend FCFLAGS=-Msignextend 
--with-wrapper-fflags=-Msignextend --with-wrapper-fcflags=-Msignextend"

Or to see the problem directly, I go to the shell:
sh; set --w
sh: set: --: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]

2)
if ("\$LD_LIBRARY_PATH" !~ *%{_libdir}*) then
is the only possibility which works for me.

I'am using
tcsh 6.13.00 (Astron) 2004-05-19 (i386-intel-linux) options 
8b,nls,dl,al,kan,rh,color,dspm,filec

If I use "%{_libdir}", then every time I
source /opt/openmpi/1.2/bin/mpivars-1.2.csh
a new entry of opemnpi is prepended, so the LD_LIBRARY_PATH is growing.
The same if I use  
"*%{_libdir}*"

it seems that with the double quotes the shell despite the pattern comparison 
requested by !~ uses literal matching.

3) 


using

setenv MANPATH %{_mandir}:

(with the colon (:) included), if I start from empty MANPATH

unsetenv MANPATH

and run

source /opt/openmpi/1.2/bin/mpivars-1.2.csh

I get
echo $MANPATH

/opt/openmpi/1.2/man:

I tried to google for something like

also include the default MANPATH

but I cannot find anything. What is the meaning of this colon at the end?

Marcin

Jeff Squyres wrote:

On Apr 4, 2007, at 4:50 AM, Marcin Dulak wrote:

  

Thank you for the links.
I tried the  Revision 14205 of  openmpi.spec and it works for me  
only after some changes:

- in the mpivars-1.2.csh script part,
- and related to the line 330 in the original (14205) openmpi.spec:

eval "set %{configure_options}"

which will fail, if configure_options starts with --, in which case  
it will be interpreted as an option to set.



Hmm.  I did not have this problem.  What version of shell are you using?

I can apply this change because it's harmless, but I'm curious as to  
why I did not see the same problem.


See below for more comments.

  

--- openmpi.spec2007-04-04 09:34:12.397722000 +0200
+++ openmpi-fixed.spec  2007-04-04 10:25:26.648442000 +0200
@@ -327,7 +327,8 @@

 if test "$using_gcc" = "1"; then
 # Do wretched things to find a CC=* token
-eval "set %{configure_options}"
+# Remove starting --*, as it is interpreted as an option to set
+eval "set `echo %{configure_options} | sed 's/--*//'`"



See comment above.

  

 compiler=
 while test "$1" != "" -a "$compiler" = ""; do
  case "$1" in
@@ -449,7 +450,7 @@

 # LD_LIBRARY_PATH
 if ("1" == "\$?LD_LIBRARY_PATH") then
-if ("\$LD_LIBRARY_PATH" =~ "'*%{_libdir}*'") then
+if ("\$LD_LIBRARY_PATH" !~ *%{_libdir}*) then
 setenv LD_LIBRARY_PATH %{_libdir}:\${LD_LIBRARY_PATH}
 endif
 else
@@ -458,11 +459,11 @@

 # MANPATH
 if ("1" == "\$?MANPATH") then
-if ("\$MANPATH" =~ '*%{_mandir}*'") then
+if ("\$MANPATH" !~ *%{_mandir}*) then



Fixed the above 2 typos, although the *'s should also disappear and  
the double quotes should remain (the %{_mandir} one was actually  
broken).


  

 setenv MANPATH %{_mandir}:\${MANPATH}
 endif
 else
-setenv MANPATH %{_mandir}:
+setenv MANPATH %{_mandir}



The : at the end of the string is intentional.  Its presence means  
"also include the default MANPATH".