Add patch for python 3 support, use python3 for createmodule.py on F22

This commit is contained in:
Orion Poplawski 2015-01-28 13:07:56 -07:00
parent c5ce4a52cb
commit 6dacb3a2a8
2 changed files with 34 additions and 21 deletions

View File

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from optparse import OptionParser
import os,sys,re
@ -41,13 +42,13 @@ def getenv(cmd = ':'):
p = Popen(cmd + ";env", shell=True, stdout=PIPE, stderr=PIPE)
(stdout, stderr) = p.communicate()
if p.returncode != 0:
print "EROR: Could not execute initscript:"
print "%s returned exit code %d" % (cmd, p.returncode)
print stderr
print("EROR: Could not execute initscript:")
print("%s returned exit code %d" % (cmd, p.returncode))
print(stderr)
exit(1)
if stderr != '':
print "WARNING: initscript sent the following to stderr:"
print stderr
print("WARNING: initscript sent the following to stderr:")
print(stderr)
# Parse the output key=value pairs
skip = False
for line in stdout.splitlines():
@ -58,8 +59,8 @@ def getenv(cmd = ':'):
try:
(var,value) = line.split('=',1)
except ValueError:
print "ERROR: Could not parse output line:"
print line
print("ERROR: Could not parse output line:")
print(line)
exit(1)
# Exported functions - not handled
if value.find('() {') == 0:
@ -149,30 +150,30 @@ elif not options.noprefix:
prefix = None
# Print out the modulefile
print "#%Module 1.0"
print("#%Module 1.0")
# Prefix
if prefix is not None:
print "\nset prefix " + prefix + "\n"
print("\nset prefix " + prefix + "\n")
# Chdir
if chdir is not None:
print "chdir\t" + chdir
print("chdir\t" + chdir)
# Function to format output line with tabs and substituting prefix
def formatline(item, key, value=None):
print item,
print "\t"*(2-(len(item)+1)/8),
print key,
print(item, end=' ')
print("\t"*(2-(len(item)+1)/8), end=' ')
print(key, end=' ')
if value is not None:
print "\t"*(3-(len(key)+1)/8),
print("\t"*(3-(len(key)+1)/8), end=' ')
if prefix is not None:
print value.replace(prefix,'$prefix')
print(value.replace(prefix,'$prefix'))
else:
print value
print(value)
# Paths first, grouped by variable name
pathkeys = appendpath.keys() + prependpath.keys()
pathkeys = list(appendpath.keys()) + list(prependpath.keys())
pathkeys.sort()
for key in pathkeys:
if key in prependpath:
@ -181,16 +182,16 @@ for key in pathkeys:
formatline("append-path",key,appendpath[key])
# Setenv
setenvkeys = setenv.keys()
setenvkeys = list(setenv.keys())
setenvkeys.sort()
if setenvkeys:
print
print()
for key in setenvkeys:
formatline("setenv",key,setenv[key])
# Unsetenv
unsetenv.sort()
if unsetenv:
print
print()
for key in unsetenv:
formatline("unsetenv",key)

View File

@ -2,7 +2,7 @@
Name: environment-modules
Version: 3.2.10
Release: 12%{?dist}
Release: 13%{?dist}
Summary: Provides dynamic modification of a user's environment
Group: System Environment/Base
@ -29,6 +29,10 @@ Patch4: environment-modules-format.patch
# Support Tcl 8.6
# https://sourceforge.net/p/modules/feature-requests/14/
Patch5: environment-modules-tcl86.patch
# python 3 support
# https://sourceforge.net/p/modules/patches/15/
# https://bugzilla.redhat.com/show_bug.cgi?id=1184979
Patch6: environment-modules-py3-and-doc-fix.patch
BuildRequires: tcl-devel, tclx-devel, libX11-devel
BuildRequires: dejagnu
@ -72,6 +76,7 @@ have access to the module alias.
%patch3 -p1 -b .avail
%patch4 -p1 -b .format
%patch5 -p1 -b .tcl86
%patch6 -p1 -b .py3
%build
@ -90,6 +95,10 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
touch %{buildroot}%{_sysconfdir}/profile.d/modules.{csh,sh}
cp -p %SOURCE1 $RPM_BUILD_ROOT%{_datadir}/Modules/init/modules.sh
cp -p %SOURCE2 %SOURCE3 $RPM_BUILD_ROOT%{_datadir}/Modules/bin
%if 0%{?fedora} >= 22
sed -i -e 1s,/usr/bin/python,/usr/bin/python3, \
$RPM_BUILD_ROOT%{_datadir}/Modules/bin/createmodule.py
%endif
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/modulefiles \
$RPM_BUILD_ROOT%{_datadir}/modulefiles
# Install the rpm config file
@ -131,6 +140,9 @@ fi
%changelog
* Wed Jan 28 2015 Orion Poplwski <orion@cora.nwra.com> - 3.2.10-13
- Add patch for python 3 support, use python3 for createmodule.py on F22
* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.2.10-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild