Bug 951295 - pysdm fails when running from shell
Summary: pysdm fails when running from shell
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: pysdm
Version: 18
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Richard Shaw
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-04-12 02:04 UTC by Fabio Olive Leite
Modified: 2013-11-05 02:55 UTC (History)
1 user (show)

Fixed In Version: pysdm-0.4.1-7.fc19
Clone Of:
Environment:
Last Closed: 2013-11-05 02:51:15 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Fabio Olive Leite 2013-04-12 02:04:17 UTC
Description of problem:

When pysdm is called from a shell, the default PATH finds it as /bin/pysdm (with F18 /bin being a symlink to /usr/bin) and the dirname logic in the script tries to find the python code in /share/pysdm instead of /usr/share/pysdm.

$ sudo pysdm
/bin/pysdm: line 5: cd: //share/pysdm: No such file or directory
python: can't open file 'pysdm.py': [Errno 2] No such file or directory


$ sudo sh -x pysdm
++ dirname pysdm
+ path=.
++ dirname .
+ path=.
+ cd ./share/pysdm
/bin/pysdm: line 5: cd: ./share/pysdm: No such file or directory
+ python pysdm.py
python: can't open file 'pysdm.py': [Errno 2] No such file or directory


$ sudo sh -x /bin/pysdm
++ dirname /bin/pysdm
+ path=/bin
++ dirname /bin
+ path=/
+ cd //share/pysdm
/bin/pysdm: line 5: cd: //share/pysdm: No such file or directory
+ python pysdm.py
python: can't open file 'pysdm.py': [Errno 2] No such file or directory


Only when you actually run it as /usr/bin/pysdm does it work:

$ sudo sh -x /usr/bin/pysdm
++ dirname /usr/bin/pysdm
+ path=/usr/bin
++ dirname /usr/bin
+ path=/usr
+ cd /usr/share/pysdm
+ python pysdm.py


Perhaps the upstream package does this dirname dance to accomodate weird distro layouts, but there's no reason for us in Fedora to do this. We should just cd into the right directory and call it.

Version-Release number of selected component (if applicable):

pysdm-0.4.1-4.fc18.noarch

How reproducible:

100%. Just call it on a shell and it will fail, unless you use the full path to the executable script.

Comment 1 Richard Shaw 2013-10-25 18:33:55 UTC
Whoops, looks like i fixed this and did builds but never submitted a bodhi update. Working on it now.

Comment 2 Fedora Update System 2013-10-25 18:52:48 UTC
pysdm-0.4.1-7.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/pysdm-0.4.1-7.fc18

Comment 3 Fedora Update System 2013-10-25 18:52:57 UTC
pysdm-0.4.1-7.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/pysdm-0.4.1-7.fc19

Comment 4 Fedora Update System 2013-10-27 03:52:43 UTC
Package pysdm-0.4.1-7.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing pysdm-0.4.1-7.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-20040/pysdm-0.4.1-7.fc18
then log in and leave karma (feedback).

Comment 5 Fabio Olive Leite 2013-10-29 02:42:11 UTC
Verified that pysdm-0.4.1-7.fc18.noarch works fine regardless of how it is called. Tried these:

$ sudo pysdm
$ sudo /bin/pysdm
$ sudo /usr/bin/pysdm

They all work equally well. Thank you!

For a future update, you might as well completely remove the "path=" lines, as they serve absolutely no purpose in the script:

$ cat -n /usr/bin/pysdm 
     1	#!/bin/sh
     2	
     3	path=`dirname $0`
     4	path=`dirname /usr`
     5	cd /usr/share/pysdm
     6	python pysdm.py

Remove lines 3 and 4. "path" is not an exported variable in that script, so they will not affect how pysdm runs in any way. :)

Thank you for your attention!
Fábio Olivé

Comment 6 Richard Shaw 2013-10-29 02:45:06 UTC
Yeah, but then it would be better to patch it. This fix is a sed one liner :)

The best (upstream) patch would probably be to use a .in file and substitute the correct path during package building.

Comment 7 Fabio Olive Leite 2013-10-29 02:47:59 UTC
OK, I get your point now. :) Added karma to the update on bodhi.

Comment 8 Fedora Update System 2013-11-05 02:51:15 UTC
pysdm-0.4.1-7.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2013-11-05 02:55:37 UTC
pysdm-0.4.1-7.fc19 has been pushed to the Fedora 19 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.