Ticket #34900: Portfile.3

File Portfile.3, 13.1 KB (added by neverpanic (Clemens Lang), 12 years ago)
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-extract {
74    file mkdir ${worksrcpath}/MacPorts
75    foreach filename {Myth_Frontend.applescript Myth_Frontend_Logging.applescript Myth_Filldatabase.applescript Myth_Setup.applescript Myth_Stop_Start.applescript} {
76        copy ${filesdir}/${filename} ${worksrcpath}/MacPorts
77    }
78}
79
80post-patch {
81    set sedPath ${worksrcpath}/mythtv/
82    ui_debug "Make Myth utils use MacPorts Perl"
83
84    reinplace "s|#!/usr/bin/perl|#!${prefix}/bin/perl5.12|" \
85        "${sedPath}bindings/perl/Makefile.PL"  \
86        "${sedPath}bindings/perl/MythTV.pm"  \
87        "${sedPath}programs/scripts/internetcontent/topdocumentaryfilm.pl"  \
88        "${sedPath}programs/scripts/internetcontent/twit.tv.pl"  \
89        "${sedPath}contrib/maintenance/optimize_mythdb.pl"  \
90        "${sedPath}contrib/user_jobs/mythlink.pl"  \
91        "${sedPath}programs/scripts/database/mythconverg_backup.pl" \
92        "${sedPath}programs/scripts/database/mythconverg_restore.pl"
93
94    reinplace "s|/usr/local/|${prefix}/|"       ${sedPath}programs/scripts/database/mythconverg_backup.pl
95    reinplace "s|\'mysqldump\'|\'mysqldump5\'|" ${sedPath}programs/scripts/database/mythconverg_backup.pl
96    reinplace "s|/usr/local/|${prefix}/|"       ${sedPath}programs/scripts/database/mythconverg_restore.pl
97    reinplace "s|\'mysql\'|\'mysql5\'|"         ${sedPath}programs/scripts/database/mythconverg_restore.pl
98
99    reinplace "s|/Applications/MacPorts|${applications_dir}|" ${worksrcpath}/MacPorts/Myth_Frontend_Logging.applescript
100
101    ui_debug "Record Myth version strings"
102    reinplace "s#\${SOURCE_VERSION}#${mythverstring}#g" ${sedPath}version.sh
103    reinplace "s#\${BRANCH}#${mythbranch}#g" ${sedPath}version.sh
104
105    ui_debug "Install Myth Python stuff to ${prefix}"
106    reinplace "s|/usr/local|${prefix}|" ${worksrcpath}/mythtv/bindings/python/MythTV/static.py
107}
108
109# macosx_deployment_target 10.6     << ToDo: Python throws mismatch error if specified and != build os
110
111# Upstream has been working on clang compatibility but is not there yet
112# Eg http://code.mythtv.org/cgit/mythtv/commit/?id=12a3eac312d06257ba1dca771ee710eacda6ce1e
113compiler.blacklist  clang
114
115configure.dir       ${worksrcpath}/mythtv
116configure.args      --compile-type=release \
117                    --runprefix=${prefix} \
118                    --cc=${configure.cc} \
119                    --cxx=${configure.cxx} \
120                    --extra-ldflags='-F/System/Library/Frameworks' \
121                    --python=${prefix}/bin/python2.6 \
122                    --disable-distcc \
123                    --disable-firewire \
124                    --disable-audio-jack --disable-indev=jack \
125                    --enable-libmp3lame --enable-libx264
126#                   --enable-nonfree  --enable-libfaac      << ToDo:  optional variant??
127#                   some MacPorts users may have Jack installed
128
129build.dir           ${worksrcpath}/mythtv
130
131destroot.destdir    INSTALL_ROOT=${destroot}
132
133destroot.keepdirs   ${destroot}${mythtvhomedir} \
134                    ${destroot}${mythtvlogdir} \
135                    ${destroot}${mythtvpiddir}
136
137post-destroot {
138    # install the launchd plist for the backend
139    ui_debug "Installing startupitem/launchd plist..."
140    xinstall -d -m 0755 ${destroot}${plistDir}
141    xinstall -m 0644 ${filespath}/org.${nick}.mythbackend.plist ${destroot}${plistDir}
142    reinplace "s|/opt/local|${prefix}|g" ${destroot}${plistFl}
143    ln -s ${destroot}${plistFl} ${destroot}/Library/LaunchDaemons
144
145    # install scripts we want in share/contrib
146    ui_debug "Installing share/$name/contrib scripts..."
147
148    xinstall -d -m 755 ${destroot}${prefix}/share/${nick}/database
149    xinstall -d -m 755 ${destroot}${prefix}/share/${nick}/contrib
150
151    xinstall -m 755 \
152        ${configure.dir}/database/mc.sql \
153        ${destroot}${prefix}/share/${nick}/database/
154    xinstall -m 755 \
155        ${configure.dir}/contrib/maintenance/optimize_mythdb.pl \
156        ${configure.dir}/contrib/user_jobs/mythlink.pl \
157        ${destroot}${prefix}/share/${nick}/contrib/
158
159    # install some simple Applescripts to launch common myth apps
160    ui_debug "Installing Applescript helpers..."
161    # compile the Applescripts
162    xinstall -m 755 -d ${destroot}${applications_dir}/${nick}${majorversion}
163
164    system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Frontend.app ${worksrcpath}/MacPorts/Myth_Frontend.scpt"
165    system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Frontend_Logging.app ${worksrcpath}/MacPorts/Myth_Frontend_Logging.scpt"
166    system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Filldatabase.app ${worksrcpath}/MacPorts/Myth_Filldatabase.scpt"
167    system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Setup.app ${worksrcpath}/MacPorts/Myth_Setup.scpt"
168    system "osacompile -x -o ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Stop_Start.app ${worksrcpath}/MacPorts/Myth_Stop_Start.scpt"
169
170    # Myth custom icon for a couple of the applets
171    copy -force ${configure.dir}/programs/mythfrontend/mythfrontend.icns ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Frontend.app/Contents/Resources/applet.icns
172    copy -force ${configure.dir}/programs/mythfrontend/mythfrontend.icns ${destroot}${applications_dir}/${nick}${majorversion}/Myth_Stop_Start.app/Contents/Resources/applet.icns
173
174    # make other directories myth will need
175    xinstall -d -m 755 ${destroot}${mythtvhomedir}
176    xinstall -d -m 755 ${destroot}${mythtvlogdir}
177    xinstall -d -m 755 ${destroot}${mythtvpiddir}
178
179    # Fix up library entries in dylibs and executables ...
180    # need to loop on arch's if/when build universal ?!?
181    set libdir ${prefix}/lib
182
183    ui_debug "Correcting library entries in dylibs..."
184
185    foreach {dylib} [glob -types f -tails -directory ${destroot}${libdir} *.dylib] {
186        # glob gives us both files and links to files
187        if { [file type ${destroot}${libdir}/${dylib}] == "file" } {
188            ui_debug "... for ${dylib}"
189            system "install_name_tool -id ${libdir}/${dylib} ${destroot}${libdir}/${dylib}"
190
191            set otool [lrange [split [exec otool -L ${destroot}${libdir}/${dylib}] \n] 2 end]
192
193            foreach {otoolentry} ${otool} {
194                # fix entries like "libmythswscale.dylib" to "${prefix}/lib/libmythswscale.dylib"
195                # assume anything without a leading slash needs fixing
196                set firstchar [string range [string trimleft ${otoolentry}] 0 0]
197                if  { ${firstchar} != "/" }  {
198                    set lib [lindex ${otoolentry} 0]
199                    ui_debug "      Change ${lib}  to  ${libdir}/[file tail ${lib}]"
200                    system "install_name_tool -change \
201                        ${lib} \
202                        ${libdir}/[file tail ${lib}] \
203                        ${destroot}${libdir}/${dylib}"
204                }
205            }
206        }
207    }
208    set bindir ${prefix}/bin
209    ui_debug "Correcting library entries in executables..."
210
211    foreach {prog} [glob -types f -tails -directory ${destroot}${bindir} *] {
212        # glob gives us files and links to files but should be no links in bin dir
213        ui_debug "... for ${prog}"
214
215        set otool [lrange [split [exec otool -L ${destroot}${bindir}/${prog}] \n] 2 end]
216
217        foreach {otoolentry} ${otool} {
218            # fix entries like "libmythswscale.dylib" to "${prefix}/lib/libmythswscale.dylib"
219            # assume anything without a leading slash needs fixing
220            set firstchar [string range [string trimleft ${otoolentry}] 0 0]
221            if  { ${firstchar} != "/" }  {
222                set lib [lindex ${otoolentry} 0]
223                ui_debug "      Change ${lib} to ${libdir}/[file tail ${lib}]"
224                system "install_name_tool -change \
225                    ${lib} \
226                    ${libdir}/[file tail ${lib}] \
227                    ${destroot}${bindir}/${prog}"
228            }
229        }
230    }
231
232    # fix lib entries in filters
233    set fltdir ${prefix}/lib/mythtv/filters
234    set liblist [glob -types f -tails -directory ${destroot}${libdir} -- *.dylib]
235    ui_debug "Correcting library entries in plugins..."
236
237    foreach {flt} [glob -types f -tails -directory ${destroot}${fltdir} *] {
238        # glob gives us files and links to files but should be no links in filters dir
239        ui_debug "... for ${flt}"
240
241        set otool [lrange [split [exec otool -L ${destroot}${fltdir}/${flt}] \n] 2 end]
242
243        foreach {otoolentry} ${otool} {
244            # fix entries like "libmythswscale.dylib" to "${prefix}/lib/libmythswscale.dylib"
245            # assume anything without a leading slash needs fixing
246            set firstchar [string range [string trimleft ${otoolentry}] 0 0]
247            if  { ${firstchar} != "/" }  {
248                set lib [lindex ${otoolentry} 0]
249                if { [ lsearch $liblist ${lib} ] > 0 } {
250                    set goodprefix ${libdir}
251                } else {
252                    set goodprefix ${fltdir}
253                }
254                ui_debug "      Change ${lib} to ${goodprefix}/[file tail ${lib}]"
255                system "install_name_tool -change \
256                    ${lib} \
257                    ${goodprefix}/[file tail ${lib}] \
258                    ${destroot}${fltdir}/${flt}"
259            }
260        }
261    }
262}
263
264universal_variant   no
265
266variant mysql_server description {Include database server software.} {
267    depends_run-append  port:mysql51-server
268    # add backup and maintenance script!!
269}
270
271# variant mythweb  description {Web-based access and control of MythTV} {
272#   depends_run-append  port:mythweb.25   <<== ToDo!
273#}
274
275#default_variants +mysql_server
276
277notes "############################################################################
278#
279# See http://www.mythtv.org/wiki/Myth_for_Mac_with_MacPorts for information
280# essential to finishing the installation of MythTV!
281#
282# NB -
283# For troubleshooting, all Myth-related logs are stored in
284# ${mythtvlogdir}
285#
286############################################################################"