Makefile.azure (63749bfe96b792b3a435f84ad81a47888cae1dea) | Makefile.azure (fbece7609573bd51080e949df03fa3d803a637ae) |
---|---|
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) | 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}' | 14. for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY _LOCATION 15AZURE${VAR}!= grep -E ^AZURE${VAR}= ${AZURE_UPLOAD_CONF} | awk '{print $$2}' |
16. endfor 17.endif 18 19.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" 20SNAPSHOT_DATE!= date +-${BUILDDATE} 21.endif 22 | 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 | 23AZURE_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE} |
24 | 24 |
25START_DATE!= date -v-1d -I -u 26EXPIRY_DATE!= date -v+1m -I -u 27 |
|
25azure-upload: ${AZURE_UPLOAD_TGTS} 26 27azure-check-depends: | 28azure-upload: ${AZURE_UPLOAD_TGTS} 29 30azure-check-depends: |
28.for VAR in _STORAGE _ACCOUNT _KEY | 31.for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY |
29. if !defined(AZURE${VAR}) || empty(AZURE${VAR}) 30 @echo "Variable AZURE${VAR} cannot be empty." 31 @false 32. endif 33.endfor | 32. if !defined(AZURE${VAR}) || empty(AZURE${VAR}) 33 @echo "Variable AZURE${VAR} cannot be empty." 34 @false 35. endif 36.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) | 37.if !exists(/usr/local/bin/az) 38. if !exists(${PORTSDIR}/sysutils/py-azure-cli/Makefile) 39. if !exists(/usr/local/sbin/pkg-static) |
38 env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf | 40 env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf |
39. endif 40 env ASSUME_ALWAYS_YES=yes pkg install -y www/npm 41. else 42 env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/www/npm BATCH=1 all install clean | |
43. endif | 41. endif |
42 env ASSUME_ALWAYS_YES=yes pkg install -y py38-azure-cli 43. else 44 env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/sysutils/py-azure-cli BATCH=1 all install clean |
|
44. endif | 45. endif |
45 npm install -g azure-cli | |
46.endif 47 48azure-do-upload: | 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 | 49 /usr/local/bin/az storage blob upload \ 50 --account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ 51 --container-name ${AZURE_STORAGE} --type page \ 52 --file ${AZURE_IMG} --name ${AZURE_TARGET}.vhd 53 @echo "The disk access URL with shared access signature is:" 54 @echo 55 @echo -n https://${AZURE_ACCOUNT}.blob.core.windows.net/${AZURE_STORAGE}/${AZURE_TARGET}.vhd? 56 @/usr/local/bin/az storage container generate-sas \ 57 --account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ 58 --name ${AZURE_STORAGE} \ 59 --permissions lr \ 60 --start ${START_DATE} \ 61 --expiry ${EXPIRY_DATE} | cut -d '"' -f 2 62 @echo 63 @echo "Please go to Microsoft Partner Center to create a new offer and publish it:" 64 @echo 65 @echo "https://partner.microsoft.com/dashboard/commercial-marketplace/overview" 66 @echo 67 @echo "After the new offer status is live, you can delete the disk file with:" 68 @echo 69 @echo /usr/local/bin/az storage blob delete \ 70 --account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ 71 --container-name ${AZURE_STORAGE} --name ${AZURE_TARGET}.vhd 72 @echo |