diff --git a/mender-convert-modify b/mender-convert-modify index cec4c58a90..60bb0e3c46 100755 --- a/mender-convert-modify +++ b/mender-convert-modify @@ -103,6 +103,8 @@ mkdir -p work/rootfs sudo mount ${boot_part} work/boot sudo mount ${root_part} work/rootfs +probe_untainted_rootfs_input + if [ -z "${MENDER_DEVICE_TYPE}" ]; then # Observed systems who do not have this file, e.g images generated with mkosi if [ -f work/rootfs/etc/hostname ]; then diff --git a/modules/probe.sh b/modules/probe.sh index 0bdab40e26..782694569f 100644 --- a/modules/probe.sh +++ b/modules/probe.sh @@ -13,6 +13,29 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Checks there is no preexisting mender integration on the golden image +# +# mender-convert expects a vanilla image wihtout mender installed by other means. +# If you provide as input an image that has mender installed by other means already +# it might fail. +# This function will just print warnings for traces of things that look like a tainted input image +probe_untainted_rootfs_input() { + # None of these should be present in a clean rootfs + directories=( + "work/rootfs/var/lib/mender-monitor" + "work/rootfs/var/lib/mender-configure" + "work/data/mender" + ) + + for dir in "${directories[@]}"; do + if [ -e "$dir" ]; then + log_warn "$dir exists!" + log_warn "Input image contain traces Mender of previous Mender installation" + log_warn "The conversion might fail. Please provide a clean input image." + fi + done +} + # Prints target architecture # # No input parameters and these work on the assumption that boot and root parts