Use ldd instead of scanelf in install.sh
Opened this issue · 4 comments
Hey,
I just figured that the install.sh
script was not working properly for me, because scanelf
is not present on my system. However, the script can easily be changed to work with ldd
instead of scanelf
like so:
#!/usr/bin/env bash
set -e
which profanity > /dev/null
which ldd > /dev/null
which sed > /dev/null
profanity="$(which profanity)"
python_version="$(ldd "${profanity}" | grep libpython | sed -nre 's/^\s*libpython([0-9]+\.[0-9]+).*$/\1/p')"
python"${python_version}" setup.py install --force --user --prefix=
mkdir -p ~/.local/share/profanity/plugins
cp deploy/prof_omemo_plugin.py ~/.local/share/profanity/plugins/
I do not know whether this works on all systems, but as far as I can see it should.
Best,
Daniel
Hi Daniel! Thanks for your report.
We decided against ldd (see the discussion over here) – if you have any alternative that would be more compatible: we're open for improvements. 😄
Hey bascht,
thanks for the pointer, I didn't know there was a prior discussion on what tool to use to extract the built in python version. (Indeed, I even didn't know know about the security considerations around ldd
, shame on me …).
The discussion already provided an alternative (readelf
) that I would like to see instead of scanelf
, because it's part of the standard installation of virtually every Linux distribution (I don't know about OSX, though). From a quick glance over the discussion, I cannot directly see why this option had been discarded … Do you know why?
The man page of ldd
indead also mentions an alternative, namely objdump
:
$ objdump -p /usr/bin/profanity | grep libpython | perl -pe 's/.*libpython(\d\.\d).*/\1/'
3.7
objdump
should be as ubiquitous as readelf
, but again I don't know about OSX. (Come to think of it: BSD does not use ELF, does it?)
In any way: this issue is not that important, I just thought to share the idea of simplifying the install script, not realizing there was some prior discussion already covering it. So feel free to close this issue. :)
Best,
Daniel
Edit: modern BSDs do indeed use ELF.
@exot There is no ldd
on OSX. More than that, there is no libpython
library in linked libraries:
~ λ dyldinfo -dylibs $(command -v profanity)
attributes dependent dylibs
/usr/local/opt/glib/lib/libgio-2.0.0.dylib
/usr/local/opt/glib/lib/libgobject-2.0.0.dylib
/usr/local/opt/glib/lib/libglib-2.0.0.dylib
/usr/local/opt/gettext/lib/libintl.8.dylib
/usr/lib/libcurl.4.dylib
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
/usr/local/opt/libotr/lib/libotr.5.dylib
/usr/local/opt/gpgme/lib/libgpgme.11.dylib
/usr/local/opt/libassuan/lib/libassuan.0.dylib
/usr/local/opt/libgpg-error/lib/libgpg-error.0.dylib
/usr/local/opt/readline/lib/libreadline.8.dylib
/usr/lib/libncurses.5.4.dylib
/usr/local/opt/libstrophe/lib/libstrophe.0.dylib
/usr/lib/libSystem.B.dylib
In fact, I can't understand, why are you trying to fetch python version in that way. Why don't you use pkg-config
?
~ λ pkg-config --modversion python3
3.7