aboutsummaryrefslogtreecommitdiff
path: root/release/Makefile.azure
diff options
context:
space:
mode:
authorGlen Barber <gjb@FreeBSD.org>2015-06-18 19:20:00 +0000
committerGlen Barber <gjb@FreeBSD.org>2015-06-18 19:20:00 +0000
commit873fc7038251d0f8c097dbe1cec931d5a0df2166 (patch)
treef600a9327429dc11def443cd254262410176f9c4 /release/Makefile.azure
parentefb5228ce87158dda1e50d20c9179ac7fb6d9f48 (diff)
downloadsrc-873fc7038251d0f8c097dbe1cec931d5a0df2166.tar.gz
src-873fc7038251d0f8c097dbe1cec931d5a0df2166.zip
Add Makefile.azure, used to upload VHD images to the
Microsoft Azure environment, similar to the EC2 AMIs. MFC after: 3 days Tested with: stable/10@r284517 (patched) Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=284567
Diffstat (limited to 'release/Makefile.azure')
-rw-r--r--release/Makefile.azure53
1 files changed, 53 insertions, 0 deletions
diff --git a/release/Makefile.azure b/release/Makefile.azure
new file mode 100644
index 000000000000..01e2204d08f4
--- /dev/null
+++ b/release/Makefile.azure
@@ -0,0 +1,53 @@
+#
+# $FreeBSD$
+#
+#
+# Makefile for uploading Microsoft Azure disk images.
+#
+
+AZURE_IMG?= ${.OBJDIR}/azure.vhdf
+AZURE_UPLOAD_TGTS= azure-check-depends \
+ azure-do-upload
+CLEANFILES+= ${AZURE_UPLOAD_TGTS}
+
+.if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF)
+. for VAR in _STORAGE _ACCOUNT _KEY
+AZURE${VAR}!= grep -E ^AZURE${VAR} ${AZURE_UPLOAD_CONF} | awk -F' ' '{print $$2}'
+. endfor
+.endif
+
+.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT"
+SNAPSHOT_DATE!= date +-%Y-%m-%d
+.endif
+
+AZURE_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}.vhd
+
+azure-upload: ${AZURE_UPLOAD_TGTS}
+
+azure-check-depends:
+.for VAR in _STORAGE _ACCOUNT _KEY
+. if !defined(AZURE${VAR}) || empty(AZURE${VAR})
+ @echo "Variable AZURE${VAR} cannot be empty."
+ @false
+. endif
+.endfor
+.if !exists(/usr/local/bin/azure)
+. if !exists(/usr/local/bin/npm)
+. if !exists(${PORTSDIR}/www/npm/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 www/npm
+. else
+ make -C ${PORTSDIR}/www/npm BATCH=1 all install clean
+. endif
+. endif
+ npm install -g azure-cli
+.endif
+
+azure-do-upload:
+ /usr/local/bin/azure storage blob upload \
+ ${AZURE_IMG} ${AZURE_STORAGE} ${AZURE_TARGET} \
+ -t page -a ${AZURE_ACCOUNT} -k "${AZURE_KEY}"
+ touch ${.OBJDIR}/${.TARGET}
+