freebsd-dev/release/Makefile.ec2
Glen Barber 98becbfc3c Add logic to detect if the net/bsdec2-image-upload port needs
to be installed. [1]

For the cw-ec2-portinstall and ec2ami targets, touch the
.TARGET file after completion to prevent duplicate invocations.

Add cw-ec2-portinstall and ec2ami to CLEANFILES.

Submitted by:	cperciva[1]
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2015-05-04 15:04:39 +00:00

61 lines
1.7 KiB
Makefile

#
# $FreeBSD$
#
#
# Makefile for creating an EC2 AMI from a disk image.
#
.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE"
AMINAMESUFFIX!= date +-%Y-%m-%d
.endif
.if defined(EC2PUBLIC)
PUBLISH= --public
.endif
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
cw-ec2-portinstall:
.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
.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
.endif
@touch ${.TARGET}
ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
@false
.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
/usr/local/bin/bsdec2-image-upload ${PUBLISH} \
${.OBJDIR}/ec2.raw \
"${TYPE} ${REVISION}-${BRANCH}${AMINAMESUFFIX}" \
"${TYPE} ${REVISION}-${BRANCH}" \
${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE}
@touch ${.TARGET}