Ticket #34900: Portfile.2

File Portfile.2, 12.6 KB (added by ctreleaven (Craig Treleaven), 12 years ago)

Updated.

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id$
3PortSystem          1.0
4PortGroup           github 1.0 
5PortGroup                       qt4 1.0
6
7set shorthash           6a9af026
8# set fullhash          6a9af0260bf4d7c80e77a7889e999c4f0bb91867
9set majorversion        .25
10set minorversion        .1
11github.setup            MythTV mythtv ${shorthash}
12name                mythtv-core${majorversion}
13version             0${majorversion}${minorversion}-Fixes-20120615
14categories          multimedia
15platforms           darwin
16license             GPL-2
17maintainers         cogeco.ca:ctreleaven openmaintainer
18
19description         MythTV - Open source digital video recorder
20long_description    The ultimate Digital Video Recorder and home media \
21                    center hub. Think of it as a Free and Open Source alternative \
22                    to Windows Media Center or Tivo. With its plugin architecture, \
23                    it has been extended from a mere TV viewing application into a \
24                    full home media center suite, capable of managing your personal \
25                    photo, video, and music collections, as well as keep you up to \
26                    date with the weather, a ZoneMinder home security system, and \
27                    more. 
28
29homepage            http://www.mythtv.org/
30checksums           rmd160  f47519e860d7efa21a646d9719548f0db2e4111a \
31                    sha256  d6b2172f9fc30c5a0beb2c6e36519c580e6bb60324fbf4ed232fc40e3f7d381b
32
33pre-fetch {
34        if {! [file exists ${prefix}/share/qt4/plugins/sqldrivers/libqsqlmysql.dylib] } {
35        return -code error "Must have Qt4-mac installed with MySQL support!  (Eg. port install qt4-mac +mysql)"
36        }
37}
38
39set nick                        mythtv
40set mythtvhomedir       ${prefix}/var/mythtvuser
41set mythtvlogdir        ${prefix}/var/log/${nick}${majorversion}
42set mythtvpiddir        ${prefix}/var/run/${nick}${majorversion}
43set mythtvpidfile       $mythtvpiddir/${nick}
44set plistDir            ${prefix}/Library/LaunchDaemons
45set plistFl             ${plistDir}/org.mythtv.mythbackend.plist
46set mythverstring       v0${majorversion}${minorversion}-${shorthash}-MacPorts
47set mythbranch          fixes/0${majorversion}
48
49depends_lib         port:libdvdcss \
50                    port:freetype \
51                    port:lame \
52                    port:x264 \
53                    port:qt4-mac \
54                    port:py26-mysql \
55                    port:py26-lxml \
56                    port:py26-urlgrabber \
57                    port:p5.12-dbd-mysql \
58                    port:p5.12-http-request-ascgi \
59                    port:p5.12-lwp-useragent-determined \
60                    port:p5.12-io-socket-inet6 \
61                                        port:p5.12-net-upnp
62
63depends_build       port:yasm
64
65patchfiles                      patch-bindings-python-mythtv-utility.diff \
66                                        patch-greedyh.asm.diff
67#                                       patch-mythtv_configure.diff \  << Todo: distcc/ccache s/b set by MacPorts
68# patch-bindings-python-mythtv-utility.diff  see http://code.mythtv.org/trac/ticket/10737
69#       Fixed 2012May21 in master fff02e698418de20a918480694ac74661ce666db; not fixes/0.25
70# patch-greedyh.asm.diff  see http://code.mythtv.org/trac/ticket/10762
71#   Fixed 2012Jun15 in master 12a3eac312d06257ba1dca771ee710eacda6ce1e
72
73post-patch {
74        set sedPath ${worksrcpath}/mythtv/
75        ui_info "Make Myth utils use MacPorts Perl"
76        set myPerls [list  "${sedPath}bindings/perl/Makefile.PL"  \
77                "${sedPath}bindings/perl/MythTV.pm"  \
78                "${sedPath}programs/scripts/internetcontent/topdocumentaryfilm.pl"  \
79                "${sedPath}programs/scripts/internetcontent/twit.tv.pl"  \
80                "${sedPath}contrib/maintenance/optimize_mythdb.pl"  \
81                "${sedPath}contrib/user_jobs/mythlink.pl"  \
82                "${sedPath}programs/scripts/database/mythconverg_backup.pl" \
83                "${sedPath}programs/scripts/database/mythconverg_restore.pl"
84        ]
85        foreach f $myPerls {
86            reinplace "s|#!/usr/bin/perl|#!${prefix}/bin/perl5.12|" ${f}
87        }
88        reinplace "s|/usr/local/|${prefix}/|"           ${sedPath}programs/scripts/database/mythconverg_backup.pl
89        reinplace "s|\'/etc/|\'/private/etc/|"          ${sedPath}programs/scripts/database/mythconverg_backup.pl
90        reinplace "s|\'mysqldump\'|\'mysqldump5\'|"     ${sedPath}programs/scripts/database/mythconverg_backup.pl
91        reinplace "s|/usr/local/|${prefix}/|"           ${sedPath}programs/scripts/database/mythconverg_restore.pl
92        reinplace "s|\'/etc/|\'/private/etc/|"          ${sedPath}programs/scripts/database/mythconverg_restore.pl
93        reinplace "s|\'mysql\'|\'mysql5\'|"                     ${sedPath}programs/scripts/database/mythconverg_restore.pl
94
95        ui_info "Record Myth version strings"
96        reinplace "s#\${SOURCE_VERSION}#${mythverstring}#g" ${sedPath}version.sh
97        reinplace "s#\${BRANCH}#${mythbranch}#g" ${sedPath}version.sh
98
99        ui_info "Install Myth Python stuff to ${prefix}"
100        reinplace "s|/usr/local|${prefix}|" ${worksrcpath}/mythtv/bindings/python/MythTV/static.py
101       
102}
103
104# macosx_deployment_target 10.6         << ToDo: Python throws mismatch error if specified and != build os
105
106# Upstream has been working on clang compatibility but is not there yet
107# Eg http://code.mythtv.org/cgit/mythtv/commit/?id=12a3eac312d06257ba1dca771ee710eacda6ce1e
108if {${configure.compiler} == "llvm-gcc-4.2"} {
109    configure.compiler gcc-4.2
110} elseif {${configure.compiler} == "clang"} {
111    depends_build-append port:apple-gcc42
112    depends_skip_archcheck-append apple-gcc42
113    configure.compiler apple-gcc-4.2
114}
115
116configure.dir       ${worksrcpath}/mythtv
117configure.args      --compile-type=release \
118                                        --runprefix=${prefix} \
119                                        --cc=${configure.cc} \
120                                        --cxx=${configure.cxx} \
121                                        --extra-ldflags='-F/System/Library/Frameworks' \
122                                        --python=${prefix}/bin/python2.6 \
123                                        --disable-distcc \
124                                        --disable-firewire \
125                                        --disable-audio-jack --disable-indev=jack \
126                                        --enable-libmp3lame --enable-libx264
127#                                       --enable-nonfree  --enable-libfaac                      << ToDo:  optional variant??
128# some MacPorts users may have Jack installed
129
130build.dir           ${worksrcpath}/mythtv
131
132destroot.destdir    INSTALL_ROOT=${destroot}
133
134post-destroot {
135# install the launchd plist for the backend
136        ui_info "Installing startupitem/launchd plist..."
137    xinstall -d -m 0755 ${destroot}${plistDir}
138    reinplace "s|/opt/local|${prefix}|g" ${filespath}/org.${nick}.mythbackend.plist
139    xinstall -c ${filespath}/org.${nick}.mythbackend.plist ${destroot}${plistDir}
140
141# install scripts we want in share/contrib
142        ui_info "Installing share/$name/contrib scripts..."
143
144        xinstall -d -m 755 ${destroot}${prefix}/share/${nick}/database
145        xinstall -d -m 755 ${destroot}${prefix}/share/${nick}/contrib
146
147        xinstall -c -m 755 \
148                ${configure.dir}/database/mc.sql \
149                ${destroot}${prefix}/share/${nick}/database/
150        xinstall -c -m 755 \
151                ${configure.dir}/contrib/maintenance/optimize_mythdb.pl \
152                ${configure.dir}/contrib/user_jobs/mythlink.pl \
153                ${destroot}${prefix}/share/${nick}/contrib/
154
155# install some simple Applescripts to launch common myth apps
156        ui_info "Installing Applescript helpers..."
157        # compile the Applescripts
158        xinstall -m 755 -d ${destroot}${applications_dir}/${nick}${majorversion}
159
160        system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Frontend.app ${filespath}/Myth_Frontend.scpt"
161        system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Frontend_Logging.app ${filespath}/Myth_Frontend_Logging.scpt"
162        system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Filldatabase.app ${filespath}/Myth_Filldatabase.scpt"
163        system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Setup.app ${filespath}/Myth_Setup.scpt"
164        system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Stop_Start.app ${filespath}/Myth_Stop_Start.scpt"
165
166# Myth custom icon for a couple of the applets
167    copy -force ${configure.dir}/programs/mythfrontend/mythfrontend.icns ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Frontend.app/Contents/Resources/applet.icns
168    copy -force ${configure.dir}/programs/mythfrontend/mythfrontend.icns ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Stop_Start.app/Contents/Resources/applet.icns
169
170# make other directories myth will need
171        xinstall -d -m 755 ${destroot}${mythtvhomedir}
172        xinstall -d -m 755 ${destroot}${mythtvlogdir}
173        xinstall -d -m 755 ${destroot}${mythtvpiddir}
174
175    destroot.keepdirs \
176                ${destroot}${prefix}/share/${nick}/contrib \
177        ${destroot}${mythtvhomedir} \
178                ${destroot}${mythtvlogdir} \
179                ${destroot}${mythtvpiddir} \
180                ${destroot}${applications_dir}/${nick}${majorversion}
181
182# Fix up library entries in dylibs and executables ...
183# need to loop on arch's if/when build universal ?!?
184    set libdir ${prefix}/lib
185
186        ui_info "Correcting library entries in dylibs..."
187
188    foreach {dylib} [glob -types f -tails -directory ${destroot}${libdir} *.dylib] {
189        # glob gives us both files and links to files
190                if { [file type ${destroot}${libdir}/${dylib}] == "file" } {
191                ui_debug "... for ${dylib}"
192            system "install_name_tool -id ${libdir}/${dylib} ${destroot}${libdir}/${dylib}"
193               
194                set otool [lrange [split [exec otool -L ${destroot}${libdir}/${dylib}] \n] 2 end]
195               
196                foreach {otoolentry} ${otool} {
197                        # fix entries like "libmythswscale.dylib" to "${prefix}/lib/libmythswscale.dylib"
198                        # assume anything without a leading slash needs fixing
199                        set firstchar [string range [string trimleft ${otoolentry}] 0 0]
200                        if  { ${firstchar} != "/" }  {
201                        set lib [lindex ${otoolentry} 0]
202                                        ui_debug "      Change ${lib}  to  ${libdir}/[file tail ${lib}]"
203                        system "install_name_tool -change \
204                                ${lib} \
205                                ${libdir}/[file tail ${lib}] \
206                                ${destroot}${libdir}/${dylib}"
207                    }
208                }
209        }
210    }
211    set bindir ${prefix}/bin
212        ui_info "Correcting library entries in executables..."
213
214    foreach {prog} [glob -types f -tails -directory ${destroot}${bindir} *] {
215        # glob gives us files and links to files but should be no links in bin dir
216                ui_debug "... for ${prog}"
217               
218        set otool [lrange [split [exec otool -L ${destroot}${bindir}/${prog}] \n] 2 end]
219               
220        foreach {otoolentry} ${otool} {
221                # fix entries like "libmythswscale.dylib" to "${prefix}/lib/libmythswscale.dylib"
222                # assume anything without a leading slash needs fixing
223                set firstchar [string range [string trimleft ${otoolentry}] 0 0]
224                if  { ${firstchar} != "/" }  {
225                    set lib [lindex ${otoolentry} 0]
226                                ui_debug "      Change ${lib} to ${libdir}/[file tail ${lib}]"
227                system "install_name_tool -change \
228                        ${lib} \
229                        ${libdir}/[file tail ${lib}] \
230                        ${destroot}${bindir}/${prog}"
231                }
232        }
233    }
234
235# fix lib entries in filters
236    set fltdir ${prefix}/lib/mythtv/filters
237    set liblist [glob -types f -tails -directory ${destroot}${libdir} -- *.dylib]
238        ui_info "Correcting library entries in plugins..."
239
240    foreach {flt} [glob -types f -tails -directory ${destroot}${fltdir} *] {
241        # glob gives us files and links to files but should be no links in filters dir
242                ui_debug "... for ${flt}"
243               
244        set otool [lrange [split [exec otool -L ${destroot}${fltdir}/${flt}] \n] 2 end]
245               
246        foreach {otoolentry} ${otool} {
247                # fix entries like "libmythswscale.dylib" to "${prefix}/lib/libmythswscale.dylib"
248                # assume anything without a leading slash needs fixing
249                set firstchar [string range [string trimleft ${otoolentry}] 0 0]
250                if  { ${firstchar} != "/" }  {
251                    set lib [lindex ${otoolentry} 0]
252                    if { [ lsearch $liblist ${lib} ] > 0 } {
253                        set goodprefix ${libdir}
254                    } else {
255                        set goodprefix ${fltdir}
256                    }
257                                ui_debug "      Change ${lib} to ${goodprefix}/[file tail ${lib}]"
258                        system "install_name_tool -change \
259                                ${lib} \
260                                ${goodprefix}/[file tail ${lib}] \
261                        ${destroot}${fltdir}/${flt}"
262                }
263        }
264    }
265}
266
267universal_variant               no
268
269variant mysql_server description {Include database server software.} {
270          depends_run-append            port:mysql51-server
271# add backup and maintenance script!!
272}
273
274# variant mythweb  description {Web-based access and control of MythTV} {
275#         depends_run-append            port:mythweb.25   <<== ToDo!
276#}
277
278#default_variants +mysql_server
279
280# startupitem.create                    yes
281# Need two environment variables set => roll our own plist
282
283post-activate {
284        ln -s ${plistFl} /Library/LaunchDaemons
285}
286
287pre-deactivate {
288         file delete -force /Library/LaunchDaemons/org.mythtv.mythbackend.plist
289# should throw error if mythbackend running!
290}
291
292notes "############################################################################
293#
294# See http://www.mythtv.org/wiki/Myth_for_Mac_with_MacPorts for information
295# essential to finishing the installation of MythTV!
296#
297# NB -
298# For troubleshooting, all Myth-related logs are stored in
299# ${mythtvlogdir}
300#
301############################################################################"