diff --git a/erlang.spec b/erlang.spec index c1223da..eff8714 100644 --- a/erlang.spec +++ b/erlang.spec @@ -10,7 +10,7 @@ Name: erlang Version: 17.3.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: General-purpose programming language and runtime environment Group: Development/Languages @@ -71,6 +71,9 @@ Patch9: otp-0009-Expose-NIF-version.patch # Fedora specific patch # Split off webtool dependency from tools Patch10: otp-0010-Split-off-webtool-dependency-from-tools.patch +# Fedora specific patch +# Introduce os:getenv/2 +Patch11: otp-0011-Introduce-os-getenv-2.patch # end of autogenerated patch tag list BuildRequires: lksctp-tools-devel @@ -900,6 +903,7 @@ Erlang mode for XEmacs (source lisp files). %patch8 -p1 -b .Install_internal_hrl_files_when_necessary %patch9 -p1 -b .Expose_NIF_version %patch10 -p1 -b .Split_off_webtool_dependency_from_tools +%patch11 -p1 -b .Introduce_os_getenv_2 # end of autogenerated prep patch list # FIXME we should come up with a better solution @@ -2220,6 +2224,9 @@ useradd -r -g epmd -d /tmp -s /sbin/nologin \ %changelog +* Mon Dec 01 2014 Peter Lemenkov - 17.3.4-2 +- Backport useful os:getenv/2 from master (see https://github.com/erlang/otp/pull/535 ) + * Sat Nov 08 2014 Peter Lemenkov - 17.3.4-1 - Ver. 17.3.4 (API/ABI compatible release) - Relax an erlang-tools dependency on erlang-webtool down to Suggests diff --git a/otp-0011-Introduce-os-getenv-2.patch b/otp-0011-Introduce-os-getenv-2.patch new file mode 100644 index 0000000..6c48db2 --- /dev/null +++ b/otp-0011-Introduce-os-getenv-2.patch @@ -0,0 +1,63 @@ +From: Peter Lemenkov +Date: Sat, 8 Nov 2014 15:11:04 +0300 +Subject: [PATCH] Introduce os:getenv/2 + +Signed-off-by: Peter Lemenkov + +diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml +index 2b57e75..8b85f24 100644 +--- a/lib/kernel/doc/src/os.xml ++++ b/lib/kernel/doc/src/os.xml +@@ -100,6 +100,19 @@ DirOut = os:cmd("dir"), % on Win32 platform + + + ++ ++ Get the value of an environment variable ++ ++

Returns the Value of the environment variable ++ VarName, or DefaultValue if the environment variable ++ is undefined.

++

If Unicode file name encoding is in effect (see the erl manual ++ page), the strings (both VarName and ++ Value) may contain characters with codepoints > 255.

++
++
++ + + Return the process identifier of the emulator process + +diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl +index 187fd00..8aaf13b 100644 +--- a/lib/kernel/src/os.erl ++++ b/lib/kernel/src/os.erl +@@ -26,7 +26,7 @@ + + %%% BIFs + +--export([getenv/0, getenv/1, getpid/0, putenv/2, timestamp/0, unsetenv/1]). ++-export([getenv/0, getenv/1, getenv/2, getpid/0, putenv/2, timestamp/0, unsetenv/1]). + + -spec getenv() -> [string()]. + +@@ -39,6 +39,19 @@ getenv() -> erlang:nif_error(undef). + getenv(_) -> + erlang:nif_error(undef). + ++-spec getenv(VarName, DefaultValue) -> Value when ++ VarName :: string(), ++ DefaultValue :: string(), ++ Value :: string(). ++ ++getenv(VarName, DefaultValue) -> ++ case os:getenv(VarName) of ++ false -> ++ DefaultValue; ++ Value -> ++ Value ++ end. ++ + -spec getpid() -> Value when + Value :: string(). +