[netplug] provide native systemd unit file (#914762)

Jiří Popelka jpopelka at fedoraproject.org
Mon Feb 25 16:56:05 UTC 2013


commit a32b89ebe69aa2ac26c6761eddc9eddd06697b25
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Mon Feb 25 17:53:58 2013 +0100

    provide native systemd unit file (#914762)

 .gitignore                                         |    2 +-
 netplug-1.2.9.1-init.patch                         |  140 --------------------
 ...hield.patch => netplug-1.2.9.2-execshield.patch |   50 +++-----
 netplug-1.2.9.2-man.patch                          |   26 ++++
 netplug.spec                                       |   62 ++++-----
 netplugd.service                                   |   10 ++
 sources                                            |    2 +-
 7 files changed, 83 insertions(+), 209 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 38cbc86..546ade3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-netplug-1.2.9.1.tar.bz2
+netplug-1.2.9.2.tar.bz2
diff --git a/netplug-1.2.9.1-execshield.patch b/netplug-1.2.9.2-execshield.patch
similarity index 73%
rename from netplug-1.2.9.1-execshield.patch
rename to netplug-1.2.9.2-execshield.patch
index b9809f1..13afdfc 100644
--- a/netplug-1.2.9.1-execshield.patch
+++ b/netplug-1.2.9.2-execshield.patch
@@ -1,6 +1,6 @@
-diff -up netplug-1.2.9.1/if_info.c.execshield netplug-1.2.9.1/if_info.c
---- netplug-1.2.9.1/if_info.c.execshield	2008-12-23 00:36:23.000000000 +0100
-+++ netplug-1.2.9.1/if_info.c	2009-09-09 10:02:12.000000000 +0200
+diff -up netplug-1.2.9.2/if_info.c.execshield netplug-1.2.9.2/if_info.c
+--- netplug-1.2.9.2/if_info.c.execshield	2008-12-23 00:36:23.000000000 +0100
++++ netplug-1.2.9.2/if_info.c	2013-02-25 17:50:17.163086627 +0100
 @@ -95,15 +95,16 @@ flags_str(char *buf, unsigned int fl)
      return buf;
  }
@@ -53,16 +53,10 @@ diff -up netplug-1.2.9.1/if_info.c.execshield netplug-1.2.9.1/if_info.c
  
      if (info == NULL) {
          do_log(LOG_INFO, "Unexpected child %d exited with status %d",
-diff -up netplug-1.2.9.1/main.c.execshield netplug-1.2.9.1/main.c
---- netplug-1.2.9.1/main.c.execshield	2008-12-23 00:36:23.000000000 +0100
-+++ netplug-1.2.9.1/main.c	2009-09-09 10:02:12.000000000 +0200
-@@ -161,11 +161,28 @@ child_handler(int sig, siginfo_t *info, 
-     ce.pid = info->si_pid;
-     ret = waitpid(info->si_pid, &ce.status, 0);
-     if (ret == info->si_pid)
--        write(child_handler_pipe[1], &ce, sizeof(ce));
-+        (void)write(child_handler_pipe[1], &ce, sizeof(ce));
- }
+diff -up netplug-1.2.9.2/main.c.execshield netplug-1.2.9.2/main.c
+--- netplug-1.2.9.2/main.c.execshield	2010-06-26 18:35:12.000000000 +0200
++++ netplug-1.2.9.2/main.c	2013-02-25 17:50:17.164086613 +0100
+@@ -175,6 +175,23 @@ child_handler(int sig, siginfo_t *info,
  
  /* Poll the existing interface state, so we can catch any state
     changes for which we may not have neen a netlink message. */
@@ -86,7 +80,7 @@ diff -up netplug-1.2.9.1/main.c.execshield netplug-1.2.9.1/main.c
  static void
  poll_interfaces(void)
  {
-@@ -180,24 +197,13 @@ poll_interfaces(void)
+@@ -189,24 +206,13 @@ poll_interfaces(void)
          close_on_exec(sockfd);
      }
  
@@ -117,7 +111,7 @@ diff -up netplug-1.2.9.1/main.c.execshield netplug-1.2.9.1/main.c
  }
  
  int debug = 0;
-@@ -331,17 +337,11 @@ main(int argc, char *argv[])
+@@ -340,17 +346,11 @@ main(int argc, char *argv[])
          { child_handler_pipe[0], POLLIN, 0 },
      };
  
@@ -140,9 +134,9 @@ diff -up netplug-1.2.9.1/main.c.execshield netplug-1.2.9.1/main.c
  
      for(;;) {
          int ret;
-diff -up netplug-1.2.9.1/Makefile.execshield netplug-1.2.9.1/Makefile
---- netplug-1.2.9.1/Makefile.execshield	2008-12-23 00:41:38.000000000 +0100
-+++ netplug-1.2.9.1/Makefile	2009-09-09 10:02:12.000000000 +0200
+diff -up netplug-1.2.9.2/Makefile.execshield netplug-1.2.9.2/Makefile
+--- netplug-1.2.9.2/Makefile.execshield	2010-06-26 18:35:51.000000000 +0200
++++ netplug-1.2.9.2/Makefile	2013-02-25 17:50:17.164086613 +0100
 @@ -4,15 +4,15 @@ DESTDIR ?=
  
  prefix ?=
@@ -155,7 +149,7 @@ diff -up netplug-1.2.9.1/Makefile.execshield netplug-1.2.9.1/Makefile
  
  install_opts :=
  
--CFLAGS += -Wall -Werror -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
+-CFLAGS += -Wall -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
 -	-DNP_SCRIPT_DIR='"$(scriptdir)"' -ggdb3 -O3 -DNP_VERSION='"$(version)"'
 +CFLAGS += -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
 +	-DNP_SCRIPT_DIR='"$(scriptdir)"' -DNP_VERSION='"$(version)"'
@@ -177,21 +171,9 @@ diff -up netplug-1.2.9.1/Makefile.execshield netplug-1.2.9.1/Makefile
  
  tarball: $(tar_file)
  
-diff -up netplug-1.2.9.1/man/man8/netplugd.8.execshield netplug-1.2.9.1/man/man8/netplugd.8
---- netplug-1.2.9.1/man/man8/netplugd.8.execshield	2008-12-23 00:36:23.000000000 +0100
-+++ netplug-1.2.9.1/man/man8/netplugd.8	2009-09-09 10:07:33.000000000 +0200
-@@ -134,7 +134,7 @@ to run in the foreground, this option is
- .\"
- .Sh FILES
- .Bl -tag -width Ds
--.It Pa /etc/netplug/netplugd.conf
-+.It Pa /etc/netplug.d/netplugd.conf
- Default config file to read, if none is specified on the command line.
- The config file format is one pattern per line, with white space,
- empty lines, and comments starting with a
-diff -up netplug-1.2.9.1/netplug.h.execshield netplug-1.2.9.1/netplug.h
---- netplug-1.2.9.1/netplug.h.execshield	2008-12-23 00:36:23.000000000 +0100
-+++ netplug-1.2.9.1/netplug.h	2009-09-09 10:02:12.000000000 +0200
+diff -up netplug-1.2.9.2/netplug.h.execshield netplug-1.2.9.2/netplug.h
+--- netplug-1.2.9.2/netplug.h.execshield	2008-12-23 00:36:23.000000000 +0100
++++ netplug-1.2.9.2/netplug.h	2013-02-25 17:50:17.164086613 +0100
 @@ -83,7 +83,7 @@ struct if_info *if_info_update_interface
                                           struct rtattr *attrs[]);
  int if_info_save_interface(struct nlmsghdr *hdr, void *arg);
diff --git a/netplug-1.2.9.2-man.patch b/netplug-1.2.9.2-man.patch
new file mode 100644
index 0000000..ffb2eb9
--- /dev/null
+++ b/netplug-1.2.9.2-man.patch
@@ -0,0 +1,26 @@
+diff -up netplug-1.2.9.2/man/man8/netplugd.8.man netplug-1.2.9.2/man/man8/netplugd.8
+--- netplug-1.2.9.2/man/man8/netplugd.8.man     2008-12-23 00:36:23.000000000 +0100
++++ netplug-1.2.9.2/man/man8/netplugd.8 2013-02-25 15:20:13.759315644 +0100
+@@ -134,7 +134,7 @@ to run in the foreground, this option is
+ .\"
+ .Sh FILES
+ .Bl -tag -width Ds
+-.It Pa /etc/netplug/netplugd.conf
++.It Pa /etc/netplug.d/netplugd.conf
+ Default config file to read, if none is specified on the command line.
+ The config file format is one pattern per line, with white space,
+ empty lines, and comments starting with a
+@@ -165,13 +165,6 @@ can generate
+ events.  The command is run synchronously; it must exit with status
+ code 0 if it succeeds, otherwise with a non-zero exit code or signal.
+ .El
+-.It Pa /etc/rc.d/init.d/netplugd
+-The
+-.Xr init 8
+-script that starts, stops, and displays status of the
+-.Nm
+-daemon.
+-.El
+ .\"
+ .\"
+ .Sh AUTHOR
diff --git a/netplug.spec b/netplug.spec
index 5840280..5a63e55 100644
--- a/netplug.spec
+++ b/netplug.spec
@@ -1,25 +1,22 @@
 Summary: Daemon that responds to network cables being plugged in and out
 Name: netplug
-Version: 1.2.9.1
-Release: 7%{?dist}
+Version: 1.2.9.2
+Release: 1%{?dist}
 License: GPLv2
 Group: System Environment/Base
 URL: http://www.red-bean.com/~bos/
 Source0: http://www.red-bean.com/~bos/netplug/netplug-%{version}.tar.bz2
+Source1: netplugd.service
 
 #execshield patch for netplug <t8m at redhat.com>
-Patch1: netplug-1.2.9.1-execshield.patch
-
-#fix netplugd init script (#242919)
-#fix init script to be LSB-compliant (#522888)
-Patch2: netplug-1.2.9.1-init.patch
-
-Requires: iproute >= 2.4.7
-Conflicts: net-tools < 1.60-96
-Requires(post): /sbin/chkconfig
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
+Patch1: netplug-1.2.9.2-execshield.patch
+
+Patch2: netplug-1.2.9.2-man.patch
+
+Requires: iproute
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
 BuildRequires: gettext
 
 %description
@@ -37,7 +34,7 @@ without a need for manual intervention.
 %prep
 %setup -q
 %patch1 -p1 -b .execshield
-%patch2 -p1 -b .init
+%patch2 -p1 -b .man
 
 %build
 export CFLAGS="$RPM_OPT_FLAGS $CFLAGS"
@@ -45,7 +42,7 @@ make
 
 %install
 make install prefix=%{buildroot} \
-             initdir=%{buildroot}/%{_initrddir} \
+             bindir=%{buildroot}/%{_sbindir} \
              mandir=%{buildroot}/%{_mandir}
 
 mkdir -p %{buildroot}/%{_mandir}/man5
@@ -53,34 +50,34 @@ ln -fs %{_mandir}/man8/netplugd.8.gz %{buildroot}/%{_mandir}/man5/netplug.5.gz
 ln -fs %{_mandir}/man8/netplugd.8.gz %{buildroot}/%{_mandir}/man5/netplug.d.5.gz
 ln -fs %{_mandir}/man8/netplugd.8.gz %{buildroot}/%{_mandir}/man5/netplugd.conf.5.gz
 
-%clean
-rm -rf %{buildroot}
+# systemd unit files
+mkdir -p %{buildroot}%{_unitdir}
+install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}
+
+rm -f %{buildroot}/etc/rc.d/init.d/netplugd
 
 %post
-  /sbin/chkconfig --add netplugd
-  exit 0
+%systemd_post netplugd.service
 
 %preun
-if [ "$1" = "0" ]; then
-  /sbin/chkconfig --del netplugd || :
-  /sbin/service netplugd stop &> /dev/null || :
-fi
-exit 0
-
+%systemd_preun netplugd.service
+ 
 %postun
-  /sbin/service netplugd condrestart >/dev/null 2>&1 || :
-  exit 0
+%systemd_postun_with_restart netplugd.service
 
 %files
-%defattr(-,root,root)
 %doc COPYING README TODO
-/sbin/netplugd
+%{_sbindir}/netplugd
 %{_mandir}/man[58]/*
-%{_sysconfdir}/netplug.d
+%dir %{_sysconfdir}/netplug.d
+%{_sysconfdir}/netplug.d/netplug
 %config(noreplace) %{_sysconfdir}/netplug.d/netplugd.conf
-%{_initddir}/netplugd
+%{_unitdir}/netplugd.service
 
 %changelog
+* Mon Feb 25 2013 Jiri Popelka <jpopelka at redhat.com> - 1.2.9.2-1
+- provide native systemd unit file (#914762)
+
 * Thu Feb 14 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.2.9.1-7
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
 
@@ -93,7 +90,6 @@ exit 0
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.2.9.1-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 
-
 * Wed Sep 30 2009  Jiri Popelka <jpopelka at redhat.com> - 1.2.9.1-3
 - use %{_initddir} macro instead of deprecated %{_initrddir}
 
diff --git a/netplugd.service b/netplugd.service
new file mode 100644
index 0000000..58314fe
--- /dev/null
+++ b/netplugd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Netplug Non-Static Network Interface Manager
+Documentation=man:netplugd(8)
+After=network.target
+
+[Service]
+ExecStart=/sbin/netplugd -F
+
+[Install]
+WantedBy=multi-user.target
diff --git a/sources b/sources
index 56b9198..99e0b92 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-1e439dc3fc5a52de0b85467efbd25a57  netplug-1.2.9.1.tar.bz2
+1d6db99536bdf875ce441f2c0e45ebf2  netplug-1.2.9.2.tar.bz2


More information about the scm-commits mailing list