| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2005 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/vdr-plugin.eclass,v 1.7 2005/10/28 08:58:19 zzam Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/vdr-plugin.eclass,v 1.9 2005/11/20 16:41:38 zzam Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: |
5 | # Author: |
| 6 | # Matthias Schwarzott <zzam@gentoo.org> |
6 | # Matthias Schwarzott <zzam@gentoo.org> |
| 7 | |
7 | |
| 8 | # vdr-plugin.eclass |
8 | # vdr-plugin.eclass |
| … | |
… | |
| 200 | } |
200 | } |
| 201 | |
201 | |
| 202 | vdr-plugin_pkg_postinst() { |
202 | vdr-plugin_pkg_postinst() { |
| 203 | update_vdrplugindb |
203 | update_vdrplugindb |
| 204 | einfo |
204 | einfo |
| 205 | einfo "The vdr plugin ${VDRPLUGIN} has now been installed," |
205 | einfo "The vdr plugin ${VDRPLUGIN} has now been installed." |
| 206 | einfo "to activate it you have to add it to /etc/conf.d/vdr." |
206 | einfo "To activate execute the following command:" |
|
|
207 | einfo |
|
|
208 | einfo " emerge --config ${PN}" |
| 207 | einfo |
209 | einfo |
| 208 | } |
210 | } |
| 209 | |
211 | |
| 210 | vdr-plugin_pkg_postrm() { |
212 | vdr-plugin_pkg_postrm() { |
| 211 | remove_vdrplugindb |
213 | remove_vdrplugindb |
| 212 | } |
214 | } |
| 213 | |
215 | |
|
|
216 | vdr-plugin_pkg_config_final() { |
|
|
217 | diff ${conf_orig} ${conf} |
|
|
218 | rm ${conf_orig} |
|
|
219 | } |
|
|
220 | |
|
|
221 | vdr-plugin_pkg_config() { |
|
|
222 | if [[ -z "${INSTALLPLUGIN}" ]]; then |
|
|
223 | INSTALLPLUGIN="${VDRPLUGIN}" |
|
|
224 | fi |
|
|
225 | # First test if plugin is already inside PLUGINS |
|
|
226 | local conf=/etc/conf.d/vdr |
|
|
227 | conf_orig=${conf}.before_emerge_config |
|
|
228 | cp ${conf} ${conf_orig} |
|
|
229 | |
|
|
230 | einfo "Reading ${conf}" |
|
|
231 | if ! grep -q "^PLUGINS=" ${conf}; then |
|
|
232 | local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1) |
|
|
233 | if [[ -n "${LINE}" ]]; then |
|
|
234 | sed -e ${LINE}'a PLUGINS=""' -i ${conf} |
|
|
235 | else |
|
|
236 | echo 'PLUGINS=""' >> ${conf} |
|
|
237 | fi |
|
|
238 | unset LINE |
|
|
239 | fi |
|
|
240 | |
|
|
241 | unset PLUGINS |
|
|
242 | PLUGINS=$(source /etc/conf.d/vdr; echo ${PLUGINS}) |
|
|
243 | |
|
|
244 | active=0 |
|
|
245 | for p in ${PLUGINS}; do |
|
|
246 | if [[ "${p}" == "${INSTALLPLUGIN}" ]]; then |
|
|
247 | active=1 |
|
|
248 | break; |
|
|
249 | fi |
|
|
250 | done |
|
|
251 | |
|
|
252 | if [[ "${active}" == "1" ]]; then |
|
|
253 | einfo "${INSTALLPLUGIN} already activated" |
|
|
254 | echo |
|
|
255 | read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer |
|
|
256 | if [[ "${answer}" != "yes" ]]; then |
|
|
257 | einfo "aborted" |
|
|
258 | return |
|
|
259 | fi |
|
|
260 | einfo "Removing ${INSTALLPLUGIN} from active plugins." |
|
|
261 | local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1) |
|
|
262 | sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \ |
|
|
263 | -e ${LINE}'s/ \( \)*/ /g' \ |
|
|
264 | -e ${LINE}'s/ "/"/g' \ |
|
|
265 | -e ${LINE}'s/" /"/g' |
|
|
266 | |
|
|
267 | vdr-plugin_pkg_config_final |
|
|
268 | return |
|
|
269 | fi |
|
|
270 | |
|
|
271 | |
|
|
272 | einfo "Adding ${INSTALLPLUGIN} to active plugins." |
|
|
273 | local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1) |
|
|
274 | sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \ |
|
|
275 | -e ${LINE}'s/ \( \)*/ /g' \ |
|
|
276 | -e ${LINE}'s/ "/"/g' \ |
|
|
277 | -e ${LINE}'s/" /"/g' |
|
|
278 | |
|
|
279 | vdr-plugin_pkg_config_final |
|
|
280 | } |
|
|
281 | |
| 214 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm |
282 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config |