freebsd-skq/release/Makefile.gce
gjb 6c9b1bee2d MFC r284893, r284895-r284897, r284942, r284968, r284996, r285005:
r284893 (brd):
  Add initial support for building Vagrant images for VMWare.
  Next steps will be adding Virtualbox support and uploading
  to Hashicorp Atlas for others to consume.

 r284895:
  Add default VAGRANT_IMG variable.

 r284896:
  Remove _ACCOUNT and add _USERNAME, _NAME, _VERSION for the
  VAGRANT_${VAR} variables extracted from VAGRANT_UPLOAD_CONF.

  Set ATLAS_${VAR} to VAGRANT_${VAR} if VAGRANT_UPLOAD_CONF
  is set.  There is intent to intentionally have separate
  variants of configuration entries, but the defaults do not
  yet have any reason to be different.

 r284897:
  Instead of hard-coding the PROVIDERS for upload, add the
  VAGRANT_PROVIDERS variable.  Right now, it defaults to only
  vmware_desktop, virtualbox support is to follow at some point.

  While here, fix the hashicorp URL: s/vagrant/atlas/, which
  was result of a sed(1) replace (and my fault).

 r284942 (brd):
  Add Support for uploading Vagrant images to Hashicorp Atlas.

 r284968:
  Default the VAGRANT_VERSION to ${REVISION}-${BRANCH} if
  not set, which expands to '11.0-CURRENT', for example.

  If the branch is -CURRENT, -STABLE, or -PRERELEASE, suffix
  the VAGRANT_VERSION with the snapshot date.

 r284996:
  Fix the gcloud port/package name.

 r285005:
  Remove the HH-MM suffix from the build date suffix.

  It was useful when working out several kinks when testing
  automated image uploading when retrying was necessary, but
  now it is making things much too messy.

Sponsored by:	The FreeBSD Foundation
2015-07-02 16:17:05 +00:00

70 lines
1.9 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?=
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
SNAPSHOT_DATE!= date +-%Y-%m-%d
.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/gcutil)
. 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/gcutil addimage ${GCE_TARGET} \
gs://${GCE_BUCKET}/${GCE_TARGET}.tar.gz
touch ${.OBJDIR}/${.TARGET}