2015-06-18 19:20:00 +00:00
|
|
|
#
|
|
|
|
# $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)
|
2021-10-01 20:59:10 +00:00
|
|
|
. for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY _LOCATION
|
2021-10-13 20:39:10 +00:00
|
|
|
AZURE${VAR}!= grep -E '^AZURE${VAR}' ${AZURE_UPLOAD_CONF} | awk -F ' ' '{print $$2}'
|
2015-06-18 19:20:00 +00:00
|
|
|
. endfor
|
|
|
|
.endif
|
|
|
|
|
2015-06-25 13:40:00 +00:00
|
|
|
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
|
2020-08-12 16:25:25 +00:00
|
|
|
SNAPSHOT_DATE!= date +-${BUILDDATE}
|
2015-06-18 19:20:00 +00:00
|
|
|
.endif
|
|
|
|
|
2021-10-01 20:59:10 +00:00
|
|
|
AZURE_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}
|
|
|
|
|
|
|
|
START_DATE!= date -v-1d -I -u
|
|
|
|
EXPIRY_DATE!= date -v+1m -I -u
|
2015-06-18 19:20:00 +00:00
|
|
|
|
|
|
|
azure-upload: ${AZURE_UPLOAD_TGTS}
|
|
|
|
|
|
|
|
azure-check-depends:
|
2021-10-01 20:59:10 +00:00
|
|
|
.for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY
|
2015-06-18 19:20:00 +00:00
|
|
|
. if !defined(AZURE${VAR}) || empty(AZURE${VAR})
|
|
|
|
@echo "Variable AZURE${VAR} cannot be empty."
|
|
|
|
@false
|
|
|
|
. endif
|
|
|
|
.endfor
|
2021-10-01 20:59:10 +00:00
|
|
|
.if !exists(/usr/local/bin/az)
|
|
|
|
. if !exists(${PORTSDIR}/sysutils/py-azure-cli/Makefile)
|
|
|
|
. if !exists(/usr/local/sbin/pkg-static)
|
2015-06-18 19:20:00 +00:00
|
|
|
env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
|
|
|
|
. endif
|
2021-10-01 20:59:10 +00:00
|
|
|
env ASSUME_ALWAYS_YES=yes pkg install -y py38-azure-cli
|
|
|
|
. else
|
|
|
|
env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/sysutils/py-azure-cli BATCH=1 all install clean
|
2015-06-18 19:20:00 +00:00
|
|
|
. endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
azure-do-upload:
|
2021-10-01 20:59:10 +00:00
|
|
|
/usr/local/bin/az storage blob upload \
|
|
|
|
--account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \
|
|
|
|
--container-name ${AZURE_STORAGE} --type page \
|
|
|
|
--file ${AZURE_IMG} --name ${AZURE_TARGET}.vhd
|
|
|
|
@echo "The disk access URL with shared access signature is:"
|
|
|
|
@echo
|
|
|
|
@echo -n https://${AZURE_ACCOUNT}.blob.core.windows.net/${AZURE_STORAGE}/${AZURE_TARGET}.vhd?
|
|
|
|
@/usr/local/bin/az storage container generate-sas \
|
|
|
|
--account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \
|
|
|
|
--name ${AZURE_STORAGE} \
|
|
|
|
--permissions lr \
|
|
|
|
--start ${START_DATE} \
|
|
|
|
--expiry ${EXPIRY_DATE} | cut -d '"' -f 2
|
|
|
|
@echo
|
|
|
|
@echo "Please go to Microsoft Partner Center to create a new offer and publish it:"
|
|
|
|
@echo
|
|
|
|
@echo "https://partner.microsoft.com/dashboard/commercial-marketplace/overview"
|
|
|
|
@echo
|
|
|
|
@echo "After the new offer status is live, you can delete the disk file with:"
|
|
|
|
@echo
|
|
|
|
@echo /usr/local/bin/az storage blob delete \
|
|
|
|
--account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \
|
|
|
|
--container-name ${AZURE_STORAGE} --name ${AZURE_TARGET}.vhd
|
|
|
|
@echo
|