1873fc703SGlen Barber# 2873fc703SGlen Barber# 3873fc703SGlen Barber# 4873fc703SGlen Barber# Makefile for uploading Microsoft Azure disk images. 5873fc703SGlen Barber# 6873fc703SGlen Barber 7873fc703SGlen BarberAZURE_UPLOAD_TGTS= azure-check-depends \ 8873fc703SGlen Barber azure-do-upload 9873fc703SGlen BarberCLEANFILES+= ${AZURE_UPLOAD_TGTS} 10873fc703SGlen Barber 11873fc703SGlen Barber.if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF) 129c0287e0SLi-Wen Hsu. for VAR in _STORAGE _ACCOUNT _KEY 13083f6d0eSGlen BarberAZURE${VAR}!= grep -E '^AZURE${VAR}' ${AZURE_UPLOAD_CONF} | awk -F ' ' '{print $$2}' 14873fc703SGlen Barber. endfor 15873fc703SGlen Barber.endif 16873fc703SGlen Barber 173c3445e8SGlen Barber.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" 1886e5b137SGlen BarberSNAPSHOT_DATE!= date +-${BUILDDATE} 19873fc703SGlen Barber.endif 20873fc703SGlen Barber 21fbece760SLi-Wen HsuSTART_DATE!= date -v-1d -I -u 22fbece760SLi-Wen HsuEXPIRY_DATE!= date -v+1m -I -u 23873fc703SGlen Barber 24873fc703SGlen Barberazure-upload: ${AZURE_UPLOAD_TGTS} 25873fc703SGlen Barber 26873fc703SGlen Barberazure-check-depends: 279c0287e0SLi-Wen Hsu.for VAR in _STORAGE _ACCOUNT _KEY 28873fc703SGlen Barber. if !defined(AZURE${VAR}) || empty(AZURE${VAR}) 29873fc703SGlen Barber @echo "Variable AZURE${VAR} cannot be empty." 30873fc703SGlen Barber @false 31873fc703SGlen Barber. endif 32873fc703SGlen Barber.endfor 33fbece760SLi-Wen Hsu.if !exists(/usr/local/bin/az) 34fbece760SLi-Wen Hsu. if !exists(${PORTSDIR}/sysutils/py-azure-cli/Makefile) 35873fc703SGlen Barber. if !exists(/usr/local/sbin/pkg-static) 36873fc703SGlen Barber env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf 37873fc703SGlen Barber. endif 380fe6998dSLi-Wen Hsu env ASSUME_ALWAYS_YES=yes pkg install -y sysutils/py-azure-cli 39873fc703SGlen Barber. else 40*6c87aed3SColin Percival env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/sysutils/py-azure-cli \ 41*6c87aed3SColin Percival BATCH=1 WRKDIRPREFIX=/tmp/ports DISTDIR=/tmp/distfiles \ 42*6c87aed3SColin Percival all install clean 43873fc703SGlen Barber. endif 44873fc703SGlen Barber.endif 45873fc703SGlen Barber 4678f901dcSLi-Wen Hsu.for _FS in ${AZURE_FSLIST} 4778f901dcSLi-Wen HsuAZURE_IMG_${_FS}= ${.OBJDIR}/azure.${_FS}.vhdf 4878f901dcSLi-Wen HsuAZURE_TARGET_${_FS}= ${OSRELEASE}-${_FS}${SNAPSHOT_DATE} 4978f901dcSLi-Wen Hsu 5078f901dcSLi-Wen Hsuazure-do-upload-${_FS}: 51fbece760SLi-Wen Hsu /usr/local/bin/az storage blob upload \ 52fbece760SLi-Wen Hsu --account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ 53fbece760SLi-Wen Hsu --container-name ${AZURE_STORAGE} --type page \ 5478f901dcSLi-Wen Hsu --file ${AZURE_IMG_${_FS}} --name ${AZURE_TARGET_${_FS}}.vhd 55fbece760SLi-Wen Hsu @echo "The disk access URL with shared access signature is:" 56fbece760SLi-Wen Hsu @echo 5778f901dcSLi-Wen Hsu @echo -n https://${AZURE_ACCOUNT}.blob.core.windows.net/${AZURE_STORAGE}/${AZURE_TARGET_${_FS}}.vhd? 58fbece760SLi-Wen Hsu @/usr/local/bin/az storage container generate-sas \ 59fbece760SLi-Wen Hsu --account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ 60fbece760SLi-Wen Hsu --name ${AZURE_STORAGE} \ 61fbece760SLi-Wen Hsu --permissions lr \ 62fbece760SLi-Wen Hsu --start ${START_DATE} \ 63fbece760SLi-Wen Hsu --expiry ${EXPIRY_DATE} | cut -d '"' -f 2 64fbece760SLi-Wen Hsu @echo 65fbece760SLi-Wen Hsu @echo "Please go to Microsoft Partner Center to create a new offer and publish it:" 66fbece760SLi-Wen Hsu @echo 67fbece760SLi-Wen Hsu @echo "https://partner.microsoft.com/dashboard/commercial-marketplace/overview" 68fbece760SLi-Wen Hsu @echo 69fbece760SLi-Wen Hsu @echo "After the new offer status is live, you can delete the disk file with:" 70fbece760SLi-Wen Hsu @echo 71fbece760SLi-Wen Hsu @echo /usr/local/bin/az storage blob delete \ 72fbece760SLi-Wen Hsu --account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ 7378f901dcSLi-Wen Hsu --container-name ${AZURE_STORAGE} --name ${AZURE_TARGET_${_FS}}.vhd 74fbece760SLi-Wen Hsu @echo 7578f901dcSLi-Wen Hsu.endfor 7678f901dcSLi-Wen Hsu 7778f901dcSLi-Wen Hsuazure-do-upload: azure-do-upload-${VMFS} 78