Packaging: Add shfmt to format deb maintainer scripts / rpm scriptlets #6317
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.
This PR is working towards doing packaging via pantsbuild. Eventually, I hope to archive and stop using st2-packages.git.
The inconsistent formatting makes it harder to compare deb vs rpm scripts. At first I reformatted manually, but that will get lost quickly as we all make improvements. So, I added
shfmtto format deb maintainer scripts / rpm scriptlets. To enable it I added the shfmt backend to[GLOBAL].backend_packagesinpants.toml.st2/pants.toml
Line 29 in 08fd2ba
I want to keep this PR focused on packaging, so I added
skip_shfmt=Trueto all the BUILD metadata for shell scripts that would be reformatted (other thanpackaging/{rpm,deb}/scripts/*.sh. Someone else can remove thoseskip_shfmtparameters to enable formatting other shell scripts.shfmtdoes not have a lot of options for formatting. I changed 2 of them:st2/pants.toml
Lines 240 to 245 in 08fd2ba
Most of our shell scripts use spaces instead of tabs for indentation. Some have 2 spaces while others have 4. I went with 4 for now (
--indent=4). We can change it later if that proves annoying. I just want consistency.All of our shell scripts indent case statements (though the indent size is inconsistent), so I enabled the
--case-indentoption as well. The formatting is a little different than I normally use, but it is at least consistent.