diff --git a/conf/build.manifest b/conf/build.manifest index 7265ecc..c81b330 100644 --- a/conf/build.manifest +++ b/conf/build.manifest @@ -329,6 +329,8 @@ iso-packages: - python3-truenas-installer - udhcpc - vim-tiny +# Must be the last package as installing it breaks /etc/resolv.conf in chroot +- systemd-resolved # # List of Git source repositories the build will checkout and perform a debian diff --git a/scale_build/image/iso.py b/scale_build/image/iso.py index 1a7f492..b16f472 100644 --- a/scale_build/image/iso.py +++ b/scale_build/image/iso.py @@ -32,10 +32,18 @@ def install_iso_packages(): def install_iso_packages_impl(): run_in_chroot(['apt', 'update']) + with open(f"{CHROOT_BASEDIR}/etc/resolv.conf") as f: + resolv_conf = f.read() + # echo "/dev/disk/by-label/TRUENAS / iso9660 loop 0 0" > ${CHROOT_BASEDIR}/etc/fstab for package in get_manifest()['iso-packages']: run_in_chroot(['apt', 'install', '-y', package]) + # Installing systemd-resolved breaks existing resolv.conf + os.unlink(f"{CHROOT_BASEDIR}/etc/resolv.conf") + with open(f"{CHROOT_BASEDIR}/etc/resolv.conf", "w") as f: + f.write(resolv_conf) + # Inject vendor name into grub.cfg with open(CONF_GRUB, 'r') as f: grub_cfg = f.read() @@ -55,7 +63,7 @@ def make_iso_file(): run(fr'chroot {CHROOT_BASEDIR} /bin/bash -c "echo -e \"root\nroot\" | passwd root"', shell=True) # Bring up network for the installer - run(f'chroot {CHROOT_BASEDIR} systemctl enable systemd-networkd', shell=True) + run(f'chroot {CHROOT_BASEDIR} systemctl enable systemd-networkd systemd-resolved', shell=True) # Create /etc/version with open(os.path.join(CHROOT_BASEDIR, 'etc/version'), 'w') as f: