1# 2# 3# 4# Makefile for uploading Microsoft Azure disk images. 5# 6 7AZURE_UPLOAD_TGTS= azure-check-depends \ 8 azure-do-upload 9CLEANFILES+= ${AZURE_UPLOAD_TGTS} 10 11.if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF) 12. for VAR in _STORAGE _ACCOUNT _KEY 13AZURE${VAR}!= grep -E '^AZURE${VAR}' ${AZURE_UPLOAD_CONF} | awk -F ' ' '{print $$2}' 14. endfor 15.endif 16 17.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" 18SNAPSHOT_DATE!= date +-${BUILDDATE} 19.endif 20 21START_DATE!= date -v-1d -I -u 22EXPIRY_DATE!= date -v+1m -I -u 23 24azure-upload: ${AZURE_UPLOAD_TGTS} 25 26azure-check-depends: 27.for VAR in _STORAGE _ACCOUNT _KEY 28. if !defined(AZURE${VAR}) || empty(AZURE${VAR}) 29 @echo "Variable AZURE${VAR} cannot be empty." 30 @false 31. endif 32.endfor 33.if !exists(/usr/local/bin/az) 34. if !exists(${PORTSDIR}/sysutils/py-azure-cli/Makefile) 35. if !exists(/usr/local/sbin/pkg-static) 36 env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf 37. endif 38 env ASSUME_ALWAYS_YES=yes pkg install -y sysutils/py-azure-cli 39. else 40 env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/sysutils/py-azure-cli BATCH=1 all install clean 41. endif 42.endif 43 44.for _FS in ${AZURE_FSLIST} 45AZURE_IMG_${_FS}= ${.OBJDIR}/azure.${_FS}.vhdf 46AZURE_TARGET_${_FS}= ${OSRELEASE}-${_FS}${SNAPSHOT_DATE} 47 48azure-do-upload-${_FS}: 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_${_FS}} --name ${AZURE_TARGET_${_FS}}.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_${_FS}}.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_${_FS}}.vhd 72 @echo 73.endfor 74 75azure-do-upload: azure-do-upload-${VMFS} 76