Index: projects/release-vmimage/release/tools/azure.conf =================================================================== --- projects/release-vmimage/release/tools/azure.conf (revision 274772) +++ projects/release-vmimage/release/tools/azure.conf (revision 274773) @@ -1,53 +1,50 @@ #!/bin/sh # # $FreeBSD$ # # Set to a list of packages to install. # Example: -#export VM_EXTRA_PACKAGES="www/apache24" +#export VM_EXTRA_PACKAGES="www/apache24 ports-mgmt/pkg" export VM_EXTRA_PACKAGES= # Set to a list of third-party software to enable in rc.conf(5). # Example: #export VM_RC_LIST="apache24" export VM_RC_LIST= vm_extra_install_base() { fetch -o ${DESTDIR}/usr/sbin/waagent \ http://people.freebsd.org/~gjb/waagent chmod +x ${DESTDIR}/usr/sbin/waagent - rm -f ${DESTDIR}/etc/resolv.conf return 0 } vm_extra_pre_umount() { chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg install -y \ python python2 python27 py27-asn1 sudo bash chroot ${DESTDIR} /usr/sbin/waagent -verbose -install yes | chroot ${DESTDIR} /usr/sbin/waagent -deprovision echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf - - rm -f ${DESTDIR}/etc/resolv.conf return 0 } vm_extra_create_disk() { if [ ! -x "/usr/local/bin/qemu-img" ]; then env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-devel fi mv ${VMIMAGE} ${VMIMAGE}.raw size=$(qemu-img info -f raw --output json ${VMIMAGE}.raw | awk '/virtual-size/ {print $2}' | tr -d ',') size=$(( ( ${size} / ( 1024 * 1024 ) + 1 ) * ( 1024 * 1024 ) )) qemu-img resize ${VMIMAGE}.raw ${size} qemu-img convert -f raw -o subformat=fixed -O vpc ${VMIMAGE}.raw ${VMIMAGE} return 0 } Index: projects/release-vmimage/release/tools/openstack.conf =================================================================== --- projects/release-vmimage/release/tools/openstack.conf (revision 274772) +++ projects/release-vmimage/release/tools/openstack.conf (revision 274773) @@ -1,28 +1,25 @@ #!/bin/sh # # $FreeBSD$ # # Set to a list of packages to install. -export VM_EXTRA_PACKAGES="net/cloud-init" +export VM_EXTRA_PACKAGES="net/cloud-init ports-mgmt/pkg" # Set to a list of third-party software to enable in rc.conf(5). export VM_RC_LIST="cloudinit" vm_extra_install_base() { fetch -o ${DESTDIR}/usr/sbin/waagent \ http://people.freebsd.org/~gjb/waagent chmod +x ${DESTDIR}/usr/sbin/waagent - rm -f ${DESTDIR}/etc/resolv.conf return 0 } vm_extra_pre_umount() { echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf - - rm -f ${DESTDIR}/etc/resolv.conf return 0 } Index: projects/release-vmimage/release/tools/vmimage.subr =================================================================== --- projects/release-vmimage/release/tools/vmimage.subr (revision 274772) +++ projects/release-vmimage/release/tools/vmimage.subr (revision 274773) @@ -1,176 +1,175 @@ #!/bin/sh # # $FreeBSD$ # # # Common functions for virtual machine image build scripts. # export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" trap "cleanup" INT QUIT TRAP ABRT TERM write_partition_layout() { if [ -z "${NOSWAP}" ]; then SWAPOPT="-p freebsd-swap/swapfs::1G" fi case "${TARGET}:${TARGET_ARCH}" in amd64:amd64 | i386:i386) mkimg -s gpt -b /boot/pmbr \ -p freebsd-boot/bootfs:=/boot/gptboot \ ${SWAPOPT} \ -p freebsd-ufs/rootfs:=${VMBASE} \ -o ${VMIMAGE} ;; powerpc:powerpc*) mkimg -s apm \ -p apple-boot/bootfs:=/boot/boot1.hfs \ ${SWAPOPT} \ -p freebsd-ufs/rootfs:=${VMBASE} \ -o ${VMIMAGE} ;; *) # ENOTSUPP return 1 ;; esac return 0 } err() { printf "${@}\n" cleanup return 1 } cleanup() { umount ${DESTDIR}/dev 2>/dev/null umount ${DESTDIR} if [ ! -z "${mddev}" ]; then mdconfig -d -u ${mddev} fi return 0 } vm_create_base() { # Creates the UFS root filesystem for the virtual machine disk, # written to the formatted disk image with mkimg(1). mkdir -p ${DESTDIR} truncate -s ${VMSIZE} ${VMBASE} mddev=$(mdconfig -f ${VMBASE}) newfs -j /dev/${mddev} mount /dev/${mddev} ${DESTDIR} return 0 } vm_install_base() { # Installs the FreeBSD userland/kernel to the virtual machine disk. cd ${WORLDDIR} && \ make DESTDIR=${DESTDIR} \ installworld installkernel distribution || \ err "\n\nCannot install the base system to ${DESTDIR}." echo '# Custom /etc/fstab for FreeBSD VM images' \ > ${DESTDIR}/etc/fstab echo '/dev/gpt/rootfs / ufs rw 1 1' \ >> ${DESTDIR}/etc/fstab if [ -z "${NOSWAP}" ]; then echo '/dev/gpt/swapfs none swap sw 0 0' \ >> ${DESTDIR}/etc/fstab fi mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} /usr/bin/newaliases chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart umount ${DESTDIR}/dev - cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf - return 0 } vm_extra_install_base() { # Prototype. When overridden, runs extra post-installworld commands # as needed, based on the target virtual machine image or cloud # provider image target. return 0 } vm_extra_enable_services() { if [ ! -z "${VM_RC_LIST}" ]; then for _rcvar in ${VM_RC_LIST}; do echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf done fi return 0 } vm_extra_install_packages() { - mkdir -p ${DESTDIR}/dev - mount -t devfs devfs ${DESTDIR}/dev - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg bootstrap -y if [ ! -z "${VM_EXTRA_PACKAGES}" ]; then - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} + PKGSDIR=`mktemp -d` + ABI=`/usr/sbin/pkg -c ${DESTDIR} config abi` + /usr/sbin/pkg -o ABI=${ABI} fetch -o ${PKGSDIR} -d -y ${VM_EXTRA_PACKAGES} + for PKG in ${PKGSDIR}/All/*; do + /usr/sbin/pkg -c ${DESTDIR} add -M - < ${PKG} + done + rm -r ${PKGSDIR} + if [ -z "${NOREPOSQLITE}" ]; then + cp /var/db/pkg/repo-FreeBSD.sqlite ${DESTDIR}/var/db/pkg + fi fi - umount ${DESTDIR}/dev return 0 } vm_extra_install_ports() { # Prototype. When overridden, installs additional ports within the # virtual machine environment. return 0 } vm_extra_pre_umount() { # Prototype. When overridden, installs additional ports within the # virtual machine environment. - - rm -f ${DESTDIR}/etc/resolv.conf return 0 } vm_umount_base() { i=0 sync while ! umount ${DESTDIR}/dev ${DESTDIR}; do i=$(( $i + 1 )) if [ $i -ge 10 ]; then # This should never happen. But, it has happened. msg="Cannot umount(8) ${DESTDIR}\n" msg="${msg}Something has gone horribly wrong." err "${msg}" fi sleep 1 done return 0 } vm_create_disk() { echo "Creating image... Please wait." echo write_partition_layout || return 1 return 0 } vm_extra_create_disk() { return 0 }