Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: firecfg.config sorting improvements #5942

Merged
merged 2 commits into from
Aug 6, 2023

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Aug 5, 2023

Remove the space after # for commented code and use # instead of -
for comments at the end of the line.

Currently the CI check does not consider certain special characters
(such as -) when sorting due to sort -d.

So remove -d, sort firecfg using LC_ALL=C and enforce that order.

Also add sort -u to check for duplicates.

This also allows the CI check to ignore normal comments (lines starting
with # ) anywhere in the file.

Relates to #4643.

Remove the space after `#` for commented code and use `#` instead of `-`
for comments at the end of the line.

Commands used to search and replace:

    $ f=src/firecfg/firecfg.config; printf '%s\n' "$(sed -E \
      -e '3,9999s/^# /#/' \
      -e '3,9999s/^#([^ ]+) --? /#\1 # /' \
      "$f")" >"$f"
@kmk3 kmk3 added the firecfg Anything related to firecfg and not firejail itself label Aug 5, 2023
@kmk3 kmk3 requested review from glitsj16 and rusty-snake August 5, 2023 20:16
Currently the CI check does not consider certain special characters
(such as `-`) when sorting due to `sort -d`.

So remove `-d`, sort firecfg using `LC_ALL=C` and enforce that order.

Also add `sort -u` to check for duplicates.

This also allows the CI check to ignore normal comments (lines starting
with `# `) anywhere in the file.

Relates to netblue30#4643.
@kmk3 kmk3 force-pushed the build-firecfg-improvements branch from fb4aba5 to ac2bd32 Compare August 5, 2023 20:17
Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I've added the comment format to my notes to avoid 'old' habits :)

@kmk3 kmk3 merged commit 9f64899 into netblue30:master Aug 6, 2023
@kmk3 kmk3 deleted the build-firecfg-improvements branch August 6, 2023 19:27
kmk3 added a commit that referenced this pull request Aug 23, 2023
kmk3 added a commit to kmk3/firejail that referenced this pull request Sep 6, 2023
Remove the space after `#` for commented code and use `#` instead of `-`
for comments at the end of the line.

Commands used to search and replace:

    arg0="$(cat contrib/syntax/lists/profile_commands_arg0.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    arg1="$(cat contrib/syntax/lists/profile_commands_arg1.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    git ls-files -z -- etc/inc etc/profile* | xargs -0 -I '{}' \
      sh -c "printf '%s\n' \"\$(sed -E \
        -e 's/^# ($arg0)( [#-]-? .*)?\$/#\\1\\2/' \
        -e 's/^# ($arg1)( [^ ]*)?( [#-]-? .*)?\$/#\\1\\2\\3/' \
        -e 's/^# (whitelist \\$)/#\\1/' \
        -e 's/^(#[^ ].+) --? /\\1 # /' \
        '{}')\" >'{}'"

Commands used to check for leftover entries:

    arg0="$(cat contrib/syntax/lists/profile_commands_arg0.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    arg1="$(cat contrib/syntax/lists/profile_commands_arg1.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    git grep -E "^# ($arg0|$arg1)( +|$)" -- etc/inc etc/profile*

See also commit 30f9ad9 ("build: improve comments in firecfg.config",
2023-08-05) / PR netblue30#5942.
kmk3 added a commit to kmk3/firejail that referenced this pull request Sep 8, 2023
Main changes:

* Remove the space after `#` for commented code lines to distinguish
  them from normal comments
* Use `#` instead of `-` for comments at the end of the line so that
  commented code lines work after being uncommented

Commands used to search and replace:

    arg0="$(cat contrib/syntax/lists/profile_commands_arg0.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    arg1="$(cat contrib/syntax/lists/profile_commands_arg1.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    git ls-files -z -- etc/inc etc/profile* | xargs -0 -I '{}' \
      sh -c "printf '%s\n' \"\$(sed -E \
        -e 's/^# ($arg0)( [#-]-? .*)?\$/#\\1\\2/' \
        -e 's/^# ($arg1)( [^ ]*)?( [#-]-? .*)?\$/#\\1\\2\\3/' \
        -e 's/^# (whitelist \\$)/#\\1/' \
        -e 's/^(#[^ ].+) --? /\\1 # /' \
        '{}')\" >'{}'"

Commands used to check for leftover entries:

    arg0="$(cat contrib/syntax/lists/profile_commands_arg0.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    arg1="$(cat contrib/syntax/lists/profile_commands_arg1.list |
      LC_ALL=C sort -u | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')"
    git grep -E "^# ($arg0|$arg1)( +|$)" -- etc/inc etc/profile*

See also commit 30f9ad9 ("build: improve comments in firecfg.config",
2023-08-05) / PR netblue30#5942.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
firecfg Anything related to firecfg and not firejail itself
Projects
Status: Done
Status: Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

3 participants