On 15/01/18 20:44 +0100, Joel Rosdahl wrote:
On 14 January 2018 at 12:01, Michael Bazzinotti via ccache
<ccache@lists.samba.org> wrote:
Try something like this:
cd ~mainuser/.ccache
cp -a --parents ? ~root/.ccache
ccache -c
Joel,
Thanks for the tip. I had mistakenly expected `cp` to overwrite dest dirs
having the same name, rather than merge, but that is not the case
afterall.
That's clever, using the ? pattern. I hadn't learned it until now.
I suppose the ccache file naming scheme assures files with the
same name in different cache's would refer to the same data afterall, huh.
Now, here are the verbatim commands I had used to merge to one shared cache:
# cd ~/.ccache
cp -a --parents ? ~bazz/.ccache
find $CCACHE_DIR -type d | xargs chmod g+s
chown -R bazz:wheel ~bazz/.ccache
chmod -R o=rwx,g=rwx,o=rx ~bazz/.ccache
Note: CCACHE_DIR pointed to ~bazz/.ccache
That got the root cache into the mainuser's cache, and then set proper
permissions on all the files for a shared cache.
To anyone reading, I would like to share further info!
The ? is a bash special pattern character that matches any one
character. So that means only the cache directories are copied and not
the configuration file or the tmp directory from the source cache.
I tried turning my verbatim lines into a script that anyone can use
to merge 2 ccache directories into a shared cache. I suppose you could
chain run it several times invoking different settings to merge >2 caches.
# DISCLAIMER: untested; use at your own risk.
# adjust these settings
src_cache="/root/.ccache"
dst_user="mainuser"
dst_cache="/home/${dst_user}/.ccache"
shr_group="wheel"
# $dst_cache does *not* need to be in a home directory
# use $dst_user to specify (desired) owner of the files in dst_cache.
cd "${src_cache}"
cp -a --parents ? "${dst_cache}"
# Alter permissions for cache-sharing on dst_cache
chown -R ${dst_user}:${shr_group} "${dst_cache}"
chmod -R o=rwx,g=rwx,o=rx "${dst_cache}"
# Make sure dst_cache folders are still setgid
find "${dst_cache}" -type d | xargs chmod g+s
# ccache -c
After running the script, you can remove the source cache if things went
well.
After ensuring your ccache settings point to dst_cache,
`ccache -c`
I'd like to share how I have my ccache settings shared to all users on my
laptop.
/etc/bash/bashrc.d/ccache.sh
export CCACHE_DIR=/home/bazz/.ccache
export CCACHE_UMASK='002'
export CCACHE_TEMPDIR=/tmp
export CCACHE_MAXSIZE=10G
#export CCACHE_LOGFILE=/tmp/ccache.log
export CC="ccache gcc"
export CXX="ccache g++"
I use the symlink method to get ccache invoked as well, which is
documented in ccache already. I'm not sure if invoking ccache through both
symlink and env variables introduces any issues, yet I haven't had a
problem.
Let that help someone.
Sincerely,
--
*****************************
Michael Bazzinotti
Technologist & Musician
http://www.bazz1.com
http://locations.schoolofrock.com/attleboro
_______________________________________________
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache