source: trunk/dports/databases/oracle-instantclient/Portfile

Last change on this file was 153908, checked in by ryandesign@…, 13 months ago

oracle-instantclient: add cctools dependency on Leopard

This provides an install_name_tool that understands -add_rpath.

Resolves #52094

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.1 KB
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: Portfile 153908 2016-10-15 16:12:20Z ryandesign@macports.org $
3
4PortSystem              1.0
5
6name                    oracle-instantclient
7categories              databases
8platforms               macosx
9maintainers             ryandesign
10homepage                http://www.oracle.com/technetwork/database/features/instant-client/
11use_zip                 yes
12
13description \
14    Oracle database connection libraries
15
16long_description \
17    Oracle Instant Client allows you to run your applications without installing the standard Oracle client or having an ORACLE_HOME.
18
19if {${os.arch} eq "powerpc"} {
20    epoch               1
21    version             10.1.0.3
22    if {${os.major} > 8} {
23        revision        1
24    }
25    set library_version 10.1
26    supported_archs     ppc
27    universal_variant   no
28   
29    # The distfiles mirror has been configured not to mirror this port's files.
30    master_sites        http://cmsrep.cern.ch/cmssw/cms/SOURCES/external/oracle/10.2.0.2/
31   
32    checksums           instantclient-basic-macosx-${version}${extract.suffix} \
33                        rmd160  d1f056f8f1b308c5493f4938b29b55fcb32452cf \
34                        sha256  55dafdab1b7387b05226fd7eb0d86d52225a702a5e690fc82af42073f49e7725 \
35                        instantclient-sdk-macosx-${version}${extract.suffix} \
36                        rmd160  c819db7f739b8ca468c8059dfbac31a6a6965938 \
37                        sha256  350052656466cc2daecbb8b1c162ff444365def151636ba704f28ae5f05ca411
38   
39    set my_worksrcdir_format        instantclient%s
40    set my_distname_format(ppc)     instantclient-%s-macosx-${version}
41    set my_library_prefix(ppc)      /b/729
42   
43    livecheck.type      none
44} else {
45    version             11.2.0.4.0
46    set library_version 11.1
47    supported_archs     x86_64 i386
48    variant universal {}
49   
50    # The distfiles mirror has been configured not to mirror this port's files.
51    #master_sites        http://astro-wise.org/instantclient/
52    master_sites        http://download.oracle.com/otn/mac/instantclient/[join [lrange [split ${version} .] 0 3] ""]/
53   
54    checksums           instantclient-basic-macos.x32-${version}${extract.suffix} \
55                        rmd160  a34edfd79dc3a34026b755bba64499ca74f72f56 \
56                        sha256  c1d59a284d7ed8a65fc38c1df08b4ab632aebeb27420f7892e38e0725f1325b4 \
57                        instantclient-sdk-macos.x32-${version}${extract.suffix} \
58                        rmd160  350790b2c08c84e03a645bef6dcc72864d5c4bfc \
59                        sha256  4d4af789e471ea393ec019c16a3731abea9d384cdde8fce562f34406e79c6d13 \
60                        instantclient-basic-macos.x64-${version}${extract.suffix} \
61                        rmd160  a1ab486f91a1a648cafaa6ff77b4e7f0a4dcdb62 \
62                        sha256  6c079713ab0a65193f7bfcbad6c90e7806fa6634a3828052f8428e1533bb89d3 \
63                        instantclient-sdk-macos.x64-${version}${extract.suffix} \
64                        rmd160  dd54cc83c54bd9d702c0de6cd2219370ca98d2e2 \
65                        sha256  aead0663c206a811cf1f61d3b2a533ff81e6e6109dd31544ad850a7ef6eb5d19
66   
67    set my_worksrcdir_format        instantclient_%s
68    set my_distname_format(i386)    instantclient-%s-macos.x32-${version}
69    set my_distname_format(x86_64)  instantclient-%s-macos.x64-${version}
70    set my_library_prefix(i386)     /ade
71    set my_library_prefix(x86_64)   /ade
72   
73    if {${os.platform} eq "darwin" && ${os.major} < 9} {
74        pre-fetch {
75            ui_error "${name} on Intel requires Mac OS X 10.5 or greater."
76            return -code error "incompatible Mac OS X version"
77        }
78    }
79   
80    livecheck.type          regex
81    livecheck.url           http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
82    livecheck.regex         instantclient-basic-macos.x64-(\[0-9.\]+)${extract.suffix}
83}
84
85platform darwin 9 {
86    depends_build-append    port:cctools
87}
88
89# merge() requires universal_archs to be set correctly. Since we use merge()
90# even when not building universal we must always set universal_archs correctly.
91if {![variant_exists universal] || ![variant_isset universal]} {
92    configure.universal_archs ${configure.build_arch}
93}
94
95distfiles
96foreach my_arch ${configure.universal_archs} {
97    if {[info exists my_distname_format(${my_arch})]} {
98        foreach my_distfile_type {basic sdk} {
99            distfiles-append [format $my_distname_format(${my_arch}) ${my_distfile_type}]${extract.suffix}
100        }
101    }
102}
103
104post-fetch {
105    set bad_distfiles {}
106    foreach distfile ${distfiles} {
107        set distfile [strsed ${distfile} {/:.*$//}]
108        if {![catch {strsed [exec [findBinary file $portutil::autoconf::file_path] ${distpath}/${distfile} --brief --mime] {s/;.*$//}} mimetype] && ${mimetype} eq "text/html"} {
109            lappend bad_distfiles ${distfile}
110            file delete ${distpath}/${distfile}
111        }
112    }
113    if {[llength ${bad_distfiles}] > 0} {
114        ui_error "MacPorts was not able to download the necessary distfiles for ${name}."
115        ui_error "Please visit this URL:"
116        ui_error ""
117        ui_error "    ${homepage}"
118        ui_error ""
119        ui_error "and download these files manually:"
120        ui_error ""
121        foreach distfile ${bad_distfiles} {
122            ui_error "    ${distfile}"
123        }
124        ui_error ""
125        ui_error "and place them in this directory:"
126        ui_error ""
127        ui_error "    ${distpath}"
128        return -code error "missing distfiles"
129    }
130}
131
132extract {
133    set my_build_dir ${extract.dir}/build
134    xinstall -d ${my_build_dir}
135    foreach my_arch ${configure.universal_archs} {
136        foreach my_distfile_type {basic sdk} {
137            system "${extract.cmd} ${extract.pre_args} ${extract.post_args} ${distpath}/[format $my_distname_format(${my_arch}) ${my_distfile_type}]${extract.suffix}"
138        }
139        move ${extract.dir}/[format ${my_worksrcdir_format} [join [lrange [split ${version} .] 0 1] "_"]] ${my_build_dir}/${my_arch}
140    }
141   
142    # Fix permissions.
143    fs-traverse f ${my_build_dir} {
144        if {[string match "*.dylib.*" ${f}]} {
145            set ext .dylib
146        } else {
147            set ext [file extension ${f}]
148        }
149        switch ${ext} {
150            .dylib -
151            .jar {
152                file attributes ${f} -permissions 0755
153            }
154            .h {
155                file attributes ${f} -permissions 0644
156            }
157        }
158    }
159}
160
161use_configure           no
162
163set lib_dir             ${prefix}/lib/oracle
164
165build {
166    foreach my_arch ${configure.universal_archs} {
167        # Oracle builds the libraries with strange install_names; fix them.
168        # For each dylib, change the directory of its install_name to ${lib_dir}.
169        foreach lib [glob -directory ${workpath}/build/${my_arch} *.dylib*] {
170            system "install_name_tool -id ${lib_dir}/[strsed ${lib} /^.*\\///] ${lib}"
171           
172            # Then for each dependent dylib with a strange install_name that
173            # this dylib references, fix the reference to use ${lib_dir}.
174            foreach dep [exec otool -L ${lib}] {
175                if [string match "$my_library_prefix(${my_arch})/*" ${dep}] {
176                    system "install_name_tool -change ${dep} ${lib_dir}/[strsed ${dep} /^.*\\///] ${lib}"
177                }
178            }
179           
180            # libociei is special: it's not linked to; it's dynamically loaded at
181            # runtime by libclntsh. Oracle says you have to set DYLD_LIBRARY_PATH
182            # to include ${lib_dir}, but adding an rpath works too—but rpath only
183            # exists on Leopard and newer.
184            if {${os.major} > 8 && [string match "*/libclntsh.dylib*" ${lib}]} {
185                system "install_name_tool -add_rpath ${lib_dir} ${lib}"
186            }
187        }
188    }
189}
190
191destroot {
192    foreach my_arch ${configure.universal_archs} {
193        set my_destroot ${workpath}/pre-dest/${my_arch}
194        set my_worksrcpath ${workpath}/build/${my_arch}
195        xinstall -d ${my_destroot}${lib_dir}
196        xinstall \
197            {*}[glob -directory ${my_worksrcpath} *.dylib*] \
198            {*}[glob -directory ${my_worksrcpath} *.jar] \
199            ${my_destroot}${lib_dir}
200       
201        # You would think the includes should go in ${prefix}/include/oracle, but
202        # the "instantclient layout" dictates they must be in ${lib_dir}/sdk/include;
203        # ports like php-oracle will expect them there.
204        xinstall -d ${my_destroot}${lib_dir}/sdk
205        copy ${my_worksrcpath}/sdk/include ${my_destroot}${lib_dir}/sdk
206    }
207   
208    merge ${workpath}/pre-dest
209   
210    # php-oracle complains without a libclntsh.dylib symlink.
211    ln -s libclntsh.dylib.${library_version} ${destroot}${lib_dir}/libclntsh.dylib
212   
213    # Add a libocci.dylib symlink too for good measure.
214    ln -s libocci.dylib.${library_version} ${destroot}${lib_dir}/libocci.dylib
215}
216
217if {${os.major} > 8} {
218    notes-append "
219If you previously set DYLD_LIBRARY_PATH=${lib_dir} in your environment,\
220you can remove it\; it is no longer needed with this version of ${name}.
221"
222} else {
223    notes-append "
224To use ${name}, add this command to your environment:
225
226export DYLD_LIBRARY_PATH=${lib_dir}
227"
228}
Note: See TracBrowser for help on using the repository browser.