Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure test for libxml2 always succeeds #41

Open
HansWeltar opened this issue Sep 8, 2020 · 1 comment
Open

Configure test for libxml2 always succeeds #41

HansWeltar opened this issue Sep 8, 2020 · 1 comment
Milestone

Comments

@HansWeltar
Copy link

How to reproduce:

  • Do not install libxml2
  • (might want to make sure /bin/sh is not symlinked to bash)
  • run ./configure
checking for python module libxml2... found
checking that generated files are newer than configure... Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'libxml2'
done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating itstool
config.status: creating itstool.1
config.status: creating its/Makefile
config.status: creating setup.py

As you can see, configure falsely claims it found libxml2 even though it's absent.
The next error is ignored.
The rest of the build proceeds with success, but itstool fails to run giving an import error on libxml2.

root cause:
bash versus sh semantics for &>.
The line to test for libxml2 is the following: echo "import $py_module" | $PYTHON - &>/dev/null
Then the exit-code $? is checked for success.

In bash &> is shorthand for redirect stdout +stderr
/bin/sh interprets &> as & (run in background) > (redirect output)
When running in background the exit-code is always 0 (success) and thus the test for libxml2 always succeeds

./configure explicitly states #!/bin/sh in the shebang so /bin/sh semantics should be observed.

Fix:
replace &>/dev/null with >/dev/null 2>&1 in ./configure
This expression is valid for both bash and sh.
patch_itstool_libxml2_detect.txt

@shaunix
Copy link
Contributor

shaunix commented Dec 28, 2020

Today I learned a bashism I was unaware of. Thanks. I think I'm going to switch entirely to setuptools for the next version, which will make this issue go away. But I'll keep this issue open for now.

@shaunix shaunix added this to the 2.1.0 milestone Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants