В Wed, 22 Jul 2015 13:20:10 +0000
Joakim Tjernlund <joakim.tjernl...@transmode.se> пишет:

> On Wed, 2015-07-22 at 14:30 +0200, Michał Górny wrote:
> > 
> > Joakim Tjernlund <joakim.tjernl...@transmode.se> napisał:
> > 
> > > We got an embedded gentoo system where we need to manage many conf
> > > files under /etc that we have
> > > modified and should be under our control when an SW upgrade is
> > > performed.
> > > 
> > > Cloning every ebuild where we have modified its conf file(s) under /etc
> > > feels awkward so
> > > I am looking for some other way to do this automatically during SW
> > > upgrade and I figured
> > > this can not be an unique problem for us, so I wonder how other people
> > > have solved this problem?
> > > Our customers will not use emerge directly and we will provide binary
> > > pkgs.
> > > 
> > > Any ideas welcome :)
> > > 
> > > Jocke
> > 
> > Maybe post-phase hooks would help you. Not around a PC right now but I 
> > think they're described in portage.5. 
> > Long story short, you create per-package env files in /etc/portage/env (you 
> > can pin them generically or to a 
> > specific version, or package spec via package.env) and declare 
> > post_src_install() where you add your custom 
> > config files atop the package.  
> > 
> 
> hmm, that sounds interesting but I don't quite get what to do, you think I 
> should copy over /etc/inittab after
> it has been installed by sys-apps/sysvinit with my own version(which is 
> stored where?)
> 
> This gave me an idea though:
> In /etc/portage/env/install-mask.conf I add
>   INSTALL_MASK="${INSTALL_MASK} /etc/inittab /etc/xxx"
> then in /etc/portage/package.env/install-mask
>   sys-apps/sysvinit install-mask.conf
>   sys-apps/xxx install-mask.conf
>   ...
> (Can I do this from my own custom profile instead? how?)
> 
> This should prevent sys-apps/sysvinit to install conf files I want to manage, 
> right?
> 
> Then I create my own new ebuild holding all config files I have changed 
> myself.
> 
>  Jocke
> 
>  

You can do much more in these environment files. Here is an ugly example from 
my BeagleBone Black. Note that since I'm not declaring any functions here, all 
this code is not saved in environment and as a result in binary package (except 
_distcc_wrapper variable :) ). I'm not sure it is a good idea to declare 
standard phase functions in env files.

$ cat /etc/portage/env/sys-devel/distcc 
_distcc_wrapper=${CHOST}-wrapper
case "${EBUILD_PHASE}" in
    postinst)
        cd "${EROOT}usr/lib/distcc/bin" && {
            cat <<EOF > "${_distcc_wrapper}"
#!/bin/bash
exec ${EROOT}usr/lib/distcc/bin/${CHOST}-g\${0:\$[-2]} "\$@"
EOF
            chmod 0755 "${_distcc_wrapper}"
            rm -fv cc c++ gcc g++
            ln -s "${_distcc_wrapper}" cc
            ln -s "${_distcc_wrapper}" c++
            ln -s "${_distcc_wrapper}" gcc
            ln -s "${_distcc_wrapper}" g++
        } ;;
    prerm)
        cd "${EROOT}usr/lib/distcc/bin" && {
            rm -fv cc c++ gcc g++
            rm -fv "${_distcc_wrapper}"
        } ;;
esac

-- 
Alexander Tsoy

Reply via email to