xref: /freebsd/release/Makefile.ec2 (revision 1f8b431d185416f70e96f03b8fd69b98442b1913)
1#
2# $FreeBSD$
3#
4#
5# Makefile for creating an EC2 AMI from a disk image.
6#
7
8# Figure out where SVN is
9.if !defined(SVN_CMD) || empty(SVN_CMD)
10. for _P in /usr/bin /usr/local/bin
11.  for _S in svn svnlite
12.   if exists(${_P}/${_S})
13SVN_CMD=   ${_P}/${_S}
14.   endif
15.  endfor
16. endfor
17.endif
18EC2_SVNBRANCH!=	${SVN_CMD} info --show-item relative-url ${WORLDDIR} | sed -e 's/\^\///'
19EC2_SVNREV!=	${SVN_CMD} info --show-item last-changed-revision ${WORLDDIR}
20
21.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE"
22AMINAMESUFFIX!=	date +-%Y-%m-%d
23.endif
24.if defined(EC2PUBLIC) && !empty(EC2PUBLIC)
25PUBLISH=	--public
26.endif
27.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC)
28EC2SNSREL=	${REVISION}-${BRANCH}
29EC2SNSVERS=	${EC2_SVNBRANCH}@${EC2_SVNREV}
30.endif
31
32CLEANFILES+=		ec2ami
33
34.if !exists(/usr/local/bin/bsdec2-image-upload)
35CW_EC2_PORTINSTALL=	cw-ec2-portinstall
36CLEANFILES+=		${CW_EC2_PORTINSTALL}
37.else
38CW_EC2_PORTINSTALL=
39.endif
40
41cw-ec2-portinstall:
42.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
43	env - PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
44.else
45. if !exists(/usr/local/sbin/pkg-static)
46	env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
47. endif
48	env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload
49.endif
50	@touch ${.TARGET}
51
52ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
53.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE})
54	@echo "--------------------------------------------------------------"
55	@echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation"
56	@echo "--------------------------------------------------------------"
57	@false
58.endif
59.if !defined(AWSREGION)
60	@echo "--------------------------------------------------------------"
61	@echo ">>> AWSREGION must be specified EC2 AMI creation"
62	@echo "--------------------------------------------------------------"
63	@false
64.endif
65.if !defined(AWSBUCKET)
66	@echo "--------------------------------------------------------------"
67	@echo ">>> AWSBUCKET must be specified for EC2 AMI creation"
68	@echo "--------------------------------------------------------------"
69	@false
70.endif
71	/usr/local/bin/bsdec2-image-upload ${PUBLISH} --sriov --ena \
72	    ${.OBJDIR}/ec2.raw \
73	    "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \
74	    "${TYPE}/${TARGET} ${EC2_SVNBRANCH}@${EC2_SVNREV}" \
75	    ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \
76	    ${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS}
77	@touch ${.TARGET}
78