Automatically set default permissions on installed files for entire target

50 views Asked by At

On a Gentoo systems, lets say I have a lot of my homemade components with one ebuild each (normal case), and I want to apply default permissions on files at installation phase.

Is there a way to automatically set/configure default permissions on installed files, without modifying each ebuild file? Is it possible to do this globally (one modification working for all ebuilds)?

I came across "libopts", "diropts", "exeopts", etc.., but it requires to modify each ebuild to set my own default permissions.

1

There are 1 answers

0
rindeal On

bashrc to the rescue! This file is sourced before each phase of the build runs. The phase you're interested in is called preinst. This phase will run before installing the data to disk. So your code could look like:

if [[ "${EBUILD_PHASE}" == 'preinst' ]] ; then
    if [[ -n "${D} ]] ; then
        find "${D}" -type f -print0 | xargs -0 chmod ...
        find "${D}" -type d -print0 | xargs -0 chmod ...
    else
        echo "Error"
    fi
fi

NOTE: the code is not tested, use at your own risk