From owner-svn-src-head@freebsd.org Sat Jun 27 01:30:00 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A039D98C006; Sat, 27 Jun 2015 01:30:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 910C710F7; Sat, 27 Jun 2015 01:30:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5R1U0jg003734; Sat, 27 Jun 2015 01:30:00 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5R1U0lr003717; Sat, 27 Jun 2015 01:30:00 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201506270130.t5R1U0lr003717@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Sat, 27 Jun 2015 01:30:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284882 - in head/release: . tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jun 2015 01:30:00 -0000 Author: gjb Date: Sat Jun 27 01:29:59 2015 New Revision: 284882 URL: https://svnweb.freebsd.org/changeset/base/284882 Log: Add initial support for automatically uploading GCE virtual machine images to the Google Compute Engine platform. By default, gcutil/gsutil requires an Oauth2 login generated from a URL that must be opened in a browser, a verification code copied back to the terminal from which it was invoked, etc., etc., making it near impossible for automation. I've hacked together an evil solution to work around this, so unless GCE_LOGIN_SKIP is set to a non-empty value, this Makefile will not do anything useful. As a result of this commit, remove the gce-package.sh script that was never, nor will ever be, used. MFC after: 3 days X-MFC-Note: (hopefully) Sponsored by: The FreeBSD Foundation Added: head/release/Makefile.gce (contents, props changed) Deleted: head/release/tools/gce-package.sh Modified: head/release/Makefile.vm Added: head/release/Makefile.gce ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/release/Makefile.gce Sat Jun 27 01:29:59 2015 (r284882) @@ -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 !execho ists(${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} + Modified: head/release/Makefile.vm ============================================================================== --- head/release/Makefile.vm Fri Jun 26 23:55:02 2015 (r284881) +++ head/release/Makefile.vm Sat Jun 27 01:29:59 2015 (r284882) @@ -155,3 +155,4 @@ cloudware-install: .include "${.CURDIR}/Makefile.ec2" .include "${.CURDIR}/Makefile.azure" +.include "${.CURDIR}/Makefile.gce"