pypi2deb.mk 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. PYPI2DEB_BUILD_STAMP_PREFIX = $(DIR_PYPI2DEB_BUILD)/.stamp
  2. PYPI2DEB_BUILD_STAMPS = $(patsubst %,$(PYPI2DEB_BUILD_STAMP_PREFIX)-%,$(PYPI2DEB_PACKAGES))
  3. # options: python or python3 (for package names: python-foo or python3-foo)
  4. PYPI2DEB_PYTHON_PREFIX ?= python3
  5. PYPI2DEB_SIMPLIFIED_PACKAGE_FILES = $(patsubst %,$(DIR_DEBIAN_SIMPLIFIED_PACKAGE_FILES)/$(PYPI2DEB_PYTHON_PREFIX)-%.deb,$(PYPI2DEB_PACKAGES))
  6. .PHONY: help
  7. help: help-pypi2deb
  8. .PHONY: help-pypi2deb
  9. help-pypi2deb:
  10. @echo "Debian-specific packaging targets:"
  11. @echo " dist-pypi2deb"
  12. @echo " upload-pypi2deb"
  13. @echo
  14. .PHONY: dist
  15. dist: dist-pypi2deb
  16. .PHONY: dist-pypi2deb
  17. dist-pypi2deb: $(PYPI2DEB_BUILD_STAMPS)
  18. # create a deb package via py2dsp (requires "pypi2deb")
  19. $(PYPI2DEB_BUILD_STAMP_PREFIX)-%:
  20. @# intelhex: tests fail; setup.py is located in a sub-directory
  21. @# marshmallow: tests fail; building the doc requires "sphinx_issues" module (not in Debian)
  22. if [ "$*" = "intelhex" ]; then export PYBUILD_DIR=intelhex-2.1 PYBUILD_DISABLE=test; fi; \
  23. if [ "$*" = "marshmallow" ]; then export PYBUILD_DISABLE=test PYPI2DEB_SPHINX_DIRS=; fi; \
  24. py2dsp --root "$(DIR_PYPI2DEB_BUILD)" --distribution unstable --build "$*"
  25. ls -tr "$(DIR_PYPI2DEB_BUILD)" | grep "^$*_.*~pypi2deb_$(DEBIAN_BUILD_ARCH)\.changes$$" | tail -n 1 >"$@"
  26. .PHONY: dist-deb-packages-directory
  27. dist-deb-packages-directory: $(PYPI2DEB_SIMPLIFIED_PACKAGE_FILES)
  28. # copy packages created via pypi2deb to the simplified debian export directory
  29. $(PYPI2DEB_SIMPLIFIED_PACKAGE_FILES): $(DIR_DEBIAN_SIMPLIFIED_PACKAGE_FILES)/$(PYPI2DEB_PYTHON_PREFIX)-%.deb: $(PYPI2DEB_BUILD_STAMP_PREFIX)-%
  30. @mkdir -p "$(DIR_DEBIAN_SIMPLIFIED_PACKAGE_FILES)"
  31. deb_name="$$(sed -n '/^Files:$$/,$$p' "$(DIR_PYPI2DEB_BUILD)/$$(cat "$<")" \
  32. | grep -E "$(PYPI2DEB_PYTHON_PREFIX)-$*_.*pypi2deb_($(DEBIAN_BUILD_ARCH)|all)\.deb$$" \
  33. | awk '{print $$5}')"; cp "$(DIR_PYPI2DEB_BUILD)/$$deb_name" "$@"
  34. .PHONY: upload
  35. upload: upload-pypi2deb
  36. .PHONY: upload-pypi2deb
  37. upload-pypi2deb: dist-pypi2deb check-dput-config
  38. @# make sure that 'cat' is not called without arguments (it would read from stdin)
  39. [ -z "$(PYPI2DEB_BUILD_STAMPS)" ] || for changes_file in $$(cat $(PYPI2DEB_BUILD_STAMPS)); do \
  40. dput "$(DEBIAN_UPLOAD_TARGET)" "$(DIR_PYPI2DEB_BUILD)/$$changes_file"; \
  41. done
  42. .PHONY: clean
  43. clean: clean-pypi2deb
  44. .PHONY: clean-pypi2deb
  45. clean-pypi2deb:
  46. $(RM) -r "$(DIR_PYPI2DEB_BUILD)"