#!/usr/bin/make -f

BUNDLE = debian/ros2-term/usr/lib/ros2-term

%:
	dh $@ --with python3

# Pure Python, nothing to build. The tests need ROS; CI runs them, and the smoke test.
override_dh_auto_build override_dh_auto_test:

# The app and the Textual it needs (apt's is too old) go in a private directory,
# seen only by the ros2-term and ros2-log-view wrappers. Textual and its
# dependencies are fetched by pip, pinned and hash-checked by
# bundle-requirements.txt (from uv.lock), so this step needs network.
override_dh_auto_install:
	python3 -m pip install --quiet --no-deps --no-compile --require-hashes \
	    --only-binary=:all: --target $(BUNDLE) -r debian/bundle-requirements.txt
	rm -rf $(BUNDLE)/bin
	cp -r src/ros2_term $(BUNDLE)/
	find $(BUNDLE) -name __pycache__ -prune -exec rm -rf {} +
	install -D -m 755 debian/ros2-term.wrapper debian/ros2-term/usr/bin/ros2-term
	install -D -m 755 debian/ros2-log-view.wrapper debian/ros2-term/usr/bin/ros2-log-view

# Byte-compiled on install, for the Python installed then; no apt dependencies
# guessed from the bundle (that is what bundling avoids).
override_dh_python3:
	dh_python3 --no-guessing-deps /usr/lib/ros2-term
