xref: /freebsd/release/Makefile.ec2 (revision 5bf5ca772c6de2d53344a78cf461447cc322ccea)
1#
2# $FreeBSD$
3#
4#
5# Makefile for creating an EC2 AMI from a disk image.
6#
7
8.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE"
9AMINAMESUFFIX!=	date +-%Y-%m-%d
10.endif
11.if defined(EC2PUBLIC)
12PUBLISH=	--public
13.endif
14
15CLEANFILES+=		ec2ami
16
17.if !exists(/usr/local/bin/bsdec2-image-upload)
18CW_EC2_PORTINSTALL=	cw-ec2-portinstall
19CLEANFILES+=		${CW_EC2_PORTINSTALL}
20.else
21CW_EC2_PORTINSTALL=
22.endif
23
24cw-ec2-portinstall:
25.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
26	env - PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
27.else
28. if !exists(/usr/local/sbin/pkg-static)
29	env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
30. endif
31	env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload
32.endif
33	@touch ${.TARGET}
34
35ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
36.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE})
37	@echo "--------------------------------------------------------------"
38	@echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation"
39	@echo "--------------------------------------------------------------"
40	@false
41.endif
42.if !defined(AWSREGION)
43	@echo "--------------------------------------------------------------"
44	@echo ">>> AWSREGION must be specified EC2 AMI creation"
45	@echo "--------------------------------------------------------------"
46	@false
47.endif
48.if !defined(AWSBUCKET)
49	@echo "--------------------------------------------------------------"
50	@echo ">>> AWSBUCKET must be specified for EC2 AMI creation"
51	@echo "--------------------------------------------------------------"
52	@false
53.endif
54	/usr/local/bin/bsdec2-image-upload ${PUBLISH} --sriov --ena \
55	    ${.OBJDIR}/ec2.raw \
56	    "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \
57	    "${TYPE} ${REVISION}-${BRANCH}-${TARGET}" \
58	    ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE}
59	@touch ${.TARGET}
60