2015-04-01 02:00:17 +02:00
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Makefile for creating an EC2 AMI from a disk image.
|
|
|
|
#
|
|
|
|
|
2018-07-22 00:54:43 +02:00
|
|
|
# Figure out where SVN is
|
|
|
|
.if !defined(SVN_CMD) || empty(SVN_CMD)
|
|
|
|
. for _P in /usr/bin /usr/local/bin
|
|
|
|
. for _S in svn svnlite
|
|
|
|
. if exists(${_P}/${_S})
|
|
|
|
SVN_CMD= ${_P}/${_S}
|
|
|
|
. endif
|
|
|
|
. endfor
|
|
|
|
. endfor
|
|
|
|
.endif
|
2018-07-23 01:20:24 +02:00
|
|
|
.if exists(${SRCTOP}/.svn)
|
2018-07-23 01:33:48 +02:00
|
|
|
. if empty(EC2_SVNBRANCH)
|
2018-08-21 17:30:47 +02:00
|
|
|
EC2_SVNBRANCH!= ${SVN_CMD} info --show-item relative-url ${WORLDDIR} 2>/dev/null | sed -e 's/\^\///'
|
2018-07-23 01:20:24 +02:00
|
|
|
. export EC2_SVNBRANCH
|
|
|
|
. endif
|
2018-07-23 01:33:48 +02:00
|
|
|
. if empty(EC2_SVNREV)
|
2018-08-21 17:30:47 +02:00
|
|
|
EC2_SVNREV!= ${SVN_CMD} info --show-item last-changed-revision ${WORLDDIR} 2>/dev/null || true
|
2018-07-23 01:20:24 +02:00
|
|
|
. export EC2_SVNREV
|
|
|
|
. endif
|
2018-07-23 00:57:52 +02:00
|
|
|
.else
|
|
|
|
EC2_SVNBRANCH= unknown
|
|
|
|
EC2_SVNREV= unknown
|
|
|
|
.endif
|
2018-07-22 00:54:43 +02:00
|
|
|
|
2015-06-25 15:40:00 +02:00
|
|
|
.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE"
|
2015-07-01 16:51:26 +02:00
|
|
|
AMINAMESUFFIX!= date +-%Y-%m-%d
|
2015-04-01 02:00:17 +02:00
|
|
|
.endif
|
2018-07-18 01:16:05 +02:00
|
|
|
.if defined(EC2PUBLIC) && !empty(EC2PUBLIC)
|
2015-04-01 02:00:17 +02:00
|
|
|
PUBLISH= --public
|
|
|
|
.endif
|
2018-08-06 21:21:32 +02:00
|
|
|
.if defined(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP)
|
2018-08-07 02:51:49 +02:00
|
|
|
PUBLICSNAP= --publicsnap
|
2018-08-06 21:21:32 +02:00
|
|
|
.endif
|
2018-07-18 01:16:05 +02:00
|
|
|
.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC)
|
2018-07-17 21:05:30 +02:00
|
|
|
EC2SNSREL= ${REVISION}-${BRANCH}
|
|
|
|
EC2SNSVERS= ${EC2_SVNBRANCH}@${EC2_SVNREV}
|
|
|
|
.endif
|
2015-04-01 02:00:17 +02:00
|
|
|
|
2015-05-04 17:04:39 +02:00
|
|
|
CLEANFILES+= ec2ami
|
|
|
|
|
|
|
|
.if !exists(/usr/local/bin/bsdec2-image-upload)
|
|
|
|
CW_EC2_PORTINSTALL= cw-ec2-portinstall
|
|
|
|
CLEANFILES+= ${CW_EC2_PORTINSTALL}
|
|
|
|
.else
|
|
|
|
CW_EC2_PORTINSTALL=
|
|
|
|
.endif
|
|
|
|
|
2015-04-27 23:38:12 +02:00
|
|
|
cw-ec2-portinstall:
|
|
|
|
.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
|
2016-06-09 05:54:25 +02:00
|
|
|
env - PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
|
2015-04-27 23:38:12 +02:00
|
|
|
.else
|
|
|
|
. if !exists(/usr/local/sbin/pkg-static)
|
|
|
|
env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
|
|
|
|
. endif
|
|
|
|
env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload
|
2015-04-01 02:00:17 +02:00
|
|
|
.endif
|
2015-05-04 17:04:39 +02:00
|
|
|
@touch ${.TARGET}
|
2015-04-27 23:38:12 +02:00
|
|
|
|
2015-05-04 17:04:39 +02:00
|
|
|
ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
|
2015-04-01 02:00:17 +02:00
|
|
|
.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE})
|
|
|
|
@echo "--------------------------------------------------------------"
|
|
|
|
@echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation"
|
|
|
|
@echo "--------------------------------------------------------------"
|
|
|
|
@false
|
|
|
|
.endif
|
|
|
|
.if !defined(AWSREGION)
|
|
|
|
@echo "--------------------------------------------------------------"
|
|
|
|
@echo ">>> AWSREGION must be specified EC2 AMI creation"
|
|
|
|
@echo "--------------------------------------------------------------"
|
|
|
|
@false
|
|
|
|
.endif
|
|
|
|
.if !defined(AWSBUCKET)
|
|
|
|
@echo "--------------------------------------------------------------"
|
|
|
|
@echo ">>> AWSBUCKET must be specified for EC2 AMI creation"
|
|
|
|
@echo "--------------------------------------------------------------"
|
|
|
|
@false
|
|
|
|
.endif
|
2018-08-06 21:21:32 +02:00
|
|
|
/usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} --sriov --ena \
|
2015-06-02 19:00:31 +02:00
|
|
|
${.OBJDIR}/ec2.raw \
|
|
|
|
"${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \
|
2018-07-22 00:54:43 +02:00
|
|
|
"${TYPE}/${TARGET} ${EC2_SVNBRANCH}@${EC2_SVNREV}" \
|
2018-07-17 21:05:30 +02:00
|
|
|
${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \
|
|
|
|
${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS}
|
2015-05-04 17:04:39 +02:00
|
|
|
@touch ${.TARGET}
|