Changeset View
Changeset View
Standalone View
Standalone View
release/Makefile.azure
# | # | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
# | # | ||||
# | # | ||||
# Makefile for uploading Microsoft Azure disk images. | # Makefile for uploading Microsoft Azure disk images. | ||||
# | # | ||||
AZURE_IMG?= ${.OBJDIR}/azure.vhdf | AZURE_IMG?= ${.OBJDIR}/azure.vhdf | ||||
AZURE_UPLOAD_TGTS= azure-check-depends \ | AZURE_UPLOAD_TGTS= azure-check-depends \ | ||||
azure-do-upload | azure-do-upload | ||||
# we do not yet have a better way to deal with the "must be run interactively" | |||||
# thing, so this is a fail-safe "do not do anything." | |||||
.if !defined(AZURE_LOGIN_SKIP) || empty(AZURE_LOGIN_SKIP) | |||||
AZURE_UPLOAD_TGTS= azure-do-login | |||||
.endif | |||||
gjb: How does it get run automatically, then? Is there a .config directory or similar that can be… | |||||
Done Inline ActionsYes, after doing az login (see target azure-do-login) the credential will be stored in ~/.azure This is learnt from Makefile.gce, please let me know if there is a preferable way. lwhsu: Yes, after doing `az login` (see target `azure-do-login`) the credential will be stored in `~/. | |||||
Not Done Inline ActionsOK, thanks. (Note, I have not yet reviewed the rest of this. I plan to do so today.) gjb: OK, thanks. (Note, I have not yet reviewed the rest of this. I plan to do so today.) | |||||
CLEANFILES+= ${AZURE_UPLOAD_TGTS} | CLEANFILES+= ${AZURE_UPLOAD_TGTS} | ||||
.if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF) | .if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF) | ||||
. for VAR in _STORAGE _ACCOUNT _KEY | . for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY | ||||
AZURE${VAR}!= grep -E ^AZURE${VAR} ${AZURE_UPLOAD_CONF} | awk -F' ' '{print $$2}' | AZURE${VAR}!= grep -E ^AZURE${VAR} ${AZURE_UPLOAD_CONF} | awk -F' ' '{print $$2}' | ||||
. endfor | . endfor | ||||
.endif | .endif | ||||
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" | .if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" | ||||
SNAPSHOT_DATE!= date +-%Y-%m-%d | SNAPSHOT_DATE!= date +-%Y-%m-%d | ||||
.endif | .endif | ||||
AZURE_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}.vhd | AZURE_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE} | ||||
START_DATE!= date -v-1d -I -u | |||||
EXPIRY_DATE!= date -v+1m -I -u | |||||
azure-upload: ${AZURE_UPLOAD_TGTS} | azure-upload: ${AZURE_UPLOAD_TGTS} | ||||
azure-check-depends: | azure-check-depends: | ||||
.for VAR in _STORAGE _ACCOUNT _KEY | .for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY | ||||
. if !defined(AZURE${VAR}) || empty(AZURE${VAR}) | . if !defined(AZURE${VAR}) || empty(AZURE${VAR}) | ||||
@echo "Variable AZURE${VAR} cannot be empty." | @echo "Variable AZURE${VAR} cannot be empty." | ||||
@false | @false | ||||
. endif | . endif | ||||
.endfor | .endfor | ||||
.if !exists(/usr/local/bin/azure) | .if !exists(/usr/local/bin/az) | ||||
. if !exists(/usr/local/bin/npm) | . if !exists(${PORTSDIR}/sysutils/py-azure-cli/Makefile) | ||||
. if !exists(${PORTSDIR}/www/npm/Makefile) | |||||
. if !exists(/usr/local/sbin/pkg-static) | . if !exists(/usr/local/sbin/pkg-static) | ||||
env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf | env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf | ||||
. endif | . endif | ||||
env ASSUME_ALWAYS_YES=yes pkg install -y www/npm | env ASSUME_ALWAYS_YES=yes pkg install -y py37-azure-cli | ||||
. else | . else | ||||
make -C ${PORTSDIR}/www/npm BATCH=1 all install clean | make -C ${PORTSDIR}/sysutils/py-azure-cli BATCH=1 all install clean | ||||
. endif | . endif | ||||
. endif | .endif | ||||
npm install -g azure-cli | |||||
.endif | |||||
azure-do-login: | |||||
@echo "This requires human interaction, which is not yet supported." | |||||
@echo "Please run \`az login\` manually." | |||||
@true | |||||
azure-do-upload: | azure-do-upload: | ||||
/usr/local/bin/azure storage blob upload \ | /usr/local/bin/az storage blob upload \ | ||||
${AZURE_IMG} ${AZURE_STORAGE} ${AZURE_TARGET} \ | --account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ | ||||
-t page -a ${AZURE_ACCOUNT} -k "${AZURE_KEY}" | --container-name ${AZURE_STORAGE} --type page \ | ||||
--file ${AZURE_IMG} --name ${AZURE_TARGET}.vhd | |||||
/usr/local/bin/az image create \ | |||||
--resource-group ${AZURE_RESOURCEGROUP} --name ${AZURE_TARGET} \ | |||||
--os-type Linux \ | |||||
--source https://${AZURE_ACCOUNT}.blob.core.windows.net/${AZURE_STORAGE}/${AZURE_TARGET}.vhd | |||||
@echo "The image access url with shared access signature is:" | |||||
@/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} | |||||
@echo "Please go to Microsoft Partner Center to create a new SKU and publish:" | |||||
@echo "https://partner.microsoft.com/dashboard/commercial-marketplace/overview" | |||||
@echo "After the new SKU goes live, you can delete the private image file with:" | |||||
@echo /usr/local/bin/az storage blob delete \ | |||||
--account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \ | |||||
--container-name ${AZURE_STORAGE} --name ${AZURE_TARGET}.vhd | |||||
touch ${.OBJDIR}/${.TARGET} | touch ${.OBJDIR}/${.TARGET} | ||||
How does it get run automatically, then? Is there a .config directory or similar that can be extracted into the build chroot environment?