2015-06-27 22:39:13 +02:00
|
|
|
#
|
|
|
|
#
|
2017-02-01 17:15:23 +01:00
|
|
|
# Makefile for producing and uploading Vagrant boxes to Hashicorp Atlas
|
2015-06-27 22:39:13 +02:00
|
|
|
#
|
2017-02-01 17:15:23 +01:00
|
|
|
# Usage Example:
|
|
|
|
# Create a Vagrant image for VirtualBox:
|
|
|
|
# make vagrant-box WITH_VMIMAGES=y WITH_CLOUDWARE=y \
|
|
|
|
# CLOUDWARE=vagrant-virtualbox VMFORMATS=vmdk
|
|
|
|
#
|
|
|
|
# To create a Vagrant image for VMWare and Upload it to Atlas:
|
|
|
|
# VAGRANT_KEY is your Atlas API Token
|
|
|
|
# VAGRANT_USERNAME is your Atlas Username
|
|
|
|
# env VAGRANT_KEY=foo VAGRANT_USERNAME=bar make vagrant-upload \
|
|
|
|
# WITH_VMIMAGES=y WITH_CLOUDWARE=y CLOUDWARE=vagrant-vmware \
|
|
|
|
# VMFORMATS=vmdk
|
|
|
|
# For more info: https://www.vagrantup.com/docs/other/atlas.html
|
2015-06-27 22:39:13 +02:00
|
|
|
#
|
|
|
|
|
2015-06-28 00:54:16 +02:00
|
|
|
VAGRANT_IMG?= ${.OBJDIR}/vagrant.vmdk
|
2015-07-20 18:27:44 +02:00
|
|
|
VAGRANT_UPLOAD_TGTS= vagrant-check-depends
|
2015-06-27 22:39:13 +02:00
|
|
|
CLEANFILES+= ${VAGRANT_UPLOAD_TGTS}
|
|
|
|
|
|
|
|
.if defined(VAGRANT_UPLOAD_CONF) && !empty(VAGRANT_UPLOAD_CONF)
|
2015-06-30 21:18:08 +02:00
|
|
|
. for VAR in _KEY _USERNAME
|
2015-06-28 00:59:29 +02:00
|
|
|
VAGRANT${VAR}!= grep -E ^VAGRANT${VAR} ${VAGRANT_UPLOAD_CONF} | awk -F' ' '{print $$2}'
|
|
|
|
ATLAS${VAR}:= ${VAGRANT${VAR}}
|
2015-06-27 22:39:13 +02:00
|
|
|
. endfor
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
|
2020-08-12 18:30:33 +02:00
|
|
|
SNAPSHOT_DATE!= date +-${BUILDDATE}
|
2015-06-27 22:39:13 +02:00
|
|
|
.endif
|
|
|
|
|
2015-07-20 18:27:44 +02:00
|
|
|
VAGRANT_VERSION!= date +%Y.%m.%d
|
2015-09-01 17:28:35 +02:00
|
|
|
VAGRANT_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}
|
2015-07-20 18:27:44 +02:00
|
|
|
.if !empty(CLOUDWARE)
|
|
|
|
. for _PROVIDER in ${CLOUDWARE}
|
2017-01-31 22:59:10 +01:00
|
|
|
. if ${_PROVIDER:tu:MVAGRANT*}
|
|
|
|
VAGRANT_PROVIDERS+= ${_PROVIDER:tu:S/VAGRANT-//:tl}
|
2015-07-20 18:27:44 +02:00
|
|
|
. endif
|
|
|
|
. endfor
|
|
|
|
.endif
|
|
|
|
VAGRANT_PROVIDERS?= vmware virtualbox
|
2015-06-27 22:39:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
vagrant-check-depends:
|
2015-06-29 23:26:41 +02:00
|
|
|
.for VAR in _KEY _USERNAME _VERSION
|
2015-06-27 22:39:13 +02:00
|
|
|
. if !defined(VAGRANT${VAR}) || empty(VAGRANT${VAR})
|
|
|
|
@echo "Variable VAGRANT${VAR} cannot be empty."
|
|
|
|
@false
|
|
|
|
. endif
|
|
|
|
.endfor
|
|
|
|
.if !exists(/usr/local/bin/curl)
|
|
|
|
. if !exists(${PORTSDIR}/ftp/curl/Makefile)
|
|
|
|
. if !exists(/usr/local/sbin/pkg-static)
|
|
|
|
env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
|
|
|
|
. endif
|
2015-06-29 23:26:41 +02:00
|
|
|
env ASSUME_ALWAYS_YES=yes pkg install -y curl
|
2015-06-27 22:39:13 +02:00
|
|
|
. else
|
2024-04-12 19:20:25 +02:00
|
|
|
env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/ftp/curl \
|
|
|
|
BATCH=1 WRKDIRPREFIX=/tmp/ports DISTDIR=/tmp/distfiles \
|
|
|
|
all install clean
|
2015-06-27 22:39:13 +02:00
|
|
|
. endif
|
|
|
|
.endif
|
|
|
|
|
2015-07-20 18:27:44 +02:00
|
|
|
.for PROVIDER in ${VAGRANT_PROVIDERS}
|
|
|
|
CLEANFILES+= vagrant-do-package-${PROVIDER} ${VAGRANT_TARGET}.${PROVIDER}.box
|
|
|
|
CLEANDIRS+= ${PROVIDER}
|
|
|
|
VAGRANT_UPLOAD_TGTS+= vagrant-do-upload-${PROVIDER}
|
2015-06-27 22:39:13 +02:00
|
|
|
|
2015-07-20 18:27:44 +02:00
|
|
|
${PROVIDER}:
|
|
|
|
@mkdir -p ${PROVIDER}
|
2015-06-27 22:39:13 +02:00
|
|
|
|
2015-07-20 18:27:44 +02:00
|
|
|
${VAGRANT_TARGET}.${PROVIDER}.box: ${PROVIDER} cw-vagrant-${PROVIDER} vagrant-create-${PROVIDER}-metadata
|
|
|
|
@echo "==> PACKAGING: ${VAGRANT_TARGET}.${PROVIDER}.box in `pwd`"
|
|
|
|
@cp vagrant-${PROVIDER}.vmdk ${PROVIDER}/vagrant.vmdk
|
|
|
|
. if ${PROVIDER} == "virtualbox"
|
|
|
|
@(cd ${.OBJDIR}/${PROVIDER} && echo '{"provider":"${PROVIDER}"}' > metadata.json)
|
|
|
|
@(cd ${.OBJDIR}/${PROVIDER} && tar -czf ../${VAGRANT_TARGET}.${PROVIDER}.box metadata.json box.ovf vagrant.vmdk)
|
|
|
|
. elif ${PROVIDER} == "vmware"
|
|
|
|
@(cd ${.OBJDIR}/${PROVIDER} && echo '{"provider":"${PROVIDER}_desktop"}' > metadata.json)
|
|
|
|
@(cd ${.OBJDIR}/${PROVIDER} && tar -czf ../${VAGRANT_TARGET}.${PROVIDER}.box metadata.json vagrant.vmx vagrant.vmdk)
|
|
|
|
. endif
|
|
|
|
|
|
|
|
CLEANFILES+= vagrant-do-upload-${PROVIDER}
|
2017-01-31 22:59:10 +01:00
|
|
|
vagrant-do-upload-${PROVIDER}: vagrant-box
|
2015-07-20 18:27:44 +02:00
|
|
|
. if ${PROVIDER} == "virtualbox"
|
|
|
|
${.CURDIR}/scripts/atlas-upload.sh -b ${TYPE}-${REVISION}-${BRANCH} -f ${VAGRANT_TARGET}.${PROVIDER}.box -p ${PROVIDER} -k ${VAGRANT_KEY} -u ${VAGRANT_USERNAME} -v ${VAGRANT_VERSION}
|
|
|
|
. elif ${PROVIDER} == "vmware"
|
|
|
|
${.CURDIR}/scripts/atlas-upload.sh -b ${TYPE}-${REVISION}-${BRANCH} -f ${VAGRANT_TARGET}.${PROVIDER}.box -p ${PROVIDER}_desktop -k ${VAGRANT_KEY} -u ${VAGRANT_USERNAME} -v ${VAGRANT_VERSION}
|
|
|
|
. endif
|
2015-06-27 22:39:13 +02:00
|
|
|
touch ${.OBJDIR}/${.TARGET}
|
2017-01-31 22:59:10 +01:00
|
|
|
|
|
|
|
vagrant-box: ${VAGRANT_TARGET}.${PROVIDER}.box
|
|
|
|
|
2015-07-20 18:27:44 +02:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
vagrant-upload: ${VAGRANT_UPLOAD_TGTS}
|
|
|
|
|
|
|
|
vagrant-create-virtualbox-metadata: virtualbox/box.ovf
|
|
|
|
|
|
|
|
virtualbox/box.ovf: ${.CURDIR}/scripts/box.ovf
|
|
|
|
cp ${.ALLSRC} virtualbox/
|
|
|
|
|
2021-01-26 18:02:57 +01:00
|
|
|
vmware/vagrant.vmx: ${.CURDIR}/scripts/vagrant.vmx
|
|
|
|
cp ${.ALLSRC} vmware/
|
2015-06-27 22:39:13 +02:00
|
|
|
|
2015-07-20 18:27:44 +02:00
|
|
|
vagrant-create-vmware-metadata: vmware/vagrant.vmx
|