| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/savedconfig.eclass,v 1.19 2012/01/04 07:45:16 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/savedconfig.eclass,v 1.21 2013/01/28 20:11:14 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: savedconfig.eclass |
5 | # @ECLASS: savedconfig.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org |
7 | # base-system@gentoo.org |
| 8 | # @BLURB: common API for saving/restoring complex configuration files |
8 | # @BLURB: common API for saving/restoring complex configuration files |
| … | |
… | |
| 11 | # grained level of configuration options that go way beyond what |
11 | # grained level of configuration options that go way beyond what |
| 12 | # USE flags can properly describe. For this purpose, a common API |
12 | # USE flags can properly describe. For this purpose, a common API |
| 13 | # of saving and restoring the configuration files was developed |
13 | # of saving and restoring the configuration files was developed |
| 14 | # so users can modify these config files and the ebuild will take it |
14 | # so users can modify these config files and the ebuild will take it |
| 15 | # into account as needed. |
15 | # into account as needed. |
|
|
16 | # |
|
|
17 | # @ROFF .nr step 1 1 |
|
|
18 | # Typically you can create your own configuration files quickly by |
|
|
19 | # doing: |
|
|
20 | # @ROFF .IP \n[step] 3 |
|
|
21 | # Build the package with FEATURES=noclean USE=savedconfig. |
|
|
22 | # @ROFF .IP \n+[step] |
|
|
23 | # Go into the build dir and edit the relevant configuration system |
|
|
24 | # (e.g. `make menuconfig` or `nano config-header.h`). You can look |
|
|
25 | # at the files in /etc/portage/savedconfig/ to see what files get |
|
|
26 | # loaded/restored. |
|
|
27 | # @ROFF .IP \n+[step] |
|
|
28 | # Copy the modified configuration files out of the workdir and to |
|
|
29 | # the paths in /etc/portage/savedconfig/. |
|
|
30 | # @ROFF .IP \n+[step] |
|
|
31 | # Emerge the package with just USE=savedconfig to get the custom build. |
| 16 | |
32 | |
| 17 | inherit portability |
33 | inherit portability |
| 18 | |
34 | |
| 19 | IUSE="savedconfig" |
35 | IUSE="savedconfig" |
| 20 | |
36 | |
| … | |
… | |
| 118 | ewarn "No saved config to restore - please remove USE=savedconfig or" |
134 | ewarn "No saved config to restore - please remove USE=savedconfig or" |
| 119 | ewarn "provide a configuration file in ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN}" |
135 | ewarn "provide a configuration file in ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN}" |
| 120 | ewarn "Your config file(s) will not be used this time" |
136 | ewarn "Your config file(s) will not be used this time" |
| 121 | fi |
137 | fi |
| 122 | } |
138 | } |
|
|
139 | |
|
|
140 | savedconfig_pkg_postinst() { |
|
|
141 | # If the user has USE=savedconfig, then chances are they |
|
|
142 | # are modifying these files, so keep them around. #396169 |
|
|
143 | # This might lead to cruft build up, but the alternatives |
|
|
144 | # are worse :/. |
|
|
145 | |
|
|
146 | if use savedconfig ; then |
|
|
147 | # Be lazy in our EAPI compat |
|
|
148 | : ${EROOT:=${ROOT}} |
|
|
149 | |
|
|
150 | find "${EROOT}/etc/portage/savedconfig/${CATEGORY}/${PF}" \ |
|
|
151 | -exec touch {} + 2>/dev/null |
|
|
152 | fi |
|
|
153 | } |
|
|
154 | |
|
|
155 | EXPORT_FUNCTIONS pkg_postinst |