.PHONY: all
all: adequate-testpkg_1_i386.changes
	$(info Run "make run" as root.)
	$(info Alternatively, if you have user-mode-linux installed, you can try "make run-uml" as normal user.)
	$(info )@:

adequate-testpkg_1_i386.changes:
	cd testpkg && dpkg-buildpackage -b -us -uc

.PHONY: run
run: adequate-testpkg_1_i386.changes
	./run-tests $(<)

.PHONY: run-uml
run-uml: adequate-testpkg_1_i386.changes
	fallocate -l 1G uml-guest-swap
	setsid linux init=$(CURDIR)/uml-guest-init \
		$(shell printf '%s' '$(CURDIR)' | base64 -w0 | tr = _) \
		$(shell printf '%s' '$(<)' | base64 -w0 | tr = _) \
		rootfstype=hostfs ubd0=uml-guest-swap mem=128M quiet con=null,fd:1 \
	| sed '/: adequate tests succeeded :/ q 100'; \
	[ $$? -eq 100 ]

.PHONY: clean
clean:
	cd testpkg && debian/rules clean
	rm -f *.changes *.deb
	rm -f uml-guest-swap

# vim:ts=4 sw=4 noet
