diff --git a/.gitignore b/.gitignore index 102f125..99b1241 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,7 @@ otp_src_R14A.tar.gz /otp_doc_html_R16B03.tar.gz /otp_doc_man_R16B03.tar.gz /otp_src_R16B03.readme +/otp_src_R16B03-1.readme +/otp_doc_html_R16B03-1.tar.gz +/otp_doc_man_R16B03-1.tar.gz +/otp_src_R16B03-1.tar.gz diff --git a/epmd.service b/epmd.service new file mode 100644 index 0000000..c029ac4 --- /dev/null +++ b/epmd.service @@ -0,0 +1,18 @@ +[Unit] +Description=Erlang Port Mapper Daemon +After=network.target +Requires=epmd.socket + +[Service] +ExecStart=/usr/bin/epmd -systemd +ExecStop=/usr/bin/epmd -kill +Type=simple +StandardOutput=journal +StandardError=journal +User=epmd +Group=epmd + +[Install] +Also=epmd.socket +WantedBy=multi-user.target + diff --git a/epmd.socket b/epmd.socket new file mode 100644 index 0000000..8eee066 --- /dev/null +++ b/epmd.socket @@ -0,0 +1,10 @@ +[Unit] +Description=Erlang Port Mapper Daemon Activation Socket + +[Socket] +ListenStream=127.0.0.1:4369 +Accept=false + +[Install] +WantedBy=sockets.target + diff --git a/erlang.spec b/erlang.spec index fe2972a..e3b55aa 100644 --- a/erlang.spec +++ b/erlang.spec @@ -32,18 +32,20 @@ Name: erlang Version: %{upstream_ver} -Release: %{upstream_rel_for_rpm}.2%{?dist} +Release: %{upstream_rel_for_rpm}.3%{?dist} Summary: General-purpose programming language and runtime environment Group: Development/Languages License: ERPL URL: http://www.erlang.org -Source0: http://www.erlang.org/download/otp_src_%{upstream_ver}%{upstream_rel}.tar.gz +Source0: http://www.erlang.org/download/otp_src_%{upstream_ver}%{upstream_rel}-1.tar.gz %if %{use_prebuilt_docs} -Source1: http://erlang.org/download/otp_doc_html_%{upstream_ver}%{upstream_rel}.tar.gz -Source2: http://erlang.org/download/otp_doc_man_%{upstream_ver}%{upstream_rel}.tar.gz +Source1: http://erlang.org/download/otp_doc_html_%{upstream_ver}%{upstream_rel}-1.tar.gz +Source2: http://erlang.org/download/otp_doc_man_%{upstream_ver}%{upstream_rel}-1.tar.gz %endif -Source4: http://www.erlang.org/download/otp_src_%{upstream_ver}%{upstream_rel}.readme +Source4: http://www.erlang.org/download/otp_src_%{upstream_ver}%{upstream_rel}-1.readme +Source5: epmd.service +Source6: epmd.socket Source999: otp-get-patches.sh @@ -91,6 +93,12 @@ Patch9: otp-0009-TEMPORARILY-disable-ECC-until-dust-settles.patch # Fedora specific patch # Fix for powerpc architecture Patch10: otp-0010-Fix-for-powerpc-architecture.patch +# Fedora specific patch +# Add -systemd option to empd. Check for include +Patch11: otp-0011-Add-systemd-option-to-empd.-Check-for-include-system.patch +# Fedora specific patch +# Add systemd support to epmd +Patch12: otp-0012-Add-systemd-support-to-epmd.patch # end of autogenerated patch tag list # BuildRoot not strictly needed since F10, but keep it for spec file robustness @@ -122,6 +130,13 @@ BuildRequires: emacs-el BuildRequires: xemacs-packages-extra-el %endif +%if 0%{?el7}%{?fedora} +Requires(post): systemd +Requires(preun):systemd +Requires(postun):systemd +Requires: systemd +%endif + Requires: erlang-appmon%{?_isa} = %{version}-%{release} Requires: erlang-asn1%{?_isa} = %{version}-%{release} Requires: erlang-common_test%{?_isa} = %{version}-%{release} @@ -958,6 +973,8 @@ Erlang mode for XEmacs (source lisp files). %patch8 -p1 -b .Fix_for_armv7hl_architecture %patch9 -p1 -b .TEMPORARILY_disable_ECC_until_dust_settles %patch10 -p1 -b .Fix_for_powerpc_architecture +%patch11 -p1 -b .Add_systemd_option_to_empd_Check_for_include_system +%patch12 -p1 -b .Add_systemd_support_to_epmd # end of autogenerated prep patch list # FIXME we should come up with a better solution @@ -1153,6 +1170,12 @@ test -d "$RPM_BUILD_ROOT$jinterface_lib_dir" install -m 0755 -d "$RPM_BUILD_ROOT%{_javadir}" ln -s "${jinterface_lib_dir}priv/OtpErlang.jar" "$RPM_BUILD_ROOT%{_javadir}/%{name}/" +# systemd-related stuff +%if 0%{?el7}%{?fedora} +install -D -p -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/epmd.service +install -D -p -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/epmd.socket +%endif + %clean rm -rf $RPM_BUILD_ROOT @@ -1493,6 +1516,10 @@ rm -rf $RPM_BUILD_ROOT %endif %{_libdir}/erlang/releases/* %{_libdir}/erlang/usr/ +%if 0%{?el7}%{?fedora} +%{_unitdir}/epmd.service +%{_unitdir}/epmd.socket +%endif %files et %dir %{_libdir}/erlang/lib/et-*/ @@ -2289,6 +2316,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Mar 27 2014 Peter Lemenkov - R16B-03.3 +- Ver. R16B03-1 (Bugfix release) +- Enabled systemd support in EPMD + * Fri Feb 7 2014 Sam Kottler - R16B-03.2 - Fix macro usage for EPEL7 build and added need_bootstrap diff --git a/otp-0006-Do-not-install-erlang-sources.patch b/otp-0006-Do-not-install-erlang-sources.patch index 38c9dd1..843e052 100644 --- a/otp-0006-Do-not-install-erlang-sources.patch +++ b/otp-0006-Do-not-install-erlang-sources.patch @@ -460,10 +460,10 @@ index 51167b3..a623824 100644 $(INSTALL_DATA) $(TARGET_FILES) "$(RELSYSDIR)/ebin" diff --git a/lib/inets/src/http_server/Makefile b/lib/inets/src/http_server/Makefile -index 67555d5..0620f3a 100644 +index 2660d04..c873a27 100644 --- a/lib/inets/src/http_server/Makefile +++ b/lib/inets/src/http_server/Makefile -@@ -125,7 +125,7 @@ include $(ERL_TOP)/make/otp_release_targets.mk +@@ -126,7 +126,7 @@ include $(ERL_TOP)/make/otp_release_targets.mk release_spec: opt $(INSTALL_DIR) "$(RELSYSDIR)/src" $(INSTALL_DIR) "$(RELSYSDIR)/src/http_server" diff --git a/otp-0011-Add-systemd-option-to-empd.-Check-for-include-system.patch b/otp-0011-Add-systemd-option-to-empd.-Check-for-include-system.patch new file mode 100644 index 0000000..bb13893 --- /dev/null +++ b/otp-0011-Add-systemd-option-to-empd.-Check-for-include-system.patch @@ -0,0 +1,74 @@ +From: "Matwey V. Kornilov" +Date: Tue, 17 Dec 2013 18:16:56 +0400 +Subject: [PATCH] Add -systemd option to empd. Check for include + systemd/sd-daemon.h and wrap systemd code into ifdef-s. + + +diff --git a/erts/configure.in b/erts/configure.in +index 9ad3671..125e579 100644 +--- a/erts/configure.in ++++ b/erts/configure.in +@@ -1565,6 +1565,8 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_enaddr], [], [], + #endif + ]) + ++AC_CHECK_HEADERS(systemd/sd-daemon.h) ++ + dnl ---------------------------------------------------------------------- + dnl Check the availability for libdlpi + dnl ---------------------------------------------------------------------- +diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c +index 2d55b37..fc58882 100644 +--- a/erts/epmd/src/epmd.c ++++ b/erts/epmd/src/epmd.c +@@ -175,6 +175,9 @@ int main(int argc, char** argv) + g->nodes.reg = g->nodes.unreg = g->nodes.unreg_tail = NULL; + g->nodes.unreg_count = 0; + g->active_conn = 0; ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ g->is_systemd = 0; ++#endif + + for (i = 0; i < MAX_LISTEN_SOCKETS; i++) + g->listenfd[i] = -1; +@@ -248,8 +251,12 @@ int main(int argc, char** argv) + else + usage(g); + epmd_cleanup_exit(g,0); +- } +- else ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ } else if (strcmp(argv[0], "-systemd") == 0) { ++ g->is_systemd = 1; ++ argv++; argc--; ++#endif ++ } else + usage(g); + } + dbg_printf(g,1,"epmd running - daemon = %d",g->is_daemon); +@@ -454,6 +461,11 @@ static void usage(EpmdVars *g) + fprintf(stderr, " Forcibly unregisters a name with epmd\n"); + fprintf(stderr, " (only allowed if -relaxed_command_check was given when \n"); + fprintf(stderr, " epmd was started).\n"); ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ fprintf(stderr, " -systemd\n"); ++ fprintf(stderr, " Wait for socket from systemd. The option makes sense\n"); ++ fprintf(stderr, " when started from .socket unit.\n"); ++#endif + epmd_cleanup_exit(g,1); + } + +diff --git a/erts/epmd/src/epmd_int.h b/erts/epmd/src/epmd_int.h +index 656dbd1..bf1ddd8 100644 +--- a/erts/epmd/src/epmd_int.h ++++ b/erts/epmd/src/epmd_int.h +@@ -321,6 +321,9 @@ typedef struct { + int listenfd[MAX_LISTEN_SOCKETS]; + char *addresses; + char **argv; ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ int is_systemd; ++#endif + } EpmdVars; + + void dbg_printf(EpmdVars*,int,const char*,...); diff --git a/otp-0012-Add-systemd-support-to-epmd.patch b/otp-0012-Add-systemd-support-to-epmd.patch new file mode 100644 index 0000000..3535601 --- /dev/null +++ b/otp-0012-Add-systemd-support-to-epmd.patch @@ -0,0 +1,111 @@ +From: "Matwey V. Kornilov" +Date: Tue, 17 Dec 2013 18:57:54 +0400 +Subject: [PATCH] Add systemd support to epmd + + +diff --git a/erts/configure.in b/erts/configure.in +index 125e579..d9bc1ec 100644 +--- a/erts/configure.in ++++ b/erts/configure.in +@@ -969,6 +969,8 @@ AC_CHECK_LIB(dl, dlopen) + AC_CHECK_LIB(inet, main) + AC_CHECK_LIB(util, openpty) + ++AC_CHECK_LIB(systemd-daemon, sd_listen_fds) ++ + dnl Try to find a thread library. + dnl + dnl ETHR_LIB_NAME, ETHR_LIBS, ETHR_X_LIBS, ETHR_THR_LIB_BASE and ETHR_DEFS +diff --git a/erts/epmd/src/epmd_int.h b/erts/epmd/src/epmd_int.h +index bf1ddd8..363923e 100644 +--- a/erts/epmd/src/epmd_int.h ++++ b/erts/epmd/src/epmd_int.h +@@ -110,6 +110,10 @@ + + #include + ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++# include ++#endif ++ + /* ************************************************************************ */ + /* Replace some functions by others by making the function name a macro */ + +diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c +index 90df7cc..cb8ca96 100644 +--- a/erts/epmd/src/epmd_srv.c ++++ b/erts/epmd/src/epmd_srv.c +@@ -208,6 +208,39 @@ void run(EpmdVars *g) + node_init(g); + g->conn = conn_init(g); + ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ if (g->is_systemd) ++ { ++ int n; ++ ++ dbg_printf(g,2,"try to obtain sockets from systemd"); ++ ++ n = sd_listen_fds(0); ++ if (n < 0) ++ { ++ dbg_perror(g,"cannot obtain sockets from systemd"); ++ epmd_cleanup_exit(g,1); ++ } ++ else if (n == 0) ++ { ++ dbg_tty_printf(g,0,"systemd provides no sockets"); ++ epmd_cleanup_exit(g,1); ++ } ++ else if (n > MAX_LISTEN_SOCKETS) ++ { ++ dbg_tty_printf(g,0,"cannot listen on more than %d IP addresses", MAX_LISTEN_SOCKETS); ++ epmd_cleanup_exit(g,1); ++ } ++ num_sockets = n; ++ for (i = 0; i < num_sockets; i++) ++ { ++ g->listenfd[i] = listensock[i] = SD_LISTEN_FDS_START + i; ++ } ++ } ++ else ++ { ++#endif ++ + dbg_printf(g,2,"try to initiate listening port %d", g->port); + + if (g->addresses != NULL && /* String contains non-separator characters if: */ +@@ -272,6 +305,9 @@ void run(EpmdVars *g) + SET_ADDR(iserv_addr[0],EPMD_ADDR_ANY,sport); + num_sockets = 1; + } ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ } ++#endif + + #if !defined(__WIN32__) + /* We ignore the SIGPIPE signal that is raised when we call write +@@ -289,6 +325,13 @@ void run(EpmdVars *g) + FD_ZERO(&g->orig_read_mask); + g->select_fd_top = 0; + ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ if (g->is_systemd) ++ for (i = 0; i < num_sockets; i++) ++ select_fd_set(g, listensock[i]); ++ else ++ { ++#endif + for (i = 0; i < num_sockets; i++) + { + if ((listensock[i] = socket(FAMILY,SOCK_STREAM,0)) < 0) +@@ -351,6 +394,9 @@ void run(EpmdVars *g) + } + select_fd_set(g, listensock[i]); + } ++#ifdef HAVE_SYSTEMD_SD_DAEMON_H ++ } ++#endif + + dbg_tty_printf(g,2,"entering the main select() loop"); + diff --git a/sources b/sources index 3eb8f02..df29746 100644 --- a/sources +++ b/sources @@ -1,4 +1,4 @@ -fb39e206739e43501f6d27edf9b04b37 otp_doc_html_R16B03.tar.gz -099ed598feadc54e7efea908cc598f08 otp_doc_man_R16B03.tar.gz -d8b65a1492007f388545176300182d4f otp_src_R16B03.readme -c330150913556a0fe73e57a441cb6375 otp_src_R16B03.tar.gz +d27250e9ee98d6388e7f2e65379a0406 otp_src_R16B03-1.readme +eff44490c9bbae3a5c5741bec2390ba3 otp_doc_html_R16B03-1.tar.gz +39113c0d2515bdd8cd7e0f975a380122 otp_doc_man_R16B03-1.tar.gz +e5ece977375197338c1b93b3d88514f8 otp_src_R16B03-1.tar.gz