Make weeklies more robust
At the moment weeklies are chosen by simply looking at the weekday: if a build happens on Wednesday it is copied.
This has two problems:
- if no images are generated on Wednesday due to a build failure, then no weekly image is preserved, causing data loss;
- if multiple builds are done on Wednesday they all get preseved, causing excessive storage consumption.
The new approach is to take the most recent build on Wednesday if available, otherwise the one on Tuesday, then Monday, then Sunday and so on.
Fixes: APERTIS-5336