-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
117 lines (104 loc) · 3.59 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
109
110
111
112
113
114
115
116
117
# Variables
PKG_NAME = pyats-image-builder
BUILD_DIR = $(shell pwd)/__build__
DIST_DIR = $(BUILD_DIR)/dist
# Development pkg requirements
DEPENDENCIES = pytest wheel PyYAML pip-tools requests gitpython docker
DEPENDENCIES += jsonschema jinja2
.PHONY: help install clean develop undevelop
help:
@echo "Please use 'make <target>' where <target> is one of"
@echo ""
@echo " help display this help"
@echo " install install package"
@echo " package build package"
@echo " clean clean stuff"
@echo " develop install package in development mode"
@echo " undevelop unset the above development mode"
@echo ""
install:
@echo "--------------------------------------------------------------------"
@echo "Installing dependencies"
@pip install $(DEPENDENCIES)
@echo "Installing package"
@python3 setup.py install
@echo ""
@echo "Done."
@echo ""
package:
@echo "--------------------------------------------------------------------"
@echo "Building package"
@mkdir -p $(DIST_DIR)/
@python3 setup.py bdist_wheel --dist-dir=$(DIST_DIR)
@echo ""
@echo "Done."
@echo ""
clean:
@echo ""
@echo "--------------------------------------------------------------------"
@python3 setup.py clean
@echo "Removing *.pyc and __pycache__/ files"
@find . -type f -name "*.pyc" | xargs rm -vrf
@find . -type d -name "__pycache__" | xargs rm -vrf
@echo ""
@echo "Done."
@echo ""
develop:
@echo "--------------------------------------------------------------------"
@echo "Uninstalling package"
@pip uninstall -y pyats-image-builder
@echo "Installing development dependencies"
@pip install $(DEPENDENCIES)
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Setting up development environment"
@python3 setup.py develop --no-deps -q
@echo ""
@echo "Done."
@echo ""
undevelop:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Removing development environment"
@python3 setup.py develop -q --no-deps --uninstall
@echo ""
@echo "Done."
@echo ""
image:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Make image"
@docker build --build-arg --no-cache -t image-builder:latest .
@echo ""
@echo "Done."
@echo ""
distribute:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(PROD_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(PROD_PKGS)/$(PKG_NAME) || mkdir $(PROD_PKGS)/$(PKG_NAME)'
@scp $(DIST_DIR)/* $(PROD_USER):$(PROD_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
distribute_staging:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(STAGING_PKGS)/$(PKG_NAME) || mkdir $(STAGING_PKGS)/$(PKG_NAME)'
@scp $(DIST_DIR)/* $(PROD_USER):$(STAGING_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
distribute_staging_external:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_EXT_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(STAGING_EXT_PKGS)/$(PKG_NAME) || mkdir $(STAGING_EXT_PKGS)/$(PKG_NAME)'
@scp $(DIST_DIR)/* $(PROD_USER):$(STAGING_EXT_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""