From 6c5ffdc428bc7b7292f78310c9f196095c7b6949 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 3 Nov 2022 12:44:21 +0100 Subject: [PATCH] buildserver: clean up secondary libvirt box image after rebuild Boxes are stored in two places when using vagrant-libvirt: 1. `vagrant box add` -> ~/.vagrant.d/boxes/buildserver/0/libvirt/ 2. `vagrant up` -> /var/lib/libvirt/images/buildserver_vagrant_box_image_0_box.img If the second box is not cleaned up, then `fdroid build` will continue to use the one from the second location, thereby ignoring the updated one at the first location. This keeps the second one around until the new box is ready in case `fdroid build` is using it while this script is running. --- makebuildserver | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/makebuildserver b/makebuildserver index fe2cc9b1..21432a38 100755 --- a/makebuildserver +++ b/makebuildserver @@ -435,6 +435,22 @@ def main(): logging.critical('could not add box \'%s\' as \'buildserver\', terminating', boxfile) sys.exit(1) + # Boxes are stored in two places when using vagrant-libvirt: + # + # 1. `vagrant box add` -> ~/.vagrant.d/boxes/buildserver/0/libvirt/ + # 2. `vagrant up` -> /var/lib/libvirt/images/buildserver_vagrant_box_image_0_box.img + # + # If the second box is not cleaned up, then `fdroid build` will + # continue to use that one from the second location, thereby + # ignoring the updated one at the first location. This process + # keeps the second one around until the new box is ready in case + # `fdroid build` is using it while this script is running. + img = 'buildserver_vagrant_box_image_0_box.img' + if os.path.exists(os.path.join('/var/lib/libvirt/images', img)): + subprocess.call( + ['virsh', '-c', 'qemu:///system', 'vol-delete', '--pool', 'default', '--vol', img] + ) + if not options.keep_box_file: logging.debug("""box added to vagrant, removing generated box file '%s'""", boxfile)