Ugh what a mess. Well done on fighting to a solution! I have some peanut gallery level observations:
1) can you explain in a bit more detail what happens without the systemctl show calls in preinst? "goes wrong" is a bit ambiguous
2) Did you consider recording the results of systemctl show --property=UnitFileState anacron.{timer,service} in preinst (guarded by checks on $1 and $2) into /run or something and then acting on that in postinst? It feels like it might be a bit less delicate than the solution you have here. But maybe I'm missing something.
Ugh what a mess. Well done on fighting to a solution! I have some peanut gallery level observations:
1) can you explain in a bit more detail what happens without the systemctl show calls in preinst? "goes wrong" is a bit ambiguous
2) Did you consider recording the results of systemctl show --property= UnitFileState anacron. {timer, service} in preinst (guarded by checks on $1 and $2) into /run or something and then acting on that in postinst? It feels like it might be a bit less delicate than the solution you have here. But maybe I'm missing something.