I think the dpkg race condition is actually coming from the removing of
apparmor as it always gives you that teardown error so dpkg isnt quite done