5 # Makefile for uploading Vagrant boxes to Hashicorp Atlas
8 VAGRANT_IMG?= ${.OBJDIR}/vagrant.vmdk
9 VAGRANT_UPLOAD_TGTS= vagrant-check-depends
10 CLEANFILES+= ${VAGRANT_UPLOAD_TGTS}
12 .if defined(VAGRANT_UPLOAD_CONF) && !empty(VAGRANT_UPLOAD_CONF)
13 . for VAR in _KEY _USERNAME
14 VAGRANT${VAR}!= grep -E ^VAGRANT${VAR} ${VAGRANT_UPLOAD_CONF} | awk -F' ' '{print $$2}'
15 ATLAS${VAR}:= ${VAGRANT${VAR}}
19 .if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE"
20 SNAPSHOT_DATE!= date +-%Y%m%d
23 VAGRANT_VERSION!= date +%Y.%m.%d
24 VAGRANT_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}
26 . for _PROVIDER in ${CLOUDWARE}
27 . if ${_PROVIDER:MVAGRANT*}
28 VAGRANT_PROVIDERS+= ${_PROVIDER:S/VAGRANT-//:tl}
32 VAGRANT_PROVIDERS?= vmware virtualbox
35 vagrant-check-depends:
36 .for VAR in _KEY _USERNAME _VERSION
37 . if !defined(VAGRANT${VAR}) || empty(VAGRANT${VAR})
38 @echo "Variable VAGRANT${VAR} cannot be empty."
42 .if !exists(/usr/local/bin/curl)
43 . if !exists(${PORTSDIR}/ftp/curl/Makefile)
44 . if !exists(/usr/local/sbin/pkg-static)
45 env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
47 env ASSUME_ALWAYS_YES=yes pkg install -y curl
49 make -C ${PORTSDIR}/ftp/curl BATCH=1 all install clean
53 .for PROVIDER in ${VAGRANT_PROVIDERS}
54 CLEANFILES+= vagrant-do-package-${PROVIDER} ${VAGRANT_TARGET}.${PROVIDER}.box
55 CLEANDIRS+= ${PROVIDER}
56 VAGRANT_UPLOAD_TGTS+= vagrant-do-upload-${PROVIDER}
61 ${VAGRANT_TARGET}.${PROVIDER}.box: ${PROVIDER} cw-vagrant-${PROVIDER} vagrant-create-${PROVIDER}-metadata
62 @echo "==> PACKAGING: ${VAGRANT_TARGET}.${PROVIDER}.box in `pwd`"
63 @cp vagrant-${PROVIDER}.vmdk ${PROVIDER}/vagrant.vmdk
64 . if ${PROVIDER} == "virtualbox"
65 @(cd ${.OBJDIR}/${PROVIDER} && echo '{"provider":"${PROVIDER}"}' > metadata.json)
66 @(cd ${.OBJDIR}/${PROVIDER} && tar -czf ../${VAGRANT_TARGET}.${PROVIDER}.box metadata.json box.ovf vagrant.vmdk)
67 . elif ${PROVIDER} == "vmware"
68 @(cd ${.OBJDIR}/${PROVIDER} && echo '{"provider":"${PROVIDER}_desktop"}' > metadata.json)
69 @(cd ${.OBJDIR}/${PROVIDER} && tar -czf ../${VAGRANT_TARGET}.${PROVIDER}.box metadata.json vagrant.vmx vagrant.vmdk)
72 CLEANFILES+= vagrant-do-upload-${PROVIDER}
73 vagrant-do-upload-${PROVIDER}: ${VAGRANT_TARGET}.${PROVIDER}.box
74 . if ${PROVIDER} == "virtualbox"
75 ${.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}
76 . elif ${PROVIDER} == "vmware"
77 ${.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}
79 touch ${.OBJDIR}/${.TARGET}
82 vagrant-upload: ${VAGRANT_UPLOAD_TGTS}
84 vagrant-create-virtualbox-metadata: virtualbox/box.ovf
86 virtualbox/box.ovf: ${.CURDIR}/scripts/box.ovf
87 cp ${.ALLSRC} virtualbox/
90 @(cd vmware && echo '.encoding = "UTF-8"' > vagrant.vmx)
91 @(cd vmware && echo 'bios.bootorder = "hdd,CDROM"' >> vagrant.vmx)
92 @(cd vmware && echo 'checkpoint.vmstate = ""' >> vagrant.vmx)
93 @(cd vmware && echo 'cleanshutdown = "TRUE"' >> vagrant.vmx)
94 @(cd vmware && echo 'config.version = "8"' >> vagrant.vmx)
95 @(cd vmware && echo 'displayname = "${VAGRANT_TARGET}"' >> vagrant.vmx)
96 @(cd vmware && echo 'ethernet0.addresstype = "generated"' >> vagrant.vmx)
97 @(cd vmware && echo 'ethernet0.bsdname = "en0"' >> vagrant.vmx)
98 @(cd vmware && echo 'ethernet0.connectiontype = "nat"' >> vagrant.vmx)
99 @(cd vmware && echo 'ethernet0.displayname = "Ethernet"' >> vagrant.vmx)
100 @(cd vmware && echo 'ethernet0.linkstatepropagation.enable = "FALSE"' >> vagrant.vmx)
101 @(cd vmware && echo 'ethernet0.pcislotnumber = "33"' >> vagrant.vmx)
102 @(cd vmware && echo 'ethernet0.present = "TRUE"' >> vagrant.vmx)
103 @(cd vmware && echo 'ethernet0.virtualdev = "e1000"' >> vagrant.vmx)
104 @(cd vmware && echo 'ethernet0.wakeonpcktrcv = "FALSE"' >> vagrant.vmx)
105 @(cd vmware && echo 'floppy0.present = "FALSE"' >> vagrant.vmx)
106 @(cd vmware && echo 'guestos = "freebsd-64"' >> vagrant.vmx)
107 @(cd vmware && echo 'gui.fullscreenatpoweron = "FALSE"' >> vagrant.vmx)
108 @(cd vmware && echo 'gui.viewmodeatpoweron = "windowed"' >> vagrant.vmx)
109 @(cd vmware && echo 'memsize = "512"' >> vagrant.vmx)
110 @(cd vmware && echo 'sound.startconnected = "FALSE"' >> vagrant.vmx)
111 @(cd vmware && echo 'softpoweroff = "TRUE"' >> vagrant.vmx)
112 @(cd vmware && echo 'scsi0.pcislotnumber = "16"' >> vagrant.vmx)
113 @(cd vmware && echo 'scsi0.present = "TRUE"' >> vagrant.vmx)
114 @(cd vmware && echo 'scsi0.virtualdev = "lsilogic"' >> vagrant.vmx)
115 @(cd vmware && echo 'scsi0:0.filename = "vagrant.vmdk"' >> vagrant.vmx)
116 @(cd vmware && echo 'scsi0:0.present = "TRUE"' >> vagrant.vmx)
117 @(cd vmware && echo 'tools.synctime = "TRUE"' >> vagrant.vmx)
118 @(cd vmware && echo 'usb.present = "FALSE"' >> vagrant.vmx)
119 @(cd vmware && echo 'virtualhw.productcompatibility = "hosted"' >> vagrant.vmx)
120 @(cd vmware && echo 'virtualhw.version = "9"' >> vagrant.vmx)
122 vagrant-create-vmware-metadata: vmware/vagrant.vmx