Saltstack Official Galera Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

123 行
5.2KB

  1. DESTDIR=/
  2. SALTENVDIR=/usr/share/salt-formulas/env
  3. RECLASSDIR=/usr/share/salt-formulas/reclass
  4. FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-\_]*')
  5. VERSION=$(shell grep version: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\.\-\_]*')
  6. VERSION_MAJOR := $(shell echo $(VERSION)|cut -d . -f 1-2)
  7. VERSION_MINOR := $(shell echo $(VERSION)|cut -d . -f 3)
  8. NEW_MAJOR_VERSION ?= $(shell date +%Y.%m|sed 's,\.0,\.,g')
  9. NEW_MINOR_VERSION ?= $(shell /bin/bash -c 'echo $$[ $(VERSION_MINOR) + 1 ]')
  10. MAKE_PID := $(shell echo $$PPID)
  11. JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
  12. ifneq ($(subst -j,,$(JOB_FLAG)),)
  13. JOBS := $(subst -j,,$(JOB_FLAG))
  14. else
  15. JOBS := 1
  16. endif
  17. KITCHEN_LOCAL_YAML?=.kitchen.yml
  18. KITCHEN_OPTS?="--concurrency=$(JOBS)"
  19. KITCHEN_OPTS_CREATE?=""
  20. KITCHEN_OPTS_CONVERGE?=""
  21. KITCHEN_OPTS_VERIFY?=""
  22. KITCHEN_OPTS_TEST?=""
  23. all:
  24. @echo "make install - Install into DESTDIR"
  25. @echo "make lint - Run lint tests"
  26. @echo "make test - Run tests"
  27. @echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
  28. @echo "make clean - Cleanup after tests run"
  29. @echo "make release-major - Generate new major release"
  30. @echo "make release-minor - Generate new minor release"
  31. @echo "make changelog - Show changes since last release"
  32. install:
  33. # Formula
  34. [ -d $(DESTDIR)/$(SALTENVDIR) ] || mkdir -p $(DESTDIR)/$(SALTENVDIR)
  35. cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
  36. [ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
  37. [ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
  38. [ ! -d _grains ] || cp -a _grains $(DESTDIR)/$(SALTENVDIR)/ || true
  39. # Metadata
  40. [ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
  41. cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
  42. lint:
  43. [ ! -d tests ] || (cd tests; ./run_tests.sh lint)
  44. test:
  45. [ ! -d tests ] || (cd tests; ./run_tests.sh)
  46. release-major: check-changes
  47. @echo "Current version is $(VERSION), new version is $(NEW_MAJOR_VERSION)"
  48. @[ $(VERSION_MAJOR) != $(NEW_MAJOR_VERSION) ] || (echo "Major version $(NEW_MAJOR_VERSION) already released, nothing to do. Do you want release-minor?" && exit 1)
  49. echo "$(NEW_MAJOR_VERSION)" > VERSION
  50. sed -i 's,version: .*,version: "$(NEW_MAJOR_VERSION)",g' metadata.yml
  51. [ ! -f debian/changelog ] || dch -v $(NEW_MAJOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
  52. make genchangelog-$(NEW_MAJOR_VERSION)
  53. (git add -u; git commit -m "Version $(NEW_MAJOR_VERSION)")
  54. git tag -s -m $(NEW_MAJOR_VERSION) $(NEW_MAJOR_VERSION)
  55. release-minor: check-changes
  56. @echo "Current version is $(VERSION), new version is $(VERSION_MAJOR).$(NEW_MINOR_VERSION)"
  57. echo "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)" > VERSION
  58. sed -i 's,version: .*,version: "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)",g' metadata.yml
  59. [ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
  60. make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
  61. (git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)")
  62. git tag -s -m $(VERSION_MAJOR).$(NEW_MINOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)
  63. check-changes:
  64. @git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1)
  65. changelog:
  66. git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $(VERSION)..HEAD
  67. genchangelog: genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
  68. genchangelog-%:
  69. $(eval NEW_VERSION := $(patsubst genchangelog-%,%,$@))
  70. (echo "=========\nChangelog\n=========\n"; \
  71. (echo $(NEW_VERSION);git tag) | sort -r | grep -E '^[0-9\.]+' | while read i; do \
  72. cur=$$i; \
  73. test $$i = $(NEW_VERSION) && i=HEAD; \
  74. prev=`(echo $(NEW_VERSION);git tag)|sort|grep -E '^[0-9\.]+'|grep -B1 "$$cur\$$"|head -1`; \
  75. echo "Version $$cur\n=============================\n"; \
  76. git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $$prev..$$i; \
  77. echo; \
  78. done) > CHANGELOG.rst
  79. kitchen-check:
  80. @[ -e $(KITCHEN_LOCAL_YAML) ] || (echo "Kitchen tests not available, there's no $(KITCHEN_LOCAL_YAML)." && exit 1)
  81. kitchen: kitchen-check kitchen-create kitchen-converge kitchen-verify kitchen-list
  82. kitchen-create: kitchen-check
  83. kitchen create ${KITCHEN_OPTS} ${KITCHEN_OPTS_CREATE}
  84. [ "$(shell echo $(KITCHEN_LOCAL_YAML)|grep -Eo docker)" = "docker" ] || sleep 120
  85. kitchen-converge: kitchen-check
  86. kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE} &&\
  87. kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE}
  88. kitchen-verify: kitchen-check
  89. [ ! -d tests/integration ] || kitchen verify -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
  90. [ -d tests/integration ] || kitchen verify ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
  91. kitchen-test: kitchen-check
  92. [ ! -d tests/integration ] || kitchen test -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
  93. [ -d tests/integration ] || kitchen test ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
  94. kitchen-list: kitchen-check
  95. kitchen list
  96. clean:
  97. [ ! -x "$(shell which kitchen)" ] || kitchen destroy
  98. [ ! -d .kitchen ] || rm -rf .kitchen
  99. [ ! -d tests/build ] || rm -rf tests/build
  100. [ ! -d build ] || rm -rf build