diff --git a/release/Makefile.vagrant b/release/Makefile.vagrant index 307e21f72745..7ae64849e0ce 100644 --- a/release/Makefile.vagrant +++ b/release/Makefile.vagrant @@ -6,8 +6,7 @@ # VAGRANT_IMG?= ${.OBJDIR}/vagrant.vmdk -VAGRANT_UPLOAD_TGTS= vagrant-check-depends \ - atlas-do-upload +VAGRANT_UPLOAD_TGTS= vagrant-check-depends CLEANFILES+= ${VAGRANT_UPLOAD_TGTS} .if defined(VAGRANT_UPLOAD_CONF) && !empty(VAGRANT_UPLOAD_CONF) @@ -18,16 +17,20 @@ ATLAS${VAR}:= ${VAGRANT${VAR}} .endif .if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" -SNAPSHOT_DATE!= date +-%Y-%m-%d +SNAPSHOT_DATE!= date +%Y%m%d .endif -VAGRANT_VERSION?= ${REVISION}-${BRANCH}${SNAPSHOT_DATE} +VAGRANT_VERSION!= date +%Y.%m.%d +VAGRANT_TARGET:= ${OSRELEASE}-${SNAPSHOT_DATE} +.if !empty(CLOUDWARE) +. for _PROVIDER in ${CLOUDWARE} +. if ${_PROVIDER:MVAGRANT*} +VAGRANT_PROVIDERS+= ${_PROVIDER:S/VAGRANT-//:tl} +. endif +. endfor +.endif +VAGRANT_PROVIDERS?= vmware virtualbox -VAGRANT_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}.box -VAGRANT_PROVIDERS?= vmware_desktop -#VAGRANT_PROVIDERS+= virtualbox - -vagrant-upload: ${VAGRANT_UPLOAD_TGTS} vagrant-check-depends: .for VAR in _KEY _USERNAME _VERSION @@ -47,48 +50,73 @@ vagrant-check-depends: . endif .endif -vagrant-do-package: cw-vagrant - -vagrant-do-package-vmware: vagrant-create-vmware-vmx vagrant-do-package - @cd ${.OBJDIR} && echo '{"provider":"vmware_desktop"}' > metadata.json - cd ${.OBJDIR} && tar -czf ${VAGRANT_TARGET} metadata.json vagrant.vmx vagrant.vmdk - touch ${.OBJDIR}/${.TARGET} - -atlas-do-upload: vagrant-do-package-vmware .for PROVIDER in ${VAGRANT_PROVIDERS} - ${.CURDIR}/scripts/atlas-upload.sh -b FreeBSD-${REVISION}-${BRANCH} -f ${VAGRANT_TARGET} -p ${PROVIDER} -k ${VAGRANT_KEY} -u ${VAGRANT_USERNAME} -v ${VAGRANT_VERSION} -.endfor - touch ${.OBJDIR}/${.TARGET} +CLEANFILES+= vagrant-do-package-${PROVIDER} ${VAGRANT_TARGET}.${PROVIDER}.box +CLEANDIRS+= ${PROVIDER} +VAGRANT_UPLOAD_TGTS+= vagrant-do-upload-${PROVIDER} -vagrant-create-vmware-vmx: - @cd ${.OBJDIR} && echo '.encoding = "UTF-8"' > vagrant.vmx - @cd ${.OBJDIR} && echo 'bios.bootorder = "hdd,CDROM"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'checkpoint.vmstate = ""' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'cleanshutdown = "TRUE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'config.version = "8"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'displayname = "${VAGRANT_TARGET}"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.addresstype = "generated"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.bsdname = "en0"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.connectiontype = "nat"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.displayname = "Ethernet"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.linkstatepropagation.enable = "FALSE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.pcislotnumber = "33"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.present = "TRUE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.virtualdev = "e1000"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'ethernet0.wakeonpcktrcv = "FALSE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'floppy0.present = "FALSE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'guestos = "freebsd-64"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'gui.fullscreenatpoweron = "FALSE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'gui.viewmodeatpoweron = "windowed"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'memsize = "512"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'sound.startconnected = "FALSE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'softpoweroff = "TRUE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'scsi0.pcislotnumber = "16"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'scsi0.present = "TRUE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'scsi0.virtualdev = "lsilogic"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'scsi0:0.filename = "vagrant.vmdk"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'scsi0:0.present = "TRUE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'tools.synctime = "TRUE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'usb.present = "FALSE"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'virtualhw.productcompatibility = "hosted"' >> vagrant.vmx - @cd ${.OBJDIR} && echo 'virtualhw.version = "9"' >> vagrant.vmx +${PROVIDER}: + @mkdir -p ${PROVIDER} + +${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} +vagrant-do-upload-${PROVIDER}: ${VAGRANT_TARGET}.${PROVIDER}.box +. 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 + touch ${.OBJDIR}/${.TARGET} +.endfor + +vagrant-upload: ${VAGRANT_UPLOAD_TGTS} + +vagrant-create-virtualbox-metadata: virtualbox/box.ovf + +virtualbox/box.ovf: ${.CURDIR}/scripts/box.ovf + cp ${.ALLSRC} virtualbox/ + +vmware/vagrant.vmx: + @(cd vmware && echo '.encoding = "UTF-8"' > vagrant.vmx) + @(cd vmware && echo 'bios.bootorder = "hdd,CDROM"' >> vagrant.vmx) + @(cd vmware && echo 'checkpoint.vmstate = ""' >> vagrant.vmx) + @(cd vmware && echo 'cleanshutdown = "TRUE"' >> vagrant.vmx) + @(cd vmware && echo 'config.version = "8"' >> vagrant.vmx) + @(cd vmware && echo 'displayname = "${VAGRANT_TARGET}"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.addresstype = "generated"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.bsdname = "en0"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.connectiontype = "nat"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.displayname = "Ethernet"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.linkstatepropagation.enable = "FALSE"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.pcislotnumber = "33"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.present = "TRUE"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.virtualdev = "e1000"' >> vagrant.vmx) + @(cd vmware && echo 'ethernet0.wakeonpcktrcv = "FALSE"' >> vagrant.vmx) + @(cd vmware && echo 'floppy0.present = "FALSE"' >> vagrant.vmx) + @(cd vmware && echo 'guestos = "freebsd-64"' >> vagrant.vmx) + @(cd vmware && echo 'gui.fullscreenatpoweron = "FALSE"' >> vagrant.vmx) + @(cd vmware && echo 'gui.viewmodeatpoweron = "windowed"' >> vagrant.vmx) + @(cd vmware && echo 'memsize = "512"' >> vagrant.vmx) + @(cd vmware && echo 'sound.startconnected = "FALSE"' >> vagrant.vmx) + @(cd vmware && echo 'softpoweroff = "TRUE"' >> vagrant.vmx) + @(cd vmware && echo 'scsi0.pcislotnumber = "16"' >> vagrant.vmx) + @(cd vmware && echo 'scsi0.present = "TRUE"' >> vagrant.vmx) + @(cd vmware && echo 'scsi0.virtualdev = "lsilogic"' >> vagrant.vmx) + @(cd vmware && echo 'scsi0:0.filename = "vagrant.vmdk"' >> vagrant.vmx) + @(cd vmware && echo 'scsi0:0.present = "TRUE"' >> vagrant.vmx) + @(cd vmware && echo 'tools.synctime = "TRUE"' >> vagrant.vmx) + @(cd vmware && echo 'usb.present = "FALSE"' >> vagrant.vmx) + @(cd vmware && echo 'virtualhw.productcompatibility = "hosted"' >> vagrant.vmx) + @(cd vmware && echo 'virtualhw.version = "9"' >> vagrant.vmx) + +vagrant-create-vmware-metadata: vmware/vagrant.vmx diff --git a/release/Makefile.vm b/release/Makefile.vm index f6e7831445a7..b39d05520768 100644 --- a/release/Makefile.vm +++ b/release/Makefile.vm @@ -19,7 +19,8 @@ CLOUDWARE?= AZURE \ EC2 \ GCE \ OPENSTACK \ - VAGRANT + VAGRANT-VIRTUALBOX \ + VAGRANT-VMWARE AZURE_FORMAT= vhdf AZURE_DESC= Microsoft Azure platform image AZURE_DISK= ${OSRELEASE}.${AZURE_FORMAT} @@ -32,9 +33,12 @@ GCE_DISK= disk.${GCE_FORMAT} OPENSTACK_FORMAT=qcow2 OPENSTACK_DESC= OpenStack platform image OPENSTACK_DISK= ${OSRELEASE}.${OPENSTACK_FORMAT} -VAGRANT_FORMAT= vmdk -VAGRANT_DESC= Vagrant Image -VAGRANT_DISK= ${OSRELEASE}.${VAGRANT_FORMAT} +VAGRANT-VIRTUALBOX_FORMAT= vmdk +VAGRANT-VIRTUALBOX_DESC= Vagrant Image for VirtualBox +VAGRANT-VIRTUALBOX_DISK= ${OSRELEASE}.vbox.${VAGRANT_FORMAT} +VAGRANT-VMWARE_FORMAT= vmdk +VAGRANT-VMWARE_DESC= Vagrant Image for VMWare +VAGRANT-VMWARE_DISK= ${OSRELEASE}.vmware.${VAGRANT_FORMAT} .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE) . for _CW in ${CLOUDWARE} diff --git a/release/scripts/atlas-upload.sh b/release/scripts/atlas-upload.sh index 63a5ba16b741..bf1dbf116dbc 100755 --- a/release/scripts/atlas-upload.sh +++ b/release/scripts/atlas-upload.sh @@ -28,20 +28,23 @@ ATLAS_API_URL='' ATLAS_UPLOAD_URL='https://binstore.hashicorp.com' -VERSION_DESCRIPTION="FreeBSD Snapshot Build" +DESCRIPTION="FreeBSD Snapshot Build" usage() { echo "${0} usage:" - echo "-b box-name -f box-to-upload -k api-key -p provider -u user -v version" + echo "-b box-name -d 'box description' -f box-to-upload -k api-key -p provider -u user -v version" return 1 } main () { - while getopts "b:f:k:p:u:v:" arg; do + while getopts "b:d:f:k:p:u:v:" arg; do case "${arg}" in b) BOX="${OPTARG}" ;; + d) + DESCRIPTION="${OPTARG}" + ;; f) FILE="${OPTARG}" ;; @@ -83,6 +86,7 @@ main () { echo "Creating box: ${BOX}" /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/boxes -X POST -d "box[name]=${BOX}" -d "access_token=${KEY}" > /dev/null /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[is_private]=false" -d "access_token=${KEY}" > /dev/null + /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[description]='${DESCRIPTION}'" -d "access_token=${KEY}" > /dev/null else echo "Box already exists" fi @@ -97,7 +101,7 @@ main () { if [ $? != 0 ]; then echo "Creating version: ${VERSION}" /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/versions -X POST -d "version[version]=${VERSION}" -d "access_token=${KEY}" > /dev/null - /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION} -X PUT -d "version[description]=${VERSION_DESCRIPTION}" -d "access_token=${KEY}" > /dev/null + /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION} -X PUT -d "version[description]=${DESCRIPTION}" -d "access_token=${KEY}" > /dev/null VERSIONRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}") echo $VERSIONRESULT | grep "\"version\":\"${VERSION}\"" > /dev/null if [ $? != 0 ]; then diff --git a/release/scripts/box.ovf b/release/scripts/box.ovf new file mode 100644 index 000000000000..571e36fb6ab5 --- /dev/null +++ b/release/scripts/box.ovf @@ -0,0 +1,226 @@ + + + + + + + List of the virtual disks used in the package + + + + Logical networks used in the package + + Logical network used by this appliance. + + + + A virtual machine + + The kind of installed guest operating system + FreeBSD_64 + FreeBSD_64 + + + Virtual hardware requirements for a virtual machine + + Virtual Hardware Family + 0 + freebsd + virtualbox-2.2 + + + 1 virtual CPU + Number of virtual CPUs + 1 virtual CPU + 1 + 3 + 1 + + + MegaBytes + 512 MB of memory + Memory Size + 512 MB of memory + 2 + 4 + 512 + + + 0 + ideController0 + IDE Controller + ideController0 + 3 + PIIX4 + 5 + + + 1 + ideController1 + IDE Controller + ideController1 + 4 + PIIX4 + 5 + + + 0 + disk1 + Disk Image + disk1 + /disk/vmdisk1 + 5 + 3 + 17 + + + true + Ethernet adapter on 'NAT' + NAT + Ethernet adapter on 'NAT' + 6 + E1000 + 10 + + + + Complete VirtualBox machine configuration in VirtualBox format + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/release/tools/vagrant-virtualbox.conf b/release/tools/vagrant-virtualbox.conf new file mode 100644 index 000000000000..ff14674ca708 --- /dev/null +++ b/release/tools/vagrant-virtualbox.conf @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +. ${WORLDDIR}/release/tools/vagrant.conf + +export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} virtualbox-ose-additions" + +vm_extra_pre_umount () { + # VirtualBox first boot pkgs + echo 'firstboot_pkgs_list="sudo rsync virtualbox-ose-additions"' >> ${DESTDIR}/etc/rc.conf + echo 'vboxguest_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'vboxservice_enable="YES"' >> ${DESTDIR}/etc/rc.conf + + # Setup the Vagrant common items + vagrant_common +} diff --git a/release/tools/vagrant-vmware.conf b/release/tools/vagrant-vmware.conf new file mode 100644 index 000000000000..330892bc7b85 --- /dev/null +++ b/release/tools/vagrant-vmware.conf @@ -0,0 +1,22 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +. ${WORLDDIR}/release/tools/vagrant.conf + +export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} open-vm-tools-nox11" + +vm_extra_pre_umount () { + # VMWare first boot pkgs + echo 'firstboot_pkgs_list="sudo rsync open-vm-tools-nox11"' >> ${DESTDIR}/etc/rc.conf + + echo 'vmware_guest_vmblock_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'vmware_guest_vmhgfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'vmware_guest_vmmemctl_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'vmware_guest_vmxnet_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'vmware_guestd_enable="YES"' >> ${DESTDIR}/etc/rc.conf + + # Setup the Vagrant common items + vagrant_common +} diff --git a/release/tools/vagrant.conf b/release/tools/vagrant.conf index 7e629caa4549..159da4fa21a9 100644 --- a/release/tools/vagrant.conf +++ b/release/tools/vagrant.conf @@ -10,17 +10,14 @@ export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs" # Set to a list of third-party software to enable in rc.conf(5). export VM_RC_LIST="firstboot_freebsd_update firstboot_pkgs" -vm_extra_pre_umount() { +vagrant_common () { # The firstboot_pkgs rc.d script will download the repository # catalogue and install or update pkg when the instance first # launches, so these files would just be replaced anyway; removing # them from the image allows it to boot faster. env ASSUME_ALWAYS_YES=yes pkg -c ${DESTDIR} delete -f -y pkg rm ${DESTDIR}/var/db/pkg/repo-*.sqlite - - # The size of the EC2 root disk can be configured at instance launch - # time; expand our filesystem to fill the disk. - echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf + env ASSUME_ALWAYS_YES=yes pkg -c ${DESTDIR} clean -y -a # Vagrant instances use DHCP to get their network configuration. echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf @@ -36,9 +33,6 @@ vm_extra_pre_umount() { echo 'sendmail_outbound_enable="NO"' >> ${DESTDIR}/etc/rc.conf echo 'sendmail_msp_queue_enable="NO"' >> ${DESTDIR}/etc/rc.conf - # sudo is required - echo 'firstboot_pkgs_list="sudo rsync"' >> ${DESTDIR}/etc/rc.conf - # Create the vagrant user with a password of vagrant /usr/sbin/pw -R ${DESTDIR} \ groupadd vagrant -g 1001