#!/bin/bash
#
# Drop the resolver configuration mmdebstrap copied in from the build host

set -eu

# mmdebstrap copies /etc/resolv.conf into the rootfs so that apt can resolve
# names, and does not remove it again: cleanup/reproducible takes out the logs,
# the caches and the machine-id, but not this. Whatever the build host happened
# to be using is therefore baked into the artefact, which makes the output
# depend on who built it and publishes their nameservers and search domains.
#
# Only remove a regular file. A layer that deliberately provides its own
# resolver configuration will have made it a symlink - to systemd-resolved's
# stub, say - and that belongs to the image.
if [ -f "$1/etc/resolv.conf" ] && [ ! -L "$1/etc/resolv.conf" ]; then
   rm -f "$1/etc/resolv.conf"
fi
