Gentoo Archives: gentoo-dev

From: Alexander Tsoy <alexander@××××.me>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Managing etc/* in an embbeded system
Date: Wed, 22 Jul 2015 15:09:48
Message-Id: 20150722180934.381aa448@work.puleglot.ru
In Reply to: Re: [gentoo-dev] Managing etc/* in an embbeded system by Joakim Tjernlund
1 В Wed, 22 Jul 2015 13:20:10 +0000
2 Joakim Tjernlund <joakim.tjernlund@×××××××××.se> пишет:
3
4 > On Wed, 2015-07-22 at 14:30 +0200, Michał Górny wrote:
5 > >
6 > > Joakim Tjernlund <joakim.tjernlund@×××××××××.se> napisał:
7 > >
8 > > > We got an embedded gentoo system where we need to manage many conf
9 > > > files under /etc that we have
10 > > > modified and should be under our control when an SW upgrade is
11 > > > performed.
12 > > >
13 > > > Cloning every ebuild where we have modified its conf file(s) under /etc
14 > > > feels awkward so
15 > > > I am looking for some other way to do this automatically during SW
16 > > > upgrade and I figured
17 > > > this can not be an unique problem for us, so I wonder how other people
18 > > > have solved this problem?
19 > > > Our customers will not use emerge directly and we will provide binary
20 > > > pkgs.
21 > > >
22 > > > Any ideas welcome :)
23 > > >
24 > > > Jocke
25 > >
26 > > Maybe post-phase hooks would help you. Not around a PC right now but I think they're described in portage.5.
27 > > Long story short, you create per-package env files in /etc/portage/env (you can pin them generically or to a
28 > > specific version, or package spec via package.env) and declare post_src_install() where you add your custom
29 > > config files atop the package.
30 > >
31 >
32 > hmm, that sounds interesting but I don't quite get what to do, you think I should copy over /etc/inittab after
33 > it has been installed by sys-apps/sysvinit with my own version(which is stored where?)
34 >
35 > This gave me an idea though:
36 > In /etc/portage/env/install-mask.conf I add
37 > INSTALL_MASK="${INSTALL_MASK} /etc/inittab /etc/xxx"
38 > then in /etc/portage/package.env/install-mask
39 > sys-apps/sysvinit install-mask.conf
40 > sys-apps/xxx install-mask.conf
41 > ...
42 > (Can I do this from my own custom profile instead? how?)
43 >
44 > This should prevent sys-apps/sysvinit to install conf files I want to manage, right?
45 >
46 > Then I create my own new ebuild holding all config files I have changed myself.
47 >
48 > Jocke
49 >
50 >
51
52 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.
53
54 $ cat /etc/portage/env/sys-devel/distcc
55 _distcc_wrapper=${CHOST}-wrapper
56 case "${EBUILD_PHASE}" in
57 postinst)
58 cd "${EROOT}usr/lib/distcc/bin" && {
59 cat <<EOF > "${_distcc_wrapper}"
60 #!/bin/bash
61 exec ${EROOT}usr/lib/distcc/bin/${CHOST}-g\${0:\$[-2]} "\$@"
62 EOF
63 chmod 0755 "${_distcc_wrapper}"
64 rm -fv cc c++ gcc g++
65 ln -s "${_distcc_wrapper}" cc
66 ln -s "${_distcc_wrapper}" c++
67 ln -s "${_distcc_wrapper}" gcc
68 ln -s "${_distcc_wrapper}" g++
69 } ;;
70 prerm)
71 cd "${EROOT}usr/lib/distcc/bin" && {
72 rm -fv cc c++ gcc g++
73 rm -fv "${_distcc_wrapper}"
74 } ;;
75 esac
76
77 --
78 Alexander Tsoy