| 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.1.1.1 2005/11/30 09:59:32 chriswhite Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/vdr-plugin.eclass,v 1.2 2005/08/07 13:55:43 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 |
| … | |
… | |
| 20 | # SRC_URI="http://www.saunalahti.fi/~rahrenbe/vdr/femon/files/${P}.tgz" |
20 | # SRC_URI="http://www.saunalahti.fi/~rahrenbe/vdr/femon/files/${P}.tgz" |
| 21 | # LICENSE="GPL-2" |
21 | # LICENSE="GPL-2" |
| 22 | # KEYWORDS="~x86" |
22 | # KEYWORDS="~x86" |
| 23 | # DEPEND=">=media-video/vdr-1.3.27" |
23 | # DEPEND=">=media-video/vdr-1.3.27" |
| 24 | # |
24 | # |
| 25 | # |
25 | # |
| 26 | |
26 | |
| 27 | # There are some special files in ${FILESDIR} which get installed when |
27 | # There are some special files in ${FILESDIR} which get installed when |
| 28 | # they exist: |
28 | # they exist: |
| 29 | |
29 | |
| 30 | # ${FILESDIR}/confd-${PV} or ${FILESDIR}/confd: |
30 | # ${FILESDIR}/confd-${PV} or ${FILESDIR}/confd: |
| … | |
… | |
| 34 | # Everything put in variable _EXTRAOPTS is appended to the command line of |
34 | # Everything put in variable _EXTRAOPTS is appended to the command line of |
| 35 | # the plugin. |
35 | # the plugin. |
| 36 | |
36 | |
| 37 | |
37 | |
| 38 | # ${FILESDIR}/rc-addon-${PV}.sh or ${FILESDIR}/rc-addon.sh: |
38 | # ${FILESDIR}/rc-addon-${PV}.sh or ${FILESDIR}/rc-addon.sh: |
| 39 | # The first matching is installed under /usr/lib/vdr/rcscript/plugin-${VDRPLUGIN}.sh |
39 | # The first matching is installed under /usr/lib/vdr/rcscript/vdr.${VDRPLUGIN}.sh |
| 40 | # (in example vdr-femon this would be /usr/lib/vdr/rcscript/plugin-femon.sh) |
40 | # (in example vdr-femon this would be /usr/lib/vdr/rcscript/vdr.femon.sh) |
| 41 | # |
41 | # |
| 42 | # This file is sourced by the startscript when plugin is activated in /etc/conf.d/vdr |
42 | # This file is sourced by the startscript when plugin is activated in /etc/conf.d/vdr |
| 43 | # It could be used for special startup actions for this plugins, or to create the |
43 | # It could be used for special startup actions for this plugins, or to create the |
| 44 | # plugin command line options from a nicer version of a conf.d file. |
44 | # plugin command line options from a nicer version of a conf.d file. |
| 45 | |
45 | |
| … | |
… | |
| 72 | DVB_INCLUDE_DIR="/usr/include" |
72 | DVB_INCLUDE_DIR="/usr/include" |
| 73 | |
73 | |
| 74 | |
74 | |
| 75 | # this code is from linux-mod.eclass |
75 | # this code is from linux-mod.eclass |
| 76 | update_vdrplugindb() { |
76 | update_vdrplugindb() { |
| 77 | local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/ |
77 | local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugins-rebuild/ |
| 78 | |
78 | |
| 79 | if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then |
79 | if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then |
| 80 | [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR} |
80 | [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR} |
| 81 | touch ${VDRPLUGINDB_DIR}/vdrplugindb |
81 | touch ${VDRPLUGINDB_DIR}/vdrplugindb |
| 82 | fi |
82 | fi |
| … | |
… | |
| 85 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb |
85 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb |
| 86 | fi |
86 | fi |
| 87 | } |
87 | } |
| 88 | |
88 | |
| 89 | remove_vdrplugindb() { |
89 | remove_vdrplugindb() { |
| 90 | local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/ |
90 | local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugins-rebuild/ |
| 91 | |
91 | |
| 92 | if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then |
92 | if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then |
| 93 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb." |
93 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb." |
| 94 | sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb |
94 | sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb |
| 95 | fi |
95 | fi |
| … | |
… | |
| 114 | ;; |
114 | ;; |
| 115 | patchmakefile) |
115 | patchmakefile) |
| 116 | cd ${S} |
116 | cd ${S} |
| 117 | |
117 | |
| 118 | ebegin "Patching Makefile" |
118 | ebegin "Patching Makefile" |
| 119 | sed -i.orig Makefile \ |
119 | sed -i Makefile \ |
| 120 | -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \ |
120 | -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \ |
| 121 | -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \ |
121 | -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \ |
| 122 | -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \ |
122 | -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \ |
| 123 | -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \ |
123 | -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \ |
| 124 | -e 's:^CXXFLAGS:#CXXFLAGS:' \ |
124 | -e 's:^CXXFLAGS:#CXXFLAGS:' \ |
| … | |
… | |
| 132 | |
132 | |
| 133 | shift |
133 | shift |
| 134 | done |
134 | done |
| 135 | } |
135 | } |
| 136 | |
136 | |
| 137 | vdr-plugin_copy_source_tree() { |
137 | vdr-plugin_src_compile() { |
| 138 | cp -r ${S} ${T}/source-tree |
138 | cd ${S} |
| 139 | cd ${T}/source-tree |
|
|
| 140 | mv Makefile.orig Makefile |
|
|
| 141 | sed -i Makefile \ |
|
|
| 142 | -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \ |
|
|
| 143 | -e 's:^CXXFLAGS:#CXXFLAGS:' \ |
|
|
| 144 | -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \ |
|
|
| 145 | -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' |
|
|
| 146 | } |
|
|
| 147 | |
139 | |
| 148 | vdr-plugin_install_source_tree() { |
|
|
| 149 | einfo "Installing sources" |
|
|
| 150 | destdir=${VDRSOURCE_DIR}/vdr-${VDRVERSION}/PLUGINS/src/${VDRPLUGIN} |
|
|
| 151 | insinto ${destdir}-${PV} |
|
|
| 152 | doins -r ${T}/source-tree/* |
|
|
| 153 | |
|
|
| 154 | dosym ${VDRPLUGIN}-${PV} ${destdir} |
|
|
| 155 | } |
|
|
| 156 | |
|
|
| 157 | vdr-plugin_src_compile() { |
|
|
| 158 | [ -z "$1" ] && vdr-plugin_src_compile prepare compile |
|
|
| 159 | |
|
|
| 160 | while [ "$1" ]; do |
|
|
| 161 | |
|
|
| 162 | case "$1" in |
|
|
| 163 | prepare) |
|
|
| 164 | [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_copy_source_tree |
|
|
| 165 | ;; |
|
|
| 166 | compile) |
|
|
| 167 | cd ${S} |
|
|
| 168 | |
|
|
| 169 | emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed" |
140 | emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed" |
| 170 | ;; |
|
|
| 171 | esac |
|
|
| 172 | |
|
|
| 173 | shift |
|
|
| 174 | done |
|
|
| 175 | } |
141 | } |
| 176 | |
142 | |
| 177 | vdr-plugin_src_install() { |
143 | vdr-plugin_src_install() { |
| 178 | [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_install_source_tree |
|
|
| 179 | cd ${S} |
144 | cd ${S} |
| 180 | |
145 | |
| 181 | insinto "${VDR_PLUGIN_DIR}" |
146 | insinto "${VDR_PLUGIN_DIR}" |
| 182 | doins libvdr-*.so.* |
147 | doins libvdr-*.so.* |
| 183 | dodoc README* HISTORY CHANGELOG |
148 | dodoc README* HISTORY CHANGELOG |
| … | |
… | |
| 191 | done |
156 | done |
| 192 | |
157 | |
| 193 | for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do |
158 | for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do |
| 194 | if [[ -f "${f}" ]]; then |
159 | if [[ -f "${f}" ]]; then |
| 195 | insinto "${VDR_RC_DIR}" |
160 | insinto "${VDR_RC_DIR}" |
| 196 | newins "${f}" plugin-${VDRPLUGIN}.sh |
161 | newins "${f}" vdr.${VDRPLUGIN}.sh |
| 197 | break |
162 | break |
| 198 | fi |
163 | fi |
| 199 | done |
164 | done |
| 200 | } |
165 | } |
| 201 | |
166 | |
| 202 | vdr-plugin_pkg_postinst() { |
167 | vdr-plugin_pkg_postinst() { |
| 203 | update_vdrplugindb |
168 | update_vdrplugindb |
| 204 | einfo |
169 | einfo |
| 205 | einfo "The vdr plugin ${VDRPLUGIN} has now been installed." |
170 | einfo "The vdr plugin ${VDRPLUGIN} has now been installed," |
| 206 | einfo "To activate execute the following command:" |
171 | einfo "to activate it you have to add it to /etc/conf.d/vdr." |
| 207 | einfo |
|
|
| 208 | einfo " emerge --config ${PN}" |
|
|
| 209 | einfo |
172 | einfo |
| 210 | } |
173 | } |
| 211 | |
174 | |
| 212 | vdr-plugin_pkg_postrm() { |
175 | vdr-plugin_pkg_postrm() { |
| 213 | remove_vdrplugindb |
176 | remove_vdrplugindb |
| 214 | } |
177 | } |
| 215 | |
178 | |
| 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 | |
|
|
| 282 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config |
179 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm |