Bug 1197321 - createmodule.sh is broken
Summary: createmodule.sh is broken
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: environment-modules
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Orion Poplawski
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-02-28 10:26 UTC by Remi Collet
Modified: 2015-03-13 17:13 UTC (History)
3 users (show)

Fixed In Version: environment-modules-3.2.10-14.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-13 17:13:25 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to parse bash function properly. (382 bytes, patch)
2015-03-02 09:57 UTC, Ľuboš Kardoš
no flags Details | Diff

Description Remi Collet 2015-02-28 10:26:02 UTC
Trying to adap some SCL to scl-utils and environment-modules according to https://www.softwarecollections.org/en/docs/guide/#sect-Converting_Software_Collection_Scriptlets_into_Environment_Modules

This result (in build.log)
+ /usr/share/Modules/bin/createmodule.sh enable
+ tee envmod
/usr/share/Modules/bin/createmodule.sh: eval: line 60: unexpected EOF while looking for matching `]'
/usr/share/Modules/bin/createmodule.sh: eval: line 61: syntax error: unexpected end of file
/usr/share/Modules/bin/createmodule.sh: eval: line 66: unexpected EOF while looking for matching `]'
/usr/share/Modules/bin/createmodule.sh: eval: line 67: syntax error: unexpected end of file
#%Module 1.0


And the empty file is obviously unusable.

Broken with 3.2.10-6.fc20 and 3.2.10-12.fc21, but works fine with 3.2.10-13.fc22

Comment 1 Ľuboš Kardoš 2015-03-02 09:56:06 UTC
The problem is that script createmodule.sh can't parse bash functions properly. Probably it can't do that in f22 either but you haven't set any such problematic function in your environment. I think the problem is function "scl" in your case. The workaround can be "unset scl". I will also attach some possible patch of the script createmodule.sh in the next comment.

Comment 2 Ľuboš Kardoš 2015-03-02 09:57:21 UTC
Created attachment 997012 [details]
Patch to parse bash function properly.

Comment 3 Remi Collet 2015-03-02 10:17:34 UTC
@Lubox please notice that it works in Fedora 22

Comment 4 Ľuboš Kardoš 2015-03-02 11:11:50 UTC
(In reply to Remi Collet from comment #3)
> @Lubox please notice that it works in Fedora 22

I tried also the script createmodules.sh from package environment-modules-3.2.10-13.fc22.x86_64.rpm and it was broken too. It is obvious beacuse the script createmodules.sh from f22 is identical with the script createmodule.sh from f21.

Comment 5 Remi Collet 2015-03-02 12:58:40 UTC
Very strange.... it doesn't work in mock (rpmdbuild), but works from the shell...

$ mock ....
+ /usr/share/Modules/bin/createmodule.sh enable
+ tee envmod
/usr/share/Modules/bin/createmodule.sh: eval: line 60: unexpected EOF while looking for matching `]'
/usr/share/Modules/bin/createmodule.sh: eval: line 61: syntax error: unexpected end of file
/usr/share/Modules/bin/createmodule.sh: eval: line 66: unexpected EOF while looking for matching `]'
/usr/share/Modules/bin/createmodule.sh: eval: line 67: syntax error: unexpected end of file
#%Module 1.0


$ mock ... shell
<mock-chroot>sh-4.2# /usr/share/Modules/bin/createmodule.sh enable
#%Module 1.0
prepend-path    LD_LIBRARY_PATH /opt/remi/php54/root/usr/lib64
prepend-path    MANPATH /opt/remi/php54/root/usr/share/man:
prepend-path    PATH    /opt/remi/php54/root/usr/bin:/opt/remi/php54/root/usr/sbin

Comment 6 Ľuboš Kardoš 2015-03-02 13:29:40 UTC
Probably because environment isn't same. You can try to put command "env" before calling script createmodule.sh and diff the outputs for these two cases (work / doesn't work). The problem is that script createmodule.sh parses output from command "env" but it expects format "key=value" on each line and it is confused 
if e. g. the following function is defined and it is in output of env command:

BASH_FUNC_scl()=() {  local CMD=$1;
 if [ "$CMD" = "load" -o "$CMD" = "unload" ]; then
 eval "module $@";
 else
 /usr/bin/scl "$@";
 fi
}

Comment 7 Orion Poplawski 2015-03-02 20:10:06 UTC
Ľuboš - thanks for the patch.  I've applied it.

Comment 8 Fedora Update System 2015-03-02 20:13:05 UTC
environment-modules-3.2.10-14.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/environment-modules-3.2.10-14.fc20

Comment 9 Remi Collet 2015-03-03 07:30:57 UTC
With environment-modules-3.2.10-14.fc20 in the buildroot:

+ /usr/share/Modules/bin/createmodule.sh enable
+ tee envmod
#%Module 1.0
prepend-path    LD_LIBRARY_PATH /opt/remi/php54/root/usr/lib64
prepend-path    MANPATH /opt/remi/php54/root/usr/share/man:
prepend-path    PATH    /opt/remi/php54/root/usr/bin:/opt/remi/php54/root/usr/sbin


@Orion, can you please also fix F21 ?

Comment 10 Remi Collet 2015-03-03 07:33:23 UTC
(In reply to Remi Collet from comment #9)
> @Orion, can you please also fix F21 ?

Sorry for the noise, I just found https://admin.fedoraproject.org/updates/environment-modules-3.2.10-14.fc21 (not attached to fix bug)

Comment 11 Fedora Update System 2015-03-04 10:22:49 UTC
Package environment-modules-3.2.10-14.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing environment-modules-3.2.10-14.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-2982/environment-modules-3.2.10-14.fc20
then log in and leave karma (feedback).

Comment 12 Fedora Update System 2015-03-13 17:13:25 UTC
environment-modules-3.2.10-14.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.