New Saltstack Salt formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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