- Add patch to set a sane default MANPATH

- Add createmodule.sh utility script for creating modulefiles
Mon Nov 30 2009 Orion Poplawski <orion@cora.nwra.com> - 3.2.7b-6
- Add Requires: propcs (bug #54272)
This commit is contained in:
Orion Poplawski 2010-01-08 15:36:11 +00:00
parent 51fc1ef6e1
commit 4ae869d157
3 changed files with 135 additions and 1 deletions

101
createmodule.sh Executable file
View File

@ -0,0 +1,101 @@
#!/bin/bash
#
# createmodule.sh - Takes the name of a environment init script and
# produces a modulefile that duplicates the changes made by the init script
#
# Copyright (C) 2010 by Orion E. Poplawski
#
# This program 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 2 of the License, or
# (at your option) any later version.
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
if [ -z "$1" ]
then
echo "usage: $0 <initscript> [args]" 1>&2
exit 1
fi
#Will print out array assignment list
printenvarray () {
env | while read x
do
key=${x%%=*}
value=${x#*=}
echo [$key]="'$value'"
done
}
#Apparently we need to declare the associative arrays
declare -A env1 env2
#Record starting environment
eval env1=(`printenvarray`)
#Source the environment script
. "$@"
#Record ending environment
eval env2=(`printenvarray`)
#Print out the modulefile
echo "#%Module 1.0"
#Keys that changed
for key in "${!env1[@]}"
do
if [ "${env1[$key]}" != "${env2[$key]}" ]
then
#Working directory change
if [ "$key" = PWD ]
then
echo -e "chdir\t\t${env2[PWD]}"
#Test for delete
elif [ -z "${env2[$key]}" ]
then
echo -e "unsetenv\t${key}\t${env2[$key]}"
#Test for prepend
elif [ "${env2[$key]%${env1[$key]}}" != "${env2[$key]}" ]
then
added="${env2[$key]%${env1[$key]}}"
echo -e "prepend-path\t$key\t${added%:}"
#Test for append
elif [ "${env2[$key]#${env1[$key]}}" != "${env2[$key]}" ]
then
added="${env2[$key]#${env1[$key]}}"
echo -e "append-path\t$key\t${added#:}"
else
#Unhandled
echo "Unhandled change of $key" 1>&2
echo "Before <${env1[$key]}>" 1>&2
echo "After <${env2[$key]}>" 1>&2
fi
fi
#Delete keys we've handled
unset env1[$key]
unset env2[$key]
done
#New keys
for key in "${!env2[@]}"
do
if [ "$key" = OLDPWD ]
then
continue
fi
#Use prepend-path for new paths
if [ "${key/PATH/}" != "$key" ]
then
echo -e "prepend-path\t${key}\t${env2[$key]}"
else
echo -e "setenv\t\t${key}\t${env2[$key]}"
fi
done

View File

@ -0,0 +1,23 @@
diff -up modules-3.2.7/cmdPath.c.manpath modules-3.2.7/cmdPath.c
--- modules-3.2.7/cmdPath.c.manpath 2009-07-30 12:03:20.000000000 -0600
+++ modules-3.2.7/cmdPath.c 2010-01-07 15:32:49.175198225 -0700
@@ -58,6 +58,10 @@ static void *UseId[] = { &UseId, Id };
#define PATH_BUFLEN 1024
#endif
+#ifndef MANPATH
+#define MANPATH "/usr/share/man"
+#endif
+
/** ************************************************************************ **/
/** MACROS **/
/** ************************************************************************ **/
@@ -215,7 +219,7 @@ int cmdSetPath( ClientData client_data,
_TCLCHK(interp)
if( oldpath == NULL)
- oldpath = !strcmp( argv[arg1], "MANPATH") ? "/usr/man" : "";
+ oldpath = !strcmp( argv[arg1], "MANPATH") ? MANPATH : "";
/**
** Split the new path into its components directories so each

View File

@ -1,6 +1,6 @@
Name: environment-modules Name: environment-modules
Version: 3.2.7b Version: 3.2.7b
Release: 6%{?dist} Release: 7%{?dist}
Summary: Provides dynamic modification of a user's environment Summary: Provides dynamic modification of a user's environment
Group: System Environment/Base Group: System Environment/Base
@ -8,10 +8,13 @@ License: GPLv2+
URL: http://modules.sourceforge.net/ URL: http://modules.sourceforge.net/
Source0: http://downloads.sourceforge.net/modules/modules-%{version}.tar.bz2 Source0: http://downloads.sourceforge.net/modules/modules-%{version}.tar.bz2
Source1: modules.sh Source1: modules.sh
Source2: createmodule.sh
Patch0: environment-modules-3.2.7-bindir.patch Patch0: environment-modules-3.2.7-bindir.patch
Patch1: environment-modules-3.2.7-manpath.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: tcl-devel, tclx-devel, libX11-devel BuildRequires: tcl-devel, tclx-devel, libX11-devel
BuildRequires: man
#For ps in startup script #For ps in startup script
Requires: procps Requires: procps
@ -43,9 +46,11 @@ have access to the module alias.
%prep %prep
%setup -q -n modules-3.2.7 %setup -q -n modules-3.2.7
%patch0 -p1 -b .bindir %patch0 -p1 -b .bindir
%patch1 -p1 -b .manpath
%build %build
export CPPFLAGS=-DMANPATH=\'\"`manpath`\"\'
%configure --disable-versioning \ %configure --disable-versioning \
--prefix=%{_datadir} \ --prefix=%{_datadir} \
--exec-prefix=%{_datadir}/Modules \ --exec-prefix=%{_datadir}/Modules \
@ -60,6 +65,7 @@ rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
cp -p %SOURCE1 $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/modules.sh cp -p %SOURCE1 $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/modules.sh
cp -p %SOURCE2 $RPM_BUILD_ROOT%{_datadir}/Modules/bin
ln -s %{_datadir}/Modules/init/csh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/modules.csh ln -s %{_datadir}/Modules/init/csh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/modules.csh
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/modulefiles mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/modulefiles
@ -80,6 +86,10 @@ rm -rf $RPM_BUILD_ROOT
%changelog %changelog
* Thu Jan 7 2010 Orion Poplawski <orion@cora.nwra.com> - 3.2.7b-7
- Add patch to set a sane default MANPATH
- Add createmodule.sh utility script for creating modulefiles
* Mon Nov 30 2009 Orion Poplawski <orion@cora.nwra.com> - 3.2.7b-6 * Mon Nov 30 2009 Orion Poplawski <orion@cora.nwra.com> - 3.2.7b-6
- Add Requires: propcs (bug #54272) - Add Requires: propcs (bug #54272)