Gentoo Archives: gentoo-dev

From: Aaron Walker <ka0ttic@g.o>
To: gentoo-dev <gentoo-dev@l.g.o>
Subject: [gentoo-dev] per-runlevel make.conf settings
Date: Tue, 09 Nov 2004 10:26:32
Message-Id: 41909B54.5050405@gentoo.org
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Hey folks,
5
6 I had this idea a while ago, to solve the problem of having different
7 make.conf settings per-runlevel. I was bored at work last night, so
8 finally decided to implement it. Figured I'd post it, since others
9 might also find it useful (not to mention offer suggestions, comments, etc).
10
11 With my laptop, I use different runlevels, depending on where I'm at
12 (work, home, etc). I used to just have an rc script that symlinked
13 make.conf to the appropriate one, but this solution is definitely better,
14 although still not perfect.
15
16 make.conf.common - settings common to all make.conf's
17 make.conf.$runlevel - per-runlevel settings, where $runlevel is the current
18 runlevel.
19
20 There are obviously certain settings you wouldn't want to differ, like
21 CFLAGS, CHOST, etc, which should go in make.conf.common.
22
23 The following is example contents for a common file, one for default
24 runlevel, and one for a "work" runlevel.
25
26 <make.conf.common>
27 # vim: set ft=conf
28 CFLAGS="-O2 -march=athlon-xp -pipe"
29 CXXFLAGS="${CFLAGS}"
30 CHOST="i686-pc-linux-gnu"
31 USE="blah blah blah"
32 FEATURES="ccache collision-protect sfperms strict"
33 GENTOO_MIRRORS="ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo \
34 ~ ftp://gentoo.chem.wisc.edu/gentoo"
35 </make.conf.common>
36
37 <make.conf.default>
38 FEATURES="${FEATURES} distcc cvs digest sign"
39 MAKEOPTS="-j5"
40 PORTAGE_GPG_DIR="/home/ka0ttic/.gnupg"
41 PORTAGE_GPG_KEY="ED34A45E"
42 SYNC=rsync://zeus/gentoo-portage
43 GENTOO_MIRRORS="http://zeus/gentoo/ \
44 ${GENTOO_MIRRORS}"
45 </make.conf.default>
46
47 <make.conf.work>
48 MAKEOPTS="-j2"
49 SYNC=rsync://some_rsync_server_only_accessible_from_work/gentoo-portage
50 DISTDIR="/path/to/some/nfs/mounted/distdir"
51 </make.conf.work>
52
53 As you can see, you can do cool stuff like override variables, or extend
54 variables (eg FEATURES in make.conf.default).
55
56 We can then create an amazingly simple init script that automatically
57 generates /etc/make.conf depending on runlevel:
58
59 <makeconfgen>
60 #!/sbin/runscript
61
62 depend() {
63 ~ before local
64 }
65
66 start() {
67 ~ local rv=0 runlevel=$(< ${svcdir}/softlevel)
68
69 ~ ebegin "Generating make.conf for $runlevel runlevel"
70
71 ~ # save existing make.conf just in case
72 ~ [ -e /etc/make.conf ] && \
73 ~ mv /etc/make.conf /etc/make.conf.save || rv=1
74 ~ # common stuff
75 ~ [ -f /etc/make.conf.common ] && \
76 ~ cat /etc/make.conf.common > /etc/make.conf || rv=1
77 ~ # runlevel stuff
78 ~ [ -f /etc/make.conf.$runlevel ] && \
79 ~ cat /etc/make.conf.$runlevel >> /etc/make.conf || rv=1
80
81 ~ eend $rv
82 }
83 </makeconfgen>
84
85 The only caveat I can think of at the moment (I'm sure there's more) is
86 that you must remember to 'rc-update add' it each runlevel you want one
87 generated for. Otherwise, the make.conf will be the previously generated
88 one.
89
90 Comments/suggestions/flames?
91
92 Toodles
93 - --
94 You will have many recoverable tape errors.
95
96 Aaron Walker < ka0ttic@g.o > http://dev.gentoo.org/~ka0ttic/
97 Gentoo/BSD | cron | shell-tools http://butsugenjitemple.org/~ka0ttic/
98
99 -----BEGIN PGP SIGNATURE-----
100 Version: GnuPG v1.2.6 (GNU/Linux)
101 Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
102
103 iD8DBQFBkJtUC3poscuANHARAoiUAKCLV+6aKwGuW14wRcsEqNz5/EYOGACgs9XC
104 Pr/dx+PbEkxvtkBsXGaAb78=
105 =hGZ3
106 -----END PGP SIGNATURE-----
107
108 --
109 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] per-runlevel make.conf settings Aron Griffis <agriffis@g.o>