1{ stdenv, makeWrapper, requireFile, patchelf, rpmextract, libaio }:
2
3assert stdenv.system == "x86_64-linux";
4
5with stdenv.lib;
6
7stdenv.mkDerivation rec {
8 name = "oracle-xe-${version}";
9 version = "11.2.0";
10
11 src = requireFile {
12 name = "${name}-1.0.x86_64.rpm";
13 sha256 = "0s2jj2xn56v5ys6hxb7l7045hw9c1mm1lhj4p2fvqbs02kqchab6";
14
15 url = "http://www.oracle.com/technetwork/"
16 + "products/express-edition/downloads/";
17 };
18
19 buildInputs = [ makeWrapper ];
20
21 unpackCmd = ''
22 (mkdir -p "${name}" && cd "${name}" &&
23 ${rpmextract}/bin/rpmextract "$curSrc")
24 '';
25
26 buildPhase = let
27 libs = makeLibraryPath [ libaio ];
28 in ''
29 basedir="u01/app/oracle/product/${version}/xe"
30 cat > "$basedir/network/admin/listener.ora" <<SQL
31 # listener.ora Network Configuration File:
32
33 SID_LIST_LISTENER =
34 (SID_LIST =
35 (SID_DESC =
36 (SID_NAME = PLSExtProc)
37 (ORACLE_HOME = ''${out}/libexec/oracle)
38 (PROGRAM = extproc)
39 )
40 )
41
42 LISTENER =
43 (DESCRIPTION_LIST =
44 (DESCRIPTION =
45 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
46 (ADDRESS = (PROTOCOL = TCP)(HOST = %hostname%)(PORT = %port%))
47 )
48 )
49
50 DEFAULT_SERVICE_LISTENER = (XE)
51 SQL
52
53 find u01 \
54 \( -name '*.sh' \
55 -o -path "$basedir/bin/*" \
56 \) -print -exec "${patchelf}/bin/patchelf" \
57 --interpreter "$(cat "$NIX_CC/nix-support/dynamic-linker")" \
58 --set-rpath "${libs}:$out/libexec/oracle/lib" \
59 --force-rpath '{}' \;
60 '';
61
62 dontStrip = true;
63 dontPatchELF = true;
64
65 installPhase = ''
66 mkdir -p "$out/libexec"
67 cp -r "u01/app/oracle/product/${version}/xe" "$out/libexec/oracle"
68
69 for i in "$out/libexec/oracle/bin"/*; do
70 makeWrapper "$i" "$out/bin/''${i##*/}" \
71 --set ORACLE_HOME "$out/libexec/oracle" \
72 --set ORACLE_SID XE \
73 --run "export NLS_LANG=\$($out/libexec/oracle/bin/nls_lang.sh)" \
74 --prefix PATH : "$out/libexec/oracle/bin"
75 done
76 '';
77
78 meta = {
79 description = "Oracle Database Express Edition";
80 homepage = http://www.oracle.com/technetwork/products/express-edition/;
81 license = licenses.unfree;
82 };
83}