c3955757a9
will include license metadata in the resultant GCE image. GCE_LICENSE is unset by default, as it primarily pertains to images produced by the FreeBSD Project, but for downstream FreeBSD consumers, it can be set in the make(1) environment in the format of: --licenses="projects/PROJECT_ID/global/licenses/LICENSE_NAME" The "license" is not a license, per se, but required metadata that is required by the GCE marketplace. For the FreeBSD Project, the license name is simply 'freebsd', with the description of 'FreeBSD'. MFC after: 3 days Sponsored by: The FreeBSD Foundation
78 lines
2.1 KiB
Makefile
78 lines
2.1 KiB
Makefile
#
|
|
# $FreeBSD$
|
|
#
|
|
#
|
|
# Makefile for uploading Google Compute Engine disk images.
|
|
#
|
|
|
|
GCE_IMG?= ${.OBJDIR}/gce.raw
|
|
GCE_UPLOAD_TGTS= gce-check-depends \
|
|
gce-do-package \
|
|
gce-do-upload
|
|
# I do not yet have a better way to deal with the "must be run interactively"
|
|
# thing, so this is a fail-safe "do not do anything."
|
|
.if !defined(GCE_LOGIN_SKIP) || empty(GCE_LOGIN_SKIP)
|
|
GCE_UPLOAD_TGTS= gce-do-login
|
|
.endif
|
|
CLEANFILES+= ${GCE_UPLOAD_TGTS}
|
|
|
|
GCE_BUCKET?=
|
|
GCE_LICENSE?=
|
|
|
|
.if !defined(GCE_FAMILY) || empty(GCE_FAMILY)
|
|
GCE_FAMILY= ${TYPE:tl}-${REVISION:S,.,-,}
|
|
.endif
|
|
|
|
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
|
|
_SNAPSHOT_DATE!= date +%Y%m%d
|
|
SNAPSHOT_DATE= -v${_SNAPSHOT_DATE}
|
|
GCE_FAMILY_SUFX= -snap
|
|
.endif
|
|
|
|
# Really? Uppercase characters are not allowed? Sigh...
|
|
# And don't even get me started on the '.'.
|
|
GCE_TARGET:= ${OSRELEASE:S,.raw,,:tl:S,.,-,g}${SNAPSHOT_DATE}
|
|
|
|
gce-upload: ${GCE_UPLOAD_TGTS}
|
|
|
|
gce-check-depends:
|
|
.for VAR in _BUCKET
|
|
. if !defined(GCE${VAR}) || empty(GCE${VAR})
|
|
@echo "Variable GCE${VAR} cannot be empty."
|
|
@false
|
|
. endif
|
|
.endfor
|
|
.if !exists(/usr/local/bin/gcloud)
|
|
. if !exists(${PORTSDIR}/net/google-cloud-sdk/Makefile)
|
|
. if !exists(/usr/local/sbin/pkg-static)
|
|
env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
|
|
. endif
|
|
env ASSUME_ALWAYS_YES=yes pkg install -y net/google-cloud-sdk
|
|
. else
|
|
make -C ${PORTSDIR}/net/google-cloud-sdk BATCH=1 all install clean
|
|
. endif
|
|
.endif
|
|
|
|
gce-do-package:
|
|
@# Yes, really... Sigh.
|
|
cd ${.OBJDIR} && mv gce.raw disk.raw
|
|
cd ${.OBJDIR} && tar --format=gnutar -zcf \
|
|
${GCE_TARGET:S,${.OBJDIR}/,,}.tar.gz disk.raw
|
|
cd ${.OBJDIR} && mv disk.raw gce.raw
|
|
touch ${.OBJDIR}/${.TARGET}
|
|
|
|
gce-do-login:
|
|
@echo "This requires human interaction, which is not yet supported."
|
|
@true
|
|
|
|
gce-do-upload:
|
|
@# Fallthrough in case the bucket already exists.
|
|
/usr/local/bin/gsutil mb gs://${GCE_BUCKET} || true
|
|
/usr/local/bin/gsutil cp ${.OBJDIR}/${GCE_TARGET}.tar.gz \
|
|
gs://${GCE_BUCKET}/
|
|
/usr/local/bin/gcloud compute images create ${GCE_TARGET} \
|
|
--family=${GCE_FAMILY}${GCE_FAMILY_SUFX} ${GCE_LICENSE} \
|
|
--source-uri gs://${GCE_BUCKET}/${GCE_TARGET}.tar.gz
|
|
touch ${.OBJDIR}/${.TARGET}
|
|
|