You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mxe.updates.mk 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # This file is part of MXE. See LICENSE.md for licensing information.
  2. # Generic updater
  3. # $(call GET_LATEST_VERSION, base url[, prefix, ext, filter, separator])
  4. # base url : required page returning list of versions
  5. # e.g https://ftp.gnu.org/gnu/libfoo
  6. # prefix : segment before version
  7. # defaults to lastword of url with dash i.e. `libfoo-`
  8. # ext : segment ending version - default `\.tar`
  9. # filter : `grep -i` filter-out pattern - default alpha\|beta\|rc
  10. # separator: transform char to `.` - typically `_`
  11. #
  12. # test changes with:
  13. # make check-get-latest-version
  14. #
  15. # and update tools/skeleton.py with usage notes
  16. define GET_LATEST_VERSION
  17. $(WGET) -q -O- '$(strip $(1))' | \
  18. $(SED) -n 's,.*<a href=".*$(strip $(or $(2),$(lastword $(subst /,$(space),$(1)))-))\([0-9][^"]*\)$(strip $(or $(3),\.tar)).*,\1,p' | \
  19. grep -vi '$(strip $(or $(4),alpha\|beta\|rc))' | \
  20. tr '$(strip $(5))' '.' | \
  21. $(SORT) -V | \
  22. tail -1
  23. endef
  24. ALL_DIRS := $(MXE_PLUGIN_DIRS) $(shell find $(realpath $(TOP_DIR)/plugins) -type d)
  25. GET_LATEST_VERSION_PKGS := $(sort \
  26. $(basename $(notdir $(shell grep -l GET_LATEST_VERSION -r $(ALL_DIRS)))))
  27. .PHONY: check-get-latest-version
  28. check-get-latest-version:
  29. @$(MAKE) -f '$(MAKEFILE)' \
  30. $(addprefix check-update-package-,$(GET_LATEST_VERSION_PKGS)) \
  31. MXE_PLUGIN_DIRS='$(ALL_DIRS)'
  32. COMPARE_VERSIONS = $(strip \
  33. $(if $($(1)_BRANCH),$(call seq,$($(1)_VERSION),$(2)),\
  34. $(filter $(2),$(shell printf '$($(1)_VERSION)\n$(2)' | $(SORT) -V | head -1))))
  35. .PHONY: update
  36. define UPDATE
  37. $(if $(2),
  38. $(if $(filter $($(1)_IGNORE),$(2)),
  39. $(info IGNORED $(1) $(2)),
  40. $(if $(COMPARE_VERSIONS),
  41. $(if $(filter $(2),$($(1)_VERSION)),
  42. $(info . $(1) $(2)),
  43. $(info OLD $(1) $($(1)_VERSION) --> $(2) ignoring)),
  44. $(info NEW $(1) $($(1)_VERSION) --> $(2))
  45. $(if $(findstring undefined, $(origin UPDATE_DRYRUN)),
  46. $(SED) -i 's/^\([^ ]*_VERSION *:=\).*/\1 $(2)/' '$($(1)_MAKEFILE)'
  47. $(MAKE) -f '$(MAKEFILE)' 'update-checksum-$(1)' \
  48. || { $(SED) -i 's/^\([^ ]*_VERSION *:=\).*/\1 $($(1)_VERSION)/' '$($(1)_MAKEFILE)'; \
  49. exit 1; }))),
  50. $(info Unable to update version number of package $(1) \
  51. $(newline)$(newline)$($(1)_UPDATE)$(newline)))
  52. endef
  53. update:
  54. $(foreach PKG,$(PKGS),\
  55. $(and $($(PKG)_UPDATE),$(call UPDATE,$(PKG),$(shell $($(PKG)_UPDATE)))))
  56. update-package-%:
  57. $(if $(call set_is_member,$*,$(PKGS)), \
  58. $(and $($*_UPDATE),$(call UPDATE,$*,$(shell $($*_UPDATE)))), \
  59. $(error Package $* not found))
  60. @echo -n
  61. check-update-package-%: UPDATE_DRYRUN = true
  62. check-update-package-%: update-package-% ;
  63. update-checksum-%: MXE_NO_BACKUP_DL = true
  64. update-checksum-%: SKIP_CHECHSUM = true
  65. update-checksum-%:
  66. $(if $(call set_is_member,$*,$(PKGS)), \
  67. $(call DOWNLOAD_PKG_ARCHIVE,$*) && \
  68. $(SED) -i 's/^\([^ ]*_CHECKSUM *:=\).*/\1 '"`$(call PKG_CHECKSUM,$*)`"'/' '$($*_MAKEFILE)', \
  69. $(error Package $* not found))