Skip to content

docker-to-squash.py: find mksquashfs on PATH in check_dependencies - #9301

Open
linzch3 wants to merge 1 commit into
apache:masterfrom
linzch3:fix-check-deps-mksquashfs-which
Open

linzch3 wants to merge 1 commit into
apache:masterfrom
linzch3:fix-check-deps-mksquashfs-which

Conversation

@linzch3

@linzch3 linzch3 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Fixes #9300.

Follow-up to #9293, from rzo1's review: now that check_dependencies can actually fail, it probes mksquashfs at the hard-coded path /usr/sbin/mksquashfs, while the conversion itself runs mksquashfs from PATH. On hosts where the binary lives elsewhere (e.g. /usr/bin) the tool would now stop.

Changes:

  • Resolve mksquashfs with shutil.which("mksquashfs") and probe that path. If it is not on PATH, the check fails the same way as a missing tool.
  • The other tools in check_dependencies are already consistent with this: skopeo, tar, and setfattr are invoked by name from PATH; hadoop is resolved via HADOOP_BIN_DIR. Only mksquashfs was hard-coded.
  • Tests mock shutil.which: a binary found at /usr/bin/mksquashfs is accepted, and a missing binary fails the check.

How was the change tested

  • uv run --python 3.9 --no-project python -m unittest test_docker_to_squash in bin/: 5 tests OK.
  • With the shutil.which lookup reverted, both new tests fail (which('mksquashfs') is not called; the missing-binary case returns 0). Restoring the fix, all tests pass.
  • On Python 3.10+ the module can't be imported (from collections import Iterable); that's covered by Fix Python 3 incompatibilities in bin/docker-to-squash.py #9296, so tests were run on Python 3.9.

Happy to adjust anything, lmk.

Fixes apache#9300.

check_dependencies probed the hard-coded path /usr/sbin/mksquashfs,
while the conversion itself runs mksquashfs from PATH. After apache#9293 the
check can actually fail, so a binary installed elsewhere (e.g. /usr/bin)
would stop the tool. Look it up with shutil.which instead, as suggested
in the apache#9293 review.
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

Successfully merging this pull request may close these issues.

docker-to-squash.py: check_dependencies should find mksquashfs on PATH

1 participant