]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/Makefile.gce
MFC: Remove confDH_PARAMETERS settings in favor of using sendmail's
[FreeBSD/FreeBSD.git] / release / Makefile.gce
1 #
2 #
3 #
4 # Makefile for uploading Google Compute Engine disk images.
5 #
6
7 GCE_IMG?=               ${.OBJDIR}/gce.raw
8 GCE_UPLOAD_TGTS=        gce-check-depends \
9                         gce-do-package \
10                         gce-do-upload
11 # I do not yet have a better way to deal with the "must be run interactively"
12 # thing, so this is a fail-safe "do not do anything."
13 .if !defined(GCE_LOGIN_SKIP) || empty(GCE_LOGIN_SKIP)
14 GCE_UPLOAD_TGTS=        gce-do-login
15 .endif
16 CLEANFILES+=            ${GCE_UPLOAD_TGTS}
17
18 GCE_BUCKET?=
19 GCE_LICENSE?=
20
21 .if !defined(GCE_FAMILY) || empty(GCE_FAMILY)
22 GCE_FAMILY=             ${TYPE:tl}-${REVISION:S,.,-,}
23 .endif
24
25 .if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
26 SNAPSHOT_DATE=          -v${BUILDDATE}
27 GCE_FAMILY_SUFX=        -snap
28 .endif
29
30 # Really?  Uppercase characters are not allowed?  Sigh...
31 # And don't even get me started on the '.'.
32 GCE_TARGET:=            ${OSRELEASE:S,.raw,,:tl:S,.,-,g}${SNAPSHOT_DATE}
33
34 gce-upload:             ${GCE_UPLOAD_TGTS}
35
36 gce-check-depends:
37 .for VAR in _BUCKET
38 . if !defined(GCE${VAR}) || empty(GCE${VAR})
39         @echo "Variable GCE${VAR} cannot be empty."
40         @false
41 . endif
42 .endfor
43 .if !exists(/usr/local/bin/gcloud)
44 . if !exists(${PORTSDIR}/net/google-cloud-sdk/Makefile)
45 .  if !exists(/usr/local/sbin/pkg-static)
46         env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
47 .  endif
48         env ASSUME_ALWAYS_YES=yes pkg install -y net/google-cloud-sdk \
49                 lang/python
50 . else
51         env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/net/google-cloud-sdk BATCH=1 all install clean
52         env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/lang/python BATCH=1 all install clean
53 . endif
54 .endif
55
56 gce-do-package:
57         @# Yes, really...  Sigh.
58         cd ${.OBJDIR} && mv gce.raw disk.raw
59         cd ${.OBJDIR} && tar --format=gnutar -zcf \
60                 ${GCE_TARGET:S,${.OBJDIR}/,,}.tar.gz disk.raw
61         cd ${.OBJDIR} && mv disk.raw gce.raw
62         touch ${.OBJDIR}/${.TARGET}
63
64 gce-do-login:
65         @echo "This requires human interaction, which is not yet supported."
66         @true
67
68 gce-do-upload:
69         @# Fallthrough in case the bucket already exists.
70         /usr/local/bin/gsutil mb gs://${GCE_BUCKET} || true
71         /usr/local/bin/gsutil cp ${.OBJDIR}/${GCE_TARGET}.tar.gz \
72                 gs://${GCE_BUCKET}/
73         /usr/local/bin/gcloud compute images create ${GCE_TARGET} \
74                 --family=${GCE_FAMILY}${GCE_FAMILY_SUFX} ${GCE_LICENSE} \
75                 --source-uri gs://${GCE_BUCKET}/${GCE_TARGET}.tar.gz
76         touch ${.OBJDIR}/${.TARGET}
77