-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
108 lines (96 loc) · 3.25 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
THIS_FILE := $(lastword $(MAKEFILE_LIST))
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CI_REPO_PATH ?= $(ROOT_DIR)/ci
CI_REPO_BRANCH ?= master
.PHONY: all
all: .DEFAULT
.PHONY: clean
clean: clean-ci-repo clean-pyc clean-kitchen clean-puppet-librarian clean-bundler clean-pkg clean-rspec
# Clone the ci-repo into the ci/ directory
.PHONY: clone-ci-repo
clone-ci-repo:
@echo
@echo "==================== clone-ci-repo ===================="
@echo
@if [ ! -d "$(CI_REPO_PATH)" ]; then \
git clone https://github.com/EncoreTechnologies/ci-puppet-python.git --depth 1 --single-branch --branch $(CI_REPO_BRANCH) $(CI_REPO_PATH); \
else \
cd $(CI_REPO_PATH); \
git pull; \
fi;
# Clean the ci-repo (calling `make clean` in that directory), then remove the
# ci-repo directory
.PHONY: clean-ci-repo
clean-ci-repo:
@echo
@echo "==================== clean-ci-repo ===================="
@echo
@if [ -d "$(CI_REPO_PATH)" ]; then \
make -f $(ROOT_DIR)/ci/Makefile clean; \
fi;
rm -rf $(CI_REPO_PATH)
# Clean *.pyc files.
.PHONY: clean-pyc
clean-pyc:
@echo
@echo "==================== clean-pyc ===================="
@echo
find $(ROOT_DIR) -name 'ci' -prune -or -name '.git' -or -type f -name "*.pyc" -print | xargs -r rm
# Clean kitchen build files
.PHONY: clean-kitchen
clean-kitchen:
@echo
@echo "== clean-kitchen ======================================"
@echo
find "$(ROOT_DIR)" -type d -name '.kitchen' | xargs -r -t -n1 rm -rf
# Clean puppet-librarian build files
.PHONY: clean-puppet-librarian
clean-puppet-librarian:
@echo
@echo "== clean-puppet-librarian ============================="
@echo
find "$(ROOT_DIR)" -type d -name '.librarian' -or -type d -name '.tmp' | xargs -r -t -n1 rm -rf
# Clean bundler build files
.PHONY: clean-bundler
clean-bundler:
@echo
@echo "== clean-bundler ======================================"
@echo
rm -rf ${ROOT_DIR}/build/kitchen/.bundle
rm -rf ${ROOT_DIR}/build/kitchen/vendor
rm -rf ${ROOT_DIR}/.bundle
rm -rf ${ROOT_DIR}/Gemfile.lock
rm -rf ${ROOT_DIR}/vendor
rm -rf /tmp/puppet-st2/build
# Clean packages
.PHONY: clean-pkg
clean-pkg:
@echo
@echo "== clean-pkg ======================================"
@echo
rm -rf ${ROOT_DIR}/pkg
# Clean bundler build files
.PHONY: clean-rspec
clean-rspec:
@echo
@echo "== clean-rspec ======================================"
@echo
rm -rf ${ROOT_DIR}/spec/fixtures/modules
# list all makefile targets
.PHONY: list
list:
@if [ -d "$(CI_REPO_PATH)" ]; then \
$(MAKE) --no-print-directory -f $(ROOT_DIR)/ci/Makefile list; \
fi;
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort | uniq | xargs
# forward all make targets not found in this makefile to the ci makefile to do
# the actual work (by calling the invoke-ci-makefile target)
# http://stackoverflow.org/wiki/Last-Resort_Makefile_Targets
# Unfortunately the .DEFAULT target doesn't allow for dependencies
# so we have to manually specify all of the steps in this target.
.DEFAULT:
$(MAKE) clone-ci-repo
@echo
@echo "==================== invoke ci/Makefile (targets: $(MAKECMDGOALS)) ===================="
@echo
make -f $(ROOT_DIR)/ci/Makefile $(MAKECMDGOALS)