1# 2# $FreeBSD$ 3# 4# 5# Makefile for uploading Vagrant boxes to Hashicorp Atlas 6# 7 8VAGRANT_IMG?= ${.OBJDIR}/vagrant.vmdk 9VAGRANT_UPLOAD_TGTS= vagrant-check-depends \ 10 atlas-do-upload 11CLEANFILES+= ${VAGRANT_UPLOAD_TGTS} 12 13.if defined(VAGRANT_UPLOAD_CONF) && !empty(VAGRANT_UPLOAD_CONF) 14. for VAR in _KEY _USERNAME 15VAGRANT${VAR}!= grep -E ^VAGRANT${VAR} ${VAGRANT_UPLOAD_CONF} | awk -F' ' '{print $$2}' 16ATLAS${VAR}:= ${VAGRANT${VAR}} 17. endfor 18.endif 19 20.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" 21SNAPSHOT_DATE!= date +-%Y-%m-%d 22.endif 23 24VAGRANT_VERSION?= ${REVISION}-${BRANCH}${SNAPSHOT_DATE} 25 26VAGRANT_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}.box 27VAGRANT_PROVIDERS?= vmware_desktop 28#VAGRANT_PROVIDERS+= virtualbox 29 30vagrant-upload: ${VAGRANT_UPLOAD_TGTS} 31 32vagrant-check-depends: 33.for VAR in _KEY _USERNAME _VERSION 34. if !defined(VAGRANT${VAR}) || empty(VAGRANT${VAR}) 35 @echo "Variable VAGRANT${VAR} cannot be empty." 36 @false 37. endif 38.endfor 39.if !exists(/usr/local/bin/curl) 40. if !exists(${PORTSDIR}/ftp/curl/Makefile) 41. if !exists(/usr/local/sbin/pkg-static) 42 env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf 43. endif 44 env ASSUME_ALWAYS_YES=yes pkg install -y curl 45. else 46 make -C ${PORTSDIR}/ftp/curl BATCH=1 all install clean 47. endif 48.endif 49 50vagrant-do-package: cw-vagrant 51 52vagrant-do-package-vmware: vagrant-create-vmware-vmx vagrant-do-package 53 @cd ${.OBJDIR} && echo '{"provider":"vmware_desktop"}' > metadata.json 54 cd ${.OBJDIR} && tar -czf ${VAGRANT_TARGET} metadata.json vagrant.vmx vagrant.vmdk 55 touch ${.OBJDIR}/${.TARGET} 56 57atlas-do-upload: vagrant-do-package-vmware 58.for PROVIDER in ${VAGRANT_PROVIDERS} 59 ${.CURDIR}/scripts/atlas-upload.sh -b FreeBSD-${REVISION}-${BRANCH} -f ${VAGRANT_TARGET} -p ${PROVIDER} -k ${VAGRANT_KEY} -u ${VAGRANT_USERNAME} -v ${VAGRANT_VERSION} 60.endfor 61 touch ${.OBJDIR}/${.TARGET} 62 63vagrant-create-vmware-vmx: 64 @cd ${.OBJDIR} && echo '.encoding = "UTF-8"' > vagrant.vmx 65 @cd ${.OBJDIR} && echo 'bios.bootorder = "hdd,CDROM"' >> vagrant.vmx 66 @cd ${.OBJDIR} && echo 'checkpoint.vmstate = ""' >> vagrant.vmx 67 @cd ${.OBJDIR} && echo 'cleanshutdown = "TRUE"' >> vagrant.vmx 68 @cd ${.OBJDIR} && echo 'config.version = "8"' >> vagrant.vmx 69 @cd ${.OBJDIR} && echo 'displayname = "${VAGRANT_TARGET}"' >> vagrant.vmx 70 @cd ${.OBJDIR} && echo 'ethernet0.addresstype = "generated"' >> vagrant.vmx 71 @cd ${.OBJDIR} && echo 'ethernet0.bsdname = "en0"' >> vagrant.vmx 72 @cd ${.OBJDIR} && echo 'ethernet0.connectiontype = "nat"' >> vagrant.vmx 73 @cd ${.OBJDIR} && echo 'ethernet0.displayname = "Ethernet"' >> vagrant.vmx 74 @cd ${.OBJDIR} && echo 'ethernet0.linkstatepropagation.enable = "FALSE"' >> vagrant.vmx 75 @cd ${.OBJDIR} && echo 'ethernet0.pcislotnumber = "33"' >> vagrant.vmx 76 @cd ${.OBJDIR} && echo 'ethernet0.present = "TRUE"' >> vagrant.vmx 77 @cd ${.OBJDIR} && echo 'ethernet0.virtualdev = "e1000"' >> vagrant.vmx 78 @cd ${.OBJDIR} && echo 'ethernet0.wakeonpcktrcv = "FALSE"' >> vagrant.vmx 79 @cd ${.OBJDIR} && echo 'floppy0.present = "FALSE"' >> vagrant.vmx 80 @cd ${.OBJDIR} && echo 'guestos = "freebsd-64"' >> vagrant.vmx 81 @cd ${.OBJDIR} && echo 'gui.fullscreenatpoweron = "FALSE"' >> vagrant.vmx 82 @cd ${.OBJDIR} && echo 'gui.viewmodeatpoweron = "windowed"' >> vagrant.vmx 83 @cd ${.OBJDIR} && echo 'memsize = "512"' >> vagrant.vmx 84 @cd ${.OBJDIR} && echo 'sound.startconnected = "FALSE"' >> vagrant.vmx 85 @cd ${.OBJDIR} && echo 'softpoweroff = "TRUE"' >> vagrant.vmx 86 @cd ${.OBJDIR} && echo 'scsi0.pcislotnumber = "16"' >> vagrant.vmx 87 @cd ${.OBJDIR} && echo 'scsi0.present = "TRUE"' >> vagrant.vmx 88 @cd ${.OBJDIR} && echo 'scsi0.virtualdev = "lsilogic"' >> vagrant.vmx 89 @cd ${.OBJDIR} && echo 'scsi0:0.filename = "vagrant.vmdk"' >> vagrant.vmx 90 @cd ${.OBJDIR} && echo 'scsi0:0.present = "TRUE"' >> vagrant.vmx 91 @cd ${.OBJDIR} && echo 'tools.synctime = "TRUE"' >> vagrant.vmx 92 @cd ${.OBJDIR} && echo 'usb.present = "FALSE"' >> vagrant.vmx 93 @cd ${.OBJDIR} && echo 'virtualhw.productcompatibility = "hosted"' >> vagrant.vmx 94 @cd ${.OBJDIR} && echo 'virtualhw.version = "9"' >> vagrant.vmx 95