Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Ergonomic configuration of CONFIG_PROTECT
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Xharlie
n00b
n00b


Joined: 21 May 2017
Posts: 12

PostPosted: Wed Jul 17, 2024 12:10 pm    Post subject: Ergonomic configuration of CONFIG_PROTECT Reply with quote

I currently have `CONFIG_PROTECT` customised in `/etc/portage/profile/make.defaults` as an unwieldy, long, space-separated string.

Is there some better way to configure this variable that would support multiple lines and perhaps comments so I could state *why* certain files are in it? (I could add one big comment at the top of `/etc/portage/profile/make.defaults` but not inline, adjacent to the file paths.)

For full disclosure, this is mine, at present:

Code:
CONFIG_PROTECT="/usr/share/X11/xkb/rules/evdev.xml /usr/share/X11/xkb/symbols/gb /usr/lib64/firefox/distribution/distribution.ini /usr/lib64/firefox/distribution/policies.json /usr/lib64/thunderbird/distribution/distribution.ini /usr/lib64/thunderbird/distribution/policies.json"


It's growing, though, because I keep finding files being silently overwritten by packages.

(Today's one was the `gb` keyboard layout file to which I had added a custom *variant*. I tried adding my variant in my own file in `/usr/share/X11/xkb/symbols/` but KDE wouldn't show the right language icon unless I appended my variant to the `gb` file, hence the desired overwrite protection.)
Back to top
View user's profile Send private message
rab0171610
Guru
Guru


Joined: 24 Dec 2022
Posts: 389

PostPosted: Wed Jul 17, 2024 1:13 pm    Post subject: Reply with quote

Code:
CONFIG_PROTECT="/usr/share/X11/xkb/rules/evdev.xml /usr/share/X11/xkb/symbols/gb /usr/lib64/firefox/distribution/distribution.ini /usr/lib64/firefox/distribution/policies.json /usr/lib64/thunderbird/distribution/distribution.ini /usr/lib64/thunderbird/distribution/policies.json"   

Can make use of an escape delimiter '\' anywhere after the spaces:
Code:

CONFIG_PROTECT="/usr/share/X11/xkb/rules/evdev.xml /usr/share/X11/xkb/symbols/gb /usr/lib64/firefox/distribution/distribution.ini \
/usr/lib64/firefox/distribution/policies.json /usr/lib64/thunderbird/distribution/distribution.ini \
/usr/lib64/thunderbird/distribution/policies.json"   

This allows one line to wrap to the next line to make it more human readable. This escape character '\' will escape the newline character inserted in the document when hitting enter on the keyboard.

Also, you can try to limit your use of config protect entries. For example, you can use the /etc/xkb/symbols/ and /etc/xkb/rules directory to mirror the /usr/share/X11/xkb/rules and /usr/share/X11/xkb/symbols directories. You can put your modified or custom config files there. "You may also use $XDG_CONFIG_HOME/xkb/, or $HOME/.config/xkb/ if the $XDG_CONFIG_HOME environment variable is not defined" per:
https://xkbcommon.org/doc/current/user-configuration.html
If that is correct and current, then you should be able to use any directory you wish by setting the $XDG_CONFIG_HOME environment variable.
See also:
https://wiki.archlinux.org/index.php?title=X_keyboard_extension&diff=prev&oldid=362133
https://bbs.archlinux.org/viewtopic.php?id=286561
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1822

PostPosted: Wed Jul 17, 2024 1:48 pm    Post subject: Reply with quote

For CONFIG_PROTECT, use custom /etc/env.d entries as needed. They are cumulative over all files and allow comments in the file. Just don't name the same as something Gentoo would use.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22325

PostPosted: Wed Jul 17, 2024 3:18 pm    Post subject: Re: Ergonomic configuration of CONFIG_PROTECT Reply with quote

Xharlie wrote:
I currently have `CONFIG_PROTECT` customised in `/etc/portage/profile/make.defaults` as an unwieldy, long, space-separated string.
Why are you putting it there? /etc/portage/make.conf is reserved to the user, and seems better suited to your purpose.
Xharlie wrote:
Is there some better way to configure this variable that would support multiple lines and perhaps comments so I could state *why* certain files are in it?
Yes.
Code:
$ grep CONFIG_PROTECT /etc/portage/make.conf
# Add /a to $CONFIG_PROTECT to start
CONFIG_PROTECT="/a"
# Append /b to $CONFIG_PROTECT, to continue
CONFIG_PROTECT="$CONFIG_PROTECT /b"
$ emerge --info | grep -w CONFIG_PROTECT
CONFIG_PROTECT="/a /b /etc /usr/share/gnupg/qualified.txt"
Xharlie wrote:
It's growing, though, because I keep finding files being silently overwritten by packages.
Packages will silently overwrite any file that they own, if it is not protected. Before customizing a file owned by a package, add it to CONFIG_PROTECT.

You can also use newlines instead of spaces within the string, if you want multiple lines without needing to repeat the literal $CONFIG_PROTECT. There is no need for a backslash to continue inside the string. However, while inside the string, you cannot use comments, so if you want per-block comments, those will need to use the form I show above.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum