1# 2# $FreeBSD$ 3# 4# 5# Makefile for uploading Microsoft Azure disk images. 6# 7 8AZURE_IMG?= ${.OBJDIR}/azure.vhdf 9AZURE_UPLOAD_TGTS= azure-check-depends \ 10 azure-do-upload 11CLEANFILES+= ${AZURE_UPLOAD_TGTS} 12 13.if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF) 14. for VAR in _STORAGE _ACCOUNT _KEY 15AZURE${VAR}!= grep -E ^AZURE${VAR} ${AZURE_UPLOAD_CONF} | awk -F' ' '{print $$2}' 16. endfor 17.endif 18 19.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" 20SNAPSHOT_DATE!= date +-${BUILDDATE} 21.endif 22 23AZURE_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}.vhd 24 25azure-upload: ${AZURE_UPLOAD_TGTS} 26 27azure-check-depends: 28.for VAR in _STORAGE _ACCOUNT _KEY 29. if !defined(AZURE${VAR}) || empty(AZURE${VAR}) 30 @echo "Variable AZURE${VAR} cannot be empty." 31 @false 32. endif 33.endfor 34.if !exists(/usr/local/bin/azure) 35. if !exists(/usr/local/bin/npm) 36. if !exists(${PORTSDIR}/www/npm/Makefile) 37. if !exists(/usr/local/sbin/pkg-static) 38 env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf 39. endif 40 env ASSUME_ALWAYS_YES=yes pkg install -y www/npm 41. else 42 make -C ${PORTSDIR}/www/npm BATCH=1 all install clean 43. endif 44. endif 45 npm install -g azure-cli 46.endif 47 48azure-do-upload: 49 /usr/local/bin/azure storage blob upload \ 50 ${AZURE_IMG} ${AZURE_STORAGE} ${AZURE_TARGET} \ 51 -t page -a ${AZURE_ACCOUNT} -k "${AZURE_KEY}" 52 touch ${.OBJDIR}/${.TARGET} 53 54