summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2015-06-30 00:51:43 +0000
committergjb <gjb@FreeBSD.org>2015-06-30 00:51:43 +0000
commitdc74c25d76650bd202bd7f6677ed03a0667533c4 (patch)
treec9556db6e25e1a06d2244ddbcf24259efae3289d
parente2ee19fb343144f313626dc9c6572640ab0133be (diff)
downloadFreeBSD-src-dc74c25d76650bd202bd7f6677ed03a0667533c4.zip
FreeBSD-src-dc74c25d76650bd202bd7f6677ed03a0667533c4.tar.gz
MFC r284882, r284884:
r284882: Add initial support for automatically uploading GCE virtual machine images to the Google Compute Engine platform. Remove gce-package.sh. r284884: Fix a vi-invoked typo. Sponsored by: The FreeBSD Foundation
-rw-r--r--release/Makefile.gce69
-rw-r--r--release/Makefile.vm1
-rwxr-xr-xrelease/tools/gce-package.sh47
3 files changed, 70 insertions, 47 deletions
diff --git a/release/Makefile.gce b/release/Makefile.gce
new file mode 100644
index 0000000..e1a91a7
--- /dev/null
+++ b/release/Makefile.gce
@@ -0,0 +1,69 @@
+#
+# $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-%H-%M
+.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-api/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-api
+. else
+ make -C ${PORTSDIR}/net/google-cloud-api 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}
+
diff --git a/release/Makefile.vm b/release/Makefile.vm
index 68fb2f3..8a8d69f 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -155,3 +155,4 @@ cloudware-install:
.include "${.CURDIR}/Makefile.ec2"
.include "${.CURDIR}/Makefile.azure"
+.include "${.CURDIR}/Makefile.gce"
diff --git a/release/tools/gce-package.sh b/release/tools/gce-package.sh
deleted file mode 100755
index 5d8ec33..0000000
--- a/release/tools/gce-package.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-# Script to handle packaging cloud images for GCE.
-#
-# XXX:
-# This script only exists to help in automating image creation,
-# and reimplementing this is intended (in other words, this is
-# temporary).
-
-usage() {
- echo "Usage:"
- echo "$(basename ${0}) -D <destdir> -I <input_file> -S <src_tree>"
- exit 1
-}
-
-main() {
- while getopts "D:I:W:" opt; do
- case ${opt} in
- D)
- DESTDIR="${OPTARG}"
- ;;
- I)
- INFILE="${OPTARG}"
- ;;
- S)
- WORLDDIR="${OPTARG}"
- ;;
- *)
- usage
- ;;
- esac
- done
- shift $(( ${OPTIND} - 1 ))
-
- if [ -z "${DESTDIR}" -o -z "${INFILE}" -o -z "${WORLDDIR}" ]; then
- usage
- fi
-
- OUTFILE="$(make -C ${WORLDDIR}/release -V OSRELEASE).tar.gz"
-
- cd ${DESTDIR} && tar --format=gnutar -zcf ${OUTFILE} ${INFILE}
-}
-
-main "$@"
OpenPOWER on IntegriCloud