From 60816110465845b6a2a955b145447d4343f63bf0 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 21 Aug 2019 02:55:59 +0200 Subject: [PATCH 1/9] oracle-instantclient: turn into a multi-output derivation --- pkgs/development/libraries/odpic/default.nix | 2 +- .../oracle-instantclient/default.nix | 24 ++++++++++++------- .../perl-modules/DBD-Oracle/default.nix | 2 +- pkgs/top-level/php-packages.nix | 7 ++++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pkgs/development/libraries/odpic/default.nix b/pkgs/development/libraries/odpic/default.nix index 931ecc186be6..84957cae1270 100644 --- a/pkgs/development/libraries/odpic/default.nix +++ b/pkgs/development/libraries/odpic/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { ++ stdenv.lib.optionals stdenv.isLinux [ libaio ]; libPath = stdenv.lib.makeLibraryPath - [ oracle-instantclient ]; + [ oracle-instantclient.lib ]; dontPatchELF = true; makeFlags = [ "PREFIX=$(out)" "CC=cc" "LD=cc"]; diff --git a/pkgs/development/libraries/oracle-instantclient/default.nix b/pkgs/development/libraries/oracle-instantclient/default.nix index fe260e0c2ad2..ffdf342b2f91 100644 --- a/pkgs/development/libraries/oracle-instantclient/default.nix +++ b/pkgs/development/libraries/oracle-instantclient/default.nix @@ -47,18 +47,15 @@ in stdenv.mkDerivation rec { ++ optional stdenv.isLinux autoPatchelfHook ++ optional stdenv.isDarwin fixDarwinDylibNames; + outputs = [ "out" "dev" "lib"]; + unpackCmd = "unzip $curSrc"; installPhase = '' - mkdir -p "$out/"{bin,include,lib,"share/java","share/${name}/demo/"} - install -Dm755 {sqlplus,adrci,genezi} $out/bin - ${optionalString stdenv.isDarwin '' - for exe in "$out/bin/"* ; do - install_name_tool -add_rpath "$out/lib" "$exe" - done - ''} - ln -sfn $out/bin/sqlplus $out/bin/sqlplus64 - install -Dm644 *${extLib}* $out/lib + mkdir -p "$out/"{bin,include,"share/java","share/${name}/demo/"} $lib/lib + install -Dm755 {adrci,genezi,uidrvci,sqlplus} $out/bin + install -Dm644 *${extLib}* $lib/lib + install -Dm644 *.jar $out/share/java install -Dm644 sdk/include/* $out/include install -Dm644 sdk/demo/* $out/share/${name}/demo @@ -68,6 +65,15 @@ in stdenv.mkDerivation rec { ln -sfn $out/lib/libclntsh${extLib}.12.1 $out/lib/libclntsh${extLib} ''; + postFixup = optionalString stdenv.isDarwin '' + for exe in "$out/bin/"* ; do + if [ ! -L "$exe" ]; then + install_name_tool -add_rpath "$lib/lib" "$exe" + fi + done + ''; + + meta = with stdenv.lib; { description = "Oracle instant client libraries and sqlplus CLI"; longDescription = '' diff --git a/pkgs/development/perl-modules/DBD-Oracle/default.nix b/pkgs/development/perl-modules/DBD-Oracle/default.nix index a7ec1e2d1826..a9d6a2798eb5 100644 --- a/pkgs/development/perl-modules/DBD-Oracle/default.nix +++ b/pkgs/development/perl-modules/DBD-Oracle/default.nix @@ -9,7 +9,7 @@ buildPerlPackage { sha256 = "b6db7f43c6252179274cfe99c1950b93e248f8f0fe35b07e50388c85d814d5f3"; }; - ORACLE_HOME = "${oracle-instantclient}/lib"; + ORACLE_HOME = "${oracle-instantclient.lib}/lib"; buildInputs = [ TestNoWarnings oracle-instantclient ] ; propagatedBuildInputs = [ DBI ]; diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index 801a9c9e30bf..949896c1036b 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -237,9 +237,12 @@ let pname = "oci8"; sha256 = "0jhivxj1nkkza4h23z33y7xhffii60d7dr51h1czjk10qywl7pyd"; - buildInputs = [ pkgs.oracle-instantclient ]; - configureFlags = [ "--with-oci8=shared,instantclient,${pkgs.oracle-instantclient}/lib" ]; + configureFlags = [ "--with-oci8=shared,instantclient,${pkgs.oracle-instantclient.lib}/lib" ]; + + postPatch = '' + sed -i -e 's|OCISDKMANINC=`.*$|OCISDKMANINC="${pkgs.oracle-instantclient.dev}/include"|' config.m4 + ''; }; pcs = buildPecl rec { From eb0fecf29470c5ae4fb73a4ed5bd71ce33ca3bec Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 21 Aug 2019 02:56:18 +0200 Subject: [PATCH 2/9] odpic: add to rpath --- pkgs/development/libraries/odpic/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/odpic/default.nix b/pkgs/development/libraries/odpic/default.nix index 84957cae1270..9de589a51669 100644 --- a/pkgs/development/libraries/odpic/default.nix +++ b/pkgs/development/libraries/odpic/default.nix @@ -22,7 +22,7 @@ stdenv.mkDerivation rec { postFixup = '' ${stdenv.lib.optionalString (stdenv.isLinux) '' - patchelf --set-rpath "${libPath}" $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary} + patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary})" $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary} ''} ${stdenv.lib.optionalString (stdenv.isDarwin) '' install_name_tool -add_rpath "${libPath}" $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary} From c79d9e17d62cd69caec0cfb930e4c1a7fbd49c22 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 20 Aug 2019 00:17:13 +0200 Subject: [PATCH 3/9] odpic: 3.1.0 -> 3.2.1 --- pkgs/development/libraries/odpic/default.nix | 24 ++++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkgs/development/libraries/odpic/default.nix b/pkgs/development/libraries/odpic/default.nix index 9de589a51669..f3e8742bb207 100644 --- a/pkgs/development/libraries/odpic/default.nix +++ b/pkgs/development/libraries/odpic/default.nix @@ -1,12 +1,19 @@ -{ stdenv, fetchurl, fixDarwinDylibNames, oracle-instantclient, libaio }: +{ stdenv, fetchFromGitHub, fixDarwinDylibNames, oracle-instantclient, libaio }: -stdenv.mkDerivation rec { - name = "odpic-${version}"; - version = "3.1.0"; +let + version = "3.2.1"; + libPath = stdenv.lib.makeLibraryPath [ oracle-instantclient.lib ]; - src = fetchurl { - url = "https://github.com/oracle/odpi/archive/v${version}.tar.gz"; - sha256 = "0m6g7lbvfir4amf2cnap9wz9fmqrihqpihd84igrd7fp076894c0"; +in stdenv.mkDerivation { + inherit version; + + pname = "odpic"; + + src = fetchFromGitHub { + owner = "oracle"; + repo = "odpi"; + rev = "v${version}"; + sha256 = "1f9gznc7h73cgx32p55rkhzla6l7l9dg53ilwh6zdgdqlp7n018i"; }; nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin [ fixDarwinDylibNames ]; @@ -14,9 +21,6 @@ stdenv.mkDerivation rec { buildInputs = [ oracle-instantclient ] ++ stdenv.lib.optionals stdenv.isLinux [ libaio ]; - libPath = stdenv.lib.makeLibraryPath - [ oracle-instantclient.lib ]; - dontPatchELF = true; makeFlags = [ "PREFIX=$(out)" "CC=cc" "LD=cc"]; From 2decc61d2839dd5332117005d31d8c05877291f2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 20 Aug 2019 01:24:36 +0200 Subject: [PATCH 4/9] oracle-instantclient: 12.2.0.1.0 -> 19.3.0.0.0 It's now possible to download Oracle Instant Client without having to click a checkbox to agree to the license, and then log in with an Oracle account to start the download, at least on Linux (for now). Darwin still seems to be at 18.1, and version numbers haven't been that aligned recently, so allow different version numbers per platform. --- .../oracle-instantclient/default.nix | 115 +++++++++++++----- 1 file changed, 83 insertions(+), 32 deletions(-) diff --git a/pkgs/development/libraries/oracle-instantclient/default.nix b/pkgs/development/libraries/oracle-instantclient/default.nix index ffdf342b2f91..2f271e6cd93a 100644 --- a/pkgs/development/libraries/oracle-instantclient/default.nix +++ b/pkgs/development/libraries/oracle-instantclient/default.nix @@ -1,46 +1,95 @@ -{ stdenv, requireFile, autoPatchelfHook, fixDarwinDylibNames, unzip, libaio, makeWrapper, odbcSupport ? false, unixODBC }: +{ stdenv +, fetchurl +, requireFile +, autoPatchelfHook +, fixDarwinDylibNames +, unzip +, libaio +, makeWrapper +, odbcSupport ? true +, unixODBC +}: assert odbcSupport -> unixODBC != null; let inherit (stdenv.lib) optional optionals optionalString; - baseVersion = "12.2"; - version = "${baseVersion}.0.1.0"; - - requireSource = component: arch: version: rel: hash: (requireFile rec { - name = "instantclient-${component}-${arch}-${version}" + (optionalString (rel != "") "-${rel}") + ".zip"; - url = "http://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html"; - sha256 = hash; - }); - throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}"; + # assemble list of components + components = [ "basic" "sdk" "sqlplus" ] ++ optional odbcSupport "odbc"; + + # determine the version number, there might be different ones per architecture + version = { + "x86_64-linux" = "19.3.0.0.0"; + "x86_64-darwin" = "18.1.0.0.0"; + }."${stdenv.hostPlatform.system}" or throwSystem; + + # hashes per component and architecture + hashes = { + "x86_64-linux" = { + "basic" = "1yk4ng3a9ka1mzgfph9br6rwclagbgfvmg6kja11nl5dapxdzaxy"; + "sdk" = "115v1gqr0czy7dcf2idwxhc6ja5b0nind0mf1rn8iawgrw560l99"; + "sqlplus" = "0zj5h84ypv4n4678kfix6jih9yakb277l9hc0819iddc0a5slbi5"; + "odbc" = "1g1z6pdn76dp440fh49pm8ijfgjazx4cvxdi665fsr62h62xkvch"; + }; + "x86_64-darwin" = { + "basic" = "fac3cdaaee7526f6c50ff167edb4ba7ab68efb763de24f65f63fb48cc1ba44c0"; + "sdk" = "98e6d797f1ce11e59b042b232f62380cec29ec7d5387b88a9e074b741c13e63a"; + "sqlplus" = "02e66dc52398fced75e7efcb6b4372afcf617f7d88344fb7f0f4bb2bed371f3b"; + "odbc" = "5d0cdd7f9dd2e27affbc9b36ef9fc48e329713ecd36905fdd089366e365ae8a2"; + }; + }."${stdenv.hostPlatform.system}" or throwSystem; + + # rels per component and architecture, optional + rels = { + "x86_64-darwin" = { + "sdk" = "2"; + }; + }."${stdenv.hostPlatform.system}" or {}; + + # convert platform to oracle architecture names arch = { "x86_64-linux" = "linux.x64"; "x86_64-darwin" = "macos.x64"; }."${stdenv.hostPlatform.system}" or throwSystem; - srcs = { - "x86_64-linux" = [ - (requireSource "basic" arch version "" "5015e3c9fba84e009f7519893f798a1622c37d1ae2c55104ff502c52a0fe5194") - (requireSource "sdk" arch version "" "7f404c3573c062ce487a51ac4cfe650c878d7edf8e73b364ec852645ed1098cb") - (requireSource "sqlplus" arch version "" "d49b2bd97376591ca07e7a836278933c3f251875c215044feac73ba9f451dfc2") ] - ++ optional odbcSupport (requireSource "odbc" arch version "2" "365a4ae32c7062d9fbc3fb41add748e7881f774484a175a4b41a2c294ce9095d"); - "x86_64-darwin" = [ - (requireSource "basic" arch version "2" "3ed3102e5a24f0da638694191edb34933309fb472eb1df21ad5c86eedac3ebb9") - (requireSource "sdk" arch version "2" "e0befca9c4e71ebc9f444957ffa70f01aeeec5976ea27c40406471b04c34848b") - (requireSource "sqlplus" arch version "2" "d147cbb5b2a954fdcb4b642df4f0bd1153fd56e0f56e7fa301601b4f7e2abe0e") ] - ++ optional odbcSupport (requireSource "odbc" arch version "2" "1805c1ab6c8c5e8df7bdcc35d7f2b94c329ecf4dff9bde55d5f9b159ecd8b64e"); - }."${stdenv.hostPlatform.system}" or throwSystem; + # calculate the filename of a single zip file + srcFilename = component: arch: version: rel: + "instantclient-${component}-${arch}-${version}" + + (optionalString (rel != "") "-${rel}") + + (optionalString (arch == "linux.x64") "dbru") + # ¯\_(ツ)_/¯ + ".zip"; + # fetcher for the clickthrough artifacts (requiring manual download) + fetchClickThrough = srcFilename: hash: (requireFile { + name = srcFilename; + url = "https://www.oracle.com/database/technologies/instant-client/downloads.html"; + sha256 = hash; + }); + + # fetcher for the non clickthrough artifacts + fetchSimple = srcFilename: hash: fetchurl { + url = "https://download.oracle.com/otn_software/linux/instantclient/193000/${srcFilename}"; + sha256 = hash; + }; + + # pick the appropriate fetcher depending on the platform + fetcher = if stdenv.hostPlatform.system == "x86_64-linux" then fetchSimple else fetchClickThrough; + + # assemble srcs + srcs = map (component: + (fetcher (srcFilename component arch version rels."${component}" or "") hashes."${component}" or "")) + components; + + pname = "oracle-instantclient"; extLib = stdenv.hostPlatform.extensions.sharedLibrary; -in stdenv.mkDerivation rec { - inherit version srcs; - name = "oracle-instantclient-${version}"; +in stdenv.mkDerivation { + inherit pname version srcs; buildInputs = [ stdenv.cc.cc.lib ] - ++ optionals (stdenv.isLinux) [ libaio ] + ++ optional stdenv.isLinux libaio ++ optional odbcSupport unixODBC; nativeBuildInputs = [ makeWrapper unzip ] @@ -52,20 +101,22 @@ in stdenv.mkDerivation rec { unpackCmd = "unzip $curSrc"; installPhase = '' - mkdir -p "$out/"{bin,include,"share/java","share/${name}/demo/"} $lib/lib + mkdir -p "$out/"{bin,include,lib,"share/java","share/${pname}-${version}/demo/"} $lib/lib install -Dm755 {adrci,genezi,uidrvci,sqlplus} $out/bin install -Dm644 *${extLib}* $lib/lib - install -Dm644 *.jar $out/share/java install -Dm644 sdk/include/* $out/include - install -Dm644 sdk/demo/* $out/share/${name}/demo + install -Dm644 sdk/demo/* $out/share/${pname}-${version}/demo + # provide alias + ln -sfn $out/bin/sqlplus $out/bin/sqlplus64 + ''; + + postFixup = '' # PECL::oci8 will not build without this # this symlink only exists in dist zipfiles for some platforms ln -sfn $out/lib/libclntsh${extLib}.12.1 $out/lib/libclntsh${extLib} - ''; - - postFixup = optionalString stdenv.isDarwin '' + '' + optionalString stdenv.isDarwin '' for exe in "$out/bin/"* ; do if [ ! -L "$exe" ]; then install_name_tool -add_rpath "$lib/lib" "$exe" From e9c53043a802f08b6ae629c3d26fb0f4a4530909 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 22 Aug 2019 00:00:33 +0200 Subject: [PATCH 5/9] oracle-instantclient: drop PECL::oci8 hack This wasn't about PECL::oci8 in first place, but DBD-Oracle. In the current version of oracle-instantclient, a libclntsh.so is shipped, so DBD-Oracle is happy. --- .../development/libraries/oracle-instantclient/default.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/development/libraries/oracle-instantclient/default.nix b/pkgs/development/libraries/oracle-instantclient/default.nix index 2f271e6cd93a..0d86aef07726 100644 --- a/pkgs/development/libraries/oracle-instantclient/default.nix +++ b/pkgs/development/libraries/oracle-instantclient/default.nix @@ -112,11 +112,7 @@ in stdenv.mkDerivation { ln -sfn $out/bin/sqlplus $out/bin/sqlplus64 ''; - postFixup = '' - # PECL::oci8 will not build without this - # this symlink only exists in dist zipfiles for some platforms - ln -sfn $out/lib/libclntsh${extLib}.12.1 $out/lib/libclntsh${extLib} - '' + optionalString stdenv.isDarwin '' + postFixup = optionalString stdenv.isDarwin '' for exe in "$out/bin/"* ; do if [ ! -L "$exe" ]; then install_name_tool -add_rpath "$lib/lib" "$exe" @@ -124,7 +120,6 @@ in stdenv.mkDerivation { done ''; - meta = with stdenv.lib; { description = "Oracle instant client libraries and sqlplus CLI"; longDescription = '' From 42f9df18add26a5cbcee5362e1f8d97d781d7f3a Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 21 Aug 2019 17:00:47 +0200 Subject: [PATCH 6/9] python3.pkgs.cx_oracle: 7.1.3 -> 7.2.2 --- pkgs/development/python-modules/cx_oracle/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/cx_oracle/default.nix b/pkgs/development/python-modules/cx_oracle/default.nix index 5708bf12d6bc..77814ec1191c 100644 --- a/pkgs/development/python-modules/cx_oracle/default.nix +++ b/pkgs/development/python-modules/cx_oracle/default.nix @@ -2,13 +2,13 @@ buildPythonPackage rec { pname = "cx_Oracle"; - version = "7.1.3"; + version = "7.2.2"; buildInputs = [ odpic ]; src = fetchPypi { inherit pname version; - sha256 = "4f26b7418e2796112f8b36338a2f9a7c07dd08df53d857e3478bb53f61dd52e4"; + sha256 = "1kp6fgyln0jkdbjm20h6rhybsmvqjj847frhsndyfvkf38m32ss0"; }; preConfigure = '' From ab6ada01f70f4920db10490cedc96faacb42946d Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 22 Aug 2019 00:41:49 +0200 Subject: [PATCH 7/9] oracle-instantclient: use copy instead of install for libraries libclntsh.so* and libocci.so* are symlinks to the latest version. By using `install`, these are all dereferenced and duplicated. Let's avoid that, and shrink the lib output from 621M to 226M. --- pkgs/development/libraries/oracle-instantclient/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/oracle-instantclient/default.nix b/pkgs/development/libraries/oracle-instantclient/default.nix index 0d86aef07726..06b9e360d1a3 100644 --- a/pkgs/development/libraries/oracle-instantclient/default.nix +++ b/pkgs/development/libraries/oracle-instantclient/default.nix @@ -103,7 +103,10 @@ in stdenv.mkDerivation { installPhase = '' mkdir -p "$out/"{bin,include,lib,"share/java","share/${pname}-${version}/demo/"} $lib/lib install -Dm755 {adrci,genezi,uidrvci,sqlplus} $out/bin - install -Dm644 *${extLib}* $lib/lib + + # cp to preserve symlinks + cp -P *${extLib}* $lib/lib + install -Dm644 *.jar $out/share/java install -Dm644 sdk/include/* $out/include install -Dm644 sdk/demo/* $out/share/${pname}-${version}/demo From 47c60b38230acc69f586088623933171267aa7b2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 22 Aug 2019 00:48:59 +0200 Subject: [PATCH 8/9] perlPackages.DBDOracle: 1.76 -> 1.80 --- pkgs/development/perl-modules/DBD-Oracle/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/perl-modules/DBD-Oracle/default.nix b/pkgs/development/perl-modules/DBD-Oracle/default.nix index a9d6a2798eb5..19c4e308289f 100644 --- a/pkgs/development/perl-modules/DBD-Oracle/default.nix +++ b/pkgs/development/perl-modules/DBD-Oracle/default.nix @@ -2,11 +2,11 @@ buildPerlPackage { pname = "DBD-Oracle"; - version = "1.76"; + version = "1.80"; src = fetchurl { url = mirror://cpan/authors/id/Z/ZA/ZARQUON/DBD-Oracle-1.76.tar.gz; - sha256 = "b6db7f43c6252179274cfe99c1950b93e248f8f0fe35b07e50388c85d814d5f3"; + sha256 = "1wym2kc8b31qa1zb0dgyy3w4iqlk1faw36gy9hkpj895qr1pznxn"; }; ORACLE_HOME = "${oracle-instantclient.lib}/lib"; From 472f3254a88481835f67814e3bb63c398c642280 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 22 Aug 2019 12:32:32 +0200 Subject: [PATCH 9/9] perlPackages.DBDOracle: fix darwin build --- pkgs/development/perl-modules/DBD-Oracle/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/perl-modules/DBD-Oracle/default.nix b/pkgs/development/perl-modules/DBD-Oracle/default.nix index 19c4e308289f..0658dd4248dd 100644 --- a/pkgs/development/perl-modules/DBD-Oracle/default.nix +++ b/pkgs/development/perl-modules/DBD-Oracle/default.nix @@ -1,4 +1,4 @@ -{ fetchurl, buildPerlPackage, DBI, TestNoWarnings, oracle-instantclient }: +{ stdenv, fetchurl, buildPerlPackage, DBI, TestNoWarnings, oracle-instantclient }: buildPerlPackage { pname = "DBD-Oracle"; @@ -13,4 +13,8 @@ buildPerlPackage { buildInputs = [ TestNoWarnings oracle-instantclient ] ; propagatedBuildInputs = [ DBI ]; + + postBuild = stdenv.lib.optionalString stdenv.isDarwin '' + install_name_tool -add_rpath "${oracle-instantclient.lib}/lib" blib/arch/auto/DBD/Oracle/Oracle.bundle + ''; }