1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-01 08:27:59 +00:00
freebsd/release/Makefile.azure
Colin Percival 6c87aed39c release: Support r/o /usr/ports for cloudware
Set WRKDIRPREFIX=/tmp/ports DISTDIR=/tmp/distfiles when building tools
needed for uploading cloudware images.

While I'm here, adjust the bsdec2-image-upload build target to match
the style used by the Azure/GCE/Vagrant Makefiles.

MFC after:	3 days
2024-04-12 10:58:09 -07:00

78 lines
2.4 KiB
Makefile

#
#
#
# Makefile for uploading Microsoft Azure disk images.
#
AZURE_UPLOAD_TGTS= azure-check-depends \
azure-do-upload
CLEANFILES+= ${AZURE_UPLOAD_TGTS}
.if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF)
. for VAR in _STORAGE _ACCOUNT _KEY
AZURE${VAR}!= grep -E '^AZURE${VAR}' ${AZURE_UPLOAD_CONF} | awk -F ' ' '{print $$2}'
. endfor
.endif
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
SNAPSHOT_DATE!= date +-${BUILDDATE}
.endif
START_DATE!= date -v-1d -I -u
EXPIRY_DATE!= date -v+1m -I -u
azure-upload: ${AZURE_UPLOAD_TGTS}
azure-check-depends:
.for VAR in _STORAGE _ACCOUNT _KEY
. if !defined(AZURE${VAR}) || empty(AZURE${VAR})
@echo "Variable AZURE${VAR} cannot be empty."
@false
. endif
.endfor
.if !exists(/usr/local/bin/az)
. if !exists(${PORTSDIR}/sysutils/py-azure-cli/Makefile)
. if !exists(/usr/local/sbin/pkg-static)
env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
. endif
env ASSUME_ALWAYS_YES=yes pkg install -y sysutils/py-azure-cli
. else
env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/sysutils/py-azure-cli \
BATCH=1 WRKDIRPREFIX=/tmp/ports DISTDIR=/tmp/distfiles \
all install clean
. endif
.endif
.for _FS in ${AZURE_FSLIST}
AZURE_IMG_${_FS}= ${.OBJDIR}/azure.${_FS}.vhdf
AZURE_TARGET_${_FS}= ${OSRELEASE}-${_FS}${SNAPSHOT_DATE}
azure-do-upload-${_FS}:
/usr/local/bin/az storage blob upload \
--account-name ${AZURE_ACCOUNT} --account-key ${AZURE_KEY} \
--container-name ${AZURE_STORAGE} --type page \
--file ${AZURE_IMG_${_FS}} --name ${AZURE_TARGET_${_FS}}.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_${_FS}}.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_${_FS}}.vhd
@echo
.endfor
azure-do-upload: azure-do-upload-${VMFS}