pypi2deb.mk 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. py2dsp --root "$(DIR_PYPI2DEB_BUILD)" --distribution unstable --build "$*"
  21. @# determine the name of the "changes" file generated by py2dsp
  22. @# remove a potential version specifier (e.g. "foo_2.1.0") from the end of the package name
  23. ls -tr "$(DIR_PYPI2DEB_BUILD)" | grep "^$$(echo "$*" | sed 's/_[0-9][^_]*$$//')*_.*~pypi2deb_$(DEBIAN_BUILD_ARCH)\.changes$$" | tail -n 1 >"$@.new"
  24. @# fail if no "changes" file was created by py2dsp
  25. [ -s "$@.new" ]
  26. mv "$@.new" "$@"
  27. .PHONY: dist-deb-packages-directory
  28. dist-deb-packages-directory: $(PYPI2DEB_SIMPLIFIED_PACKAGE_FILES)
  29. # copy packages created via pypi2deb to the simplified debian export directory
  30. $(PYPI2DEB_SIMPLIFIED_PACKAGE_FILES): $(DIR_DEBIAN_SIMPLIFIED_PACKAGE_FILES)/$(PYPI2DEB_PYTHON_PREFIX)-%.deb: $(PYPI2DEB_BUILD_STAMP_PREFIX)-%
  31. @mkdir -p "$(DIR_DEBIAN_SIMPLIFIED_PACKAGE_FILES)"
  32. deb_name="$$(sed -n '/^Files:$$/,$$p' "$(DIR_PYPI2DEB_BUILD)/$$(cat "$<")" \
  33. | grep -E "$(PYPI2DEB_PYTHON_PREFIX)-$*_.*pypi2deb_($(DEBIAN_BUILD_ARCH)|all)\.deb$$" \
  34. | awk '{print $$5}')"; cp "$(DIR_PYPI2DEB_BUILD)/$$deb_name" "$@"
  35. .PHONY: upload
  36. upload: upload-pypi2deb
  37. .PHONY: upload-pypi2deb
  38. upload-pypi2deb: dist-pypi2deb check-dput-config
  39. @# make sure that 'cat' is not called without arguments (it would read from stdin)
  40. [ -z "$(PYPI2DEB_BUILD_STAMPS)" ] || for changes_file in $$(cat $(PYPI2DEB_BUILD_STAMPS)); do \
  41. dput "$(DEBIAN_UPLOAD_TARGET)" "$(DIR_PYPI2DEB_BUILD)/$$changes_file"; \
  42. done
  43. .PHONY: clean
  44. clean: clean-pypi2deb
  45. .PHONY: clean-pypi2deb
  46. clean-pypi2deb:
  47. $(RM) -r "$(DIR_PYPI2DEB_BUILD)"