Date: Fri, 21 Nov 2014 02:13:13 +0000 (UTC) From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r274773 - projects/release-vmimage/release/tools Message-ID: <201411210213.sAL2DDcK060348@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cperciva Date: Fri Nov 21 02:13:12 2014 New Revision: 274773 URL: https://svnweb.freebsd.org/changeset/base/274773 Log: Change how packages are installed into VM images: Rather than chrooting into the image and running 'pkg install' from there, use 'pkg fetch' to download packages into a temporary location and then 'pkg add' to install them into the image. This simplifies the code by avoiding the need to copy /etc/resolv.conf into the image and then delete it later, and makes it possible to cross build (e.g., to create an amd64 image when running on i386 hardware; or in the future for building disk images for embedded platforms). Because pkg was implicitly installed when VM_EXTRA_PACKAGES was non-empty, add it to VM_EXTRA_PACKAGES in azure.conf and openstack.conf to maintain the current behaviour. By default repo-FreeBSD.sqlite is copied into the image, (a) to match previous behaviour, where the file would be downloaded by the chrooted pkg invocation; and (b) because it may be useful for testing purposes, e.g., to see why a package didn't get installed. Because this file is large (46 MB) and not likely to be useful in -RELEASE images which are being launched into Clouds several months later, it can be disabled by setting NOREPOSQLITE. As far as I know this commit does not change the disk images produced in any filesystem-visible way. Modified: projects/release-vmimage/release/tools/azure.conf projects/release-vmimage/release/tools/openstack.conf projects/release-vmimage/release/tools/vmimage.subr Modified: projects/release-vmimage/release/tools/azure.conf ============================================================================== --- projects/release-vmimage/release/tools/azure.conf Fri Nov 21 02:05:48 2014 (r274772) +++ projects/release-vmimage/release/tools/azure.conf Fri Nov 21 02:13:12 2014 (r274773) @@ -5,7 +5,7 @@ # 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). @@ -17,7 +17,6 @@ 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 } @@ -33,8 +32,6 @@ vm_extra_pre_umount() { echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf - rm -f ${DESTDIR}/etc/resolv.conf - return 0 } Modified: projects/release-vmimage/release/tools/openstack.conf ============================================================================== --- projects/release-vmimage/release/tools/openstack.conf Fri Nov 21 02:05:48 2014 (r274772) +++ projects/release-vmimage/release/tools/openstack.conf Fri Nov 21 02:13:12 2014 (r274773) @@ -4,7 +4,7 @@ # # 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" @@ -13,7 +13,6 @@ 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 } @@ -22,7 +21,5 @@ 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 } Modified: projects/release-vmimage/release/tools/vmimage.subr ============================================================================== --- projects/release-vmimage/release/tools/vmimage.subr Fri Nov 21 02:05:48 2014 (r274772) +++ projects/release-vmimage/release/tools/vmimage.subr Fri Nov 21 02:13:12 2014 (r274773) @@ -90,8 +90,6 @@ vm_install_base() { chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart umount ${DESTDIR}/dev - cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf - return 0 } @@ -114,15 +112,18 @@ vm_extra_enable_services() { } 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 } @@ -138,8 +139,6 @@ vm_extra_pre_umount() { # Prototype. When overridden, installs additional ports within the # virtual machine environment. - rm -f ${DESTDIR}/etc/resolv.conf - return 0 }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411210213.sAL2DDcK060348>