forked from vmware/photon-packer-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (42 loc) · 1.75 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
# vim:ft=make:
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Defaults
THIS_FILE := $(lastword $(MAKEFILE_LIST))
PACKER_VAR_FILE := photon-4.0-R2.pkrvars.hcl
PACKER_ARGS := -var-file=$(PACKER_VAR_FILE) .
PACKER_BUILDERS := vmware-iso.vagrant-vmw virtualbox-iso.vagrant-vbx
# Help Targets
.PHONY: help
help:
@echo "Targets:"
@echo " validate"
@echo " $(addsuffix \n , $(addprefix validate-, $(PACKER_BUILDERS)))"
@echo " build"
@echo " $(addsuffix \n , $(addprefix build-, $(PACKER_BUILDERS)))"
@echo " clean"
# Packer Targets
.PHONY: validate* build* publish*
validate:
@echo "> Initializing plug-ins..."
packer init $(PACKER_ARGS)
@echo "> Validating all builders..."
packer validate $(PACKER_ARGS)
validate-%:
@echo "> Initializing plug-ins..."
packer init -only=$(patsubst validate-%,%, $@) $(PACKER_ARGS)
@echo "> Validating builder: $(patsubst validate-%,%, $@)."
packer validate -only=$(patsubst validate-%,%, $@) $(PACKER_ARGS)
build: validate
@echo "> Building with all builders..."
packer build --force $(PACKER_ARGS)
build-%:
@$(MAKE) -f $(THIS_FILE) validate-$(patsubst build-%,%, $@)
@echo "Building with builder: $(patsubst build-%,%, $@)."
packer build --force -only=$(patsubst build-%,%, $@) $(PACKER_ARGS)
# Cleanup
.PHONY: clean*
clean:
./scripts/clean.sh