[dist] Fix initial presets handling in obsstoragesetup. #12628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The general idea is that, if a user provided a preset using
/etc/buildhost.config
, i.e., if this file exists at the start of the(first) script run, then it should be moved to
/etc/buildhost.config.presets
, assuming that this file does not existalready (which is meant as a protection for later runs).
Unfortunately, the logic for doing so was broken for 12 years and nobody
noticed it.
During the first run, the current code:
buildhost.config.presets
exists, and if it DOES NOT:buildhost.config
tobuildhost.config.presets
buildhost.config
from scratchbuildhost.config.presets
tobuildhost.config
(if existent)This has the unwanted side-effect that if no
buildhost.config
file hasbeen provided by the user, nothing will be moved in the first run and
the second run will see a
buildhost.config
file, but nobuildhost.config.presets
file, so it wrongly assumes that thebuildhost.config
is a user-provided preset and moves it tobuildhost.config.presets
.Due to that, the initial, default config will essentially always
override any user-defined value in
/etc/sysconfig/obs-server
or evenwhen modifying
/etc/buildhost.config
directly.The fix for that is trivial: if neither files exist, create
buildhost.conf.presets
as an empty file.While that will fix the issue for any NEW installations, older ones will
not be affected. Sadly, it's not possible to fix existing installations,
since we lost the information regarding user-provided or auto-generated
config entries long ago due to the initial bug.
See: #12520