5 # Makefile for uploading Google Compute Engine disk images.
8 GCE_IMG?= ${.OBJDIR}/gce.raw
9 GCE_UPLOAD_TGTS= gce-check-depends \
12 # I do not yet have a better way to deal with the "must be run interactively"
13 # thing, so this is a fail-safe "do not do anything."
14 .if !defined(GCE_LOGIN_SKIP) || empty(GCE_LOGIN_SKIP)
15 GCE_UPLOAD_TGTS= gce-do-login
17 CLEANFILES+= ${GCE_UPLOAD_TGTS}
21 .if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
22 SNAPSHOT_DATE!= date +-%Y-%m-%d
25 # Really? Uppercase characters are not allowed? Sigh...
26 # And don't even get me started on the '.'.
27 GCE_TARGET:= ${OSRELEASE:S,.raw,,:tl:S,.,-,g}${SNAPSHOT_DATE}
29 gce-upload: ${GCE_UPLOAD_TGTS}
33 . if !defined(GCE${VAR}) || empty(GCE${VAR})
34 @echo "Variable GCE${VAR} cannot be empty."
38 .if !exists(/usr/local/bin/gcloud)
39 . if !exists(${PORTSDIR}/net/google-cloud-sdk/Makefile)
40 . if !exists(/usr/local/sbin/pkg-static)
41 env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
43 env ASSUME_ALWAYS_YES=yes pkg install -y net/google-cloud-sdk
45 make -C ${PORTSDIR}/net/google-cloud-sdk BATCH=1 all install clean
50 @# Yes, really... Sigh.
51 cd ${.OBJDIR} && mv gce.raw disk.raw
52 cd ${.OBJDIR} && tar --format=gnutar -zcf \
53 ${GCE_TARGET:S,${.OBJDIR}/,,}.tar.gz disk.raw
54 cd ${.OBJDIR} && mv disk.raw gce.raw
55 touch ${.OBJDIR}/${.TARGET}
58 @echo "This requires human interaction, which is not yet supported."
62 @# Fallthrough in case the bucket already exists.
63 /usr/local/bin/gsutil mb gs://${GCE_BUCKET} || true
64 /usr/local/bin/gsutil cp ${.OBJDIR}/${GCE_TARGET}.tar.gz \
66 /usr/local/bin/gcloud compute images create ${GCE_TARGET} \
67 --source-uri gs://${GCE_BUCKET}/${GCE_TARGET}.tar.gz
68 touch ${.OBJDIR}/${.TARGET}