[ampr-ripd] Initial import (#1124483)
Jaroslav Škarvada
jskarvad at fedoraproject.org
Fri Aug 29 13:32:11 UTC 2014
commit 9382cabf2f5bdc2fd40f9d7c062c3316fae03c9f
Author: Jaroslav Škarvada <jskarvad at redhat.com>
Date: Fri Aug 29 15:32:08 2014 +0200
Initial import (#1124483)
.gitignore | 1 +
ampr-ripd-1.11-examples-noshebang.patch | 25 +++++++++++
ampr-ripd-1.11-install-fix.patch | 43 ++++++++++++++++++++
ampr-ripd-1.11-pidfile.patch | 40 ++++++++++++++++++
ampr-ripd.service | 12 ++++++
ampr-ripd.spec | 67 +++++++++++++++++++++++++++++++
sources | 1 +
7 files changed, 189 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..3fd01ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/ampr-ripd-1.11.tgz
diff --git a/ampr-ripd-1.11-examples-noshebang.patch b/ampr-ripd-1.11-examples-noshebang.patch
new file mode 100644
index 0000000..a8e55c4
--- /dev/null
+++ b/ampr-ripd-1.11-examples-noshebang.patch
@@ -0,0 +1,25 @@
+diff --git a/ampr-run.sh b/ampr-run.sh
+index 105ee04..1b7e8ef 100755
+--- a/ampr-run.sh
++++ b/ampr-run.sh
+@@ -1,5 +1,3 @@
+-#!/bin/sh
+-
+ #
+ # Example of how to run ampr-ripd
+ #
+diff --git a/find_pass.sh b/find_pass.sh
+index 6d585b8..5c9c3a1 100755
+--- a/find_pass.sh
++++ b/find_pass.sh
+@@ -1,9 +1,7 @@
+-#!/bin/sh
+-
+ #
+ # Running ampr-ripd without any options except debug and the interface name
+ # allows you to find your RIPv2 password
+ # You need to adapt the interface name to your setup
+ #
+
+-./ampr-ripd -d -i ampr0
++ampr-ripd -d -i ampr0
diff --git a/ampr-ripd-1.11-install-fix.patch b/ampr-ripd-1.11-install-fix.patch
new file mode 100644
index 0000000..d666268
--- /dev/null
+++ b/ampr-ripd-1.11-install-fix.patch
@@ -0,0 +1,43 @@
+diff --git a/Makefile b/Makefile
+index ac8146d..f9956c5 100644
+--- a/Makefile
++++ b/Makefile
+@@ -2,13 +2,9 @@
+ # Makefile for ampr-ripd
+ #
+
+-BASEDIR = /usr
++BASEDIR = $(DESTDIR)/usr
+ SBINDIR = $(BASEDIR)/sbin
+-SCACHEDIR = /var/lib/ampr-ripd
+-
+-# no need to run dx-broadcast as root
+-OWN = daemon
+-GRP = daemon
++SCACHEDIR = $(DESTDIR)/var/lib/ampr-ripd
+
+ CC = gcc
+
+@@ -22,11 +18,11 @@ CC = gcc
+ # Full debug
+ #DOPT = -Wall -O2 -D HAVE_DEBUG
+
+-COPT = -Wall -O2
+-LOPT =
++CFLAGS = -Wall -O2
++LDFLAGS =
+
+ ampr-ripd: ampr-ripd.c
+- $(CC) $(COPT) $(DOPT) $(LOPT) -o ampr-ripd ampr-ripd.c
++ $(CC) $(CFLAGS) $(DOPT) $(LDFLAGS) -o ampr-ripd ampr-ripd.c
+
+ all: ampr-ripd
+
+@@ -35,5 +31,5 @@ clean:
+
+ install: ampr-ripd
+ strip ampr-ripd
+- install -m 755 -o $(OWN) -g $(GRP) -d $(SCACHEDIR)
+- install -m 755 -o $(OWN) -g $(GRP) ampr-ripd $(SBINDIR)
++ install -m 755 -p -D -d $(SCACHEDIR)
++ install -m 755 -p -D ampr-ripd $(SBINDIR)/ampr-ripd
diff --git a/ampr-ripd-1.11-pidfile.patch b/ampr-ripd-1.11-pidfile.patch
new file mode 100644
index 0000000..c25c50e
--- /dev/null
+++ b/ampr-ripd-1.11-pidfile.patch
@@ -0,0 +1,40 @@
+diff --git a/ampr-ripd.c b/ampr-ripd.c
+index 697a48e..3af51dc 100644
+--- a/ampr-ripd.c
++++ b/ampr-ripd.c
+@@ -102,6 +102,8 @@
+
+ #define RTAB_FILE "/etc/iproute2/rt_tables" /* route tables */
+
++#define PID_FILE "/var/run/ampr-ripd.pid" /* pid file */
++
+ #define BUFFERSIZE 8192
+ #define MYIPSIZE 25 /* max number of local interface IPs */
+ #define MAXIGNORE 10 /* max number of hosts in the ignore list */
+@@ -1423,6 +1425,7 @@ static void on_term(int sig)
+ #ifdef HAVE_DEBUG
+ if (debug && verbose) fprintf(stderr, "SIGTERM/SIGKILL received.\n");
+ #endif
++ unlink(PID_FILE);
+ close(fwsd);
+ close(tunsd);
+ route_delete_all();
+@@ -1496,6 +1499,7 @@ int main(int argc, char **argv)
+ char *pload;
+ int len, plen;
+ int lval;
++ FILE *pidfile;
+
+ while ((p = getopt(argc, argv, "dvsrh?i:a:p:t:m:w:f:e:")) != -1)
+ {
+@@ -1730,6 +1734,10 @@ int main(int argc, char **argv)
+ signal(SIGHUP, on_hup);
+ signal(SIGALRM, on_alarm);
+
++ pidfile = fopen(PID_FILE, "w");
++ fprintf(pidfile, "%d\n", (int)getpid());
++ fclose(pidfile);
++
+ /* daemon or debug */
+
+ if (debug) fprintf(stderr, "Waiting for RIPv2 broadcasts...\n");
diff --git a/ampr-ripd.service b/ampr-ripd.service
new file mode 100644
index 0000000..3e0a3cc
--- /dev/null
+++ b/ampr-ripd.service
@@ -0,0 +1,12 @@
+[Unit]
+Description = AMPR Routing Daemon
+After = network.target
+
+[Service]
+Type = forking
+PIDFile = /run/ampr-ripd.pid
+ExecStart = /usr/sbin/ampr-ripd
+ExecReload = /bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy = multi-user.target
diff --git a/ampr-ripd.spec b/ampr-ripd.spec
new file mode 100644
index 0000000..c7544b1
--- /dev/null
+++ b/ampr-ripd.spec
@@ -0,0 +1,67 @@
+# hardened build if not overriden
+%{!?_hardened_build:%global _hardened_build 1}
+
+%if %{?_hardened_build}%{!?_hardened_build:0}
+%global cflags_harden -fpie
+%global ldflags_harden -pie -z relro -z now
+%endif
+
+Summary: Routing daemon for the ampr network
+Name: ampr-ripd
+Version: 1.11
+Release: 1%{?dist}
+License: GPLv2+
+Group: Applications/Communications
+URL: http://www.yo2loj.ro/hamprojects/
+BuildRequires: dos2unix, systemd
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+Source0: http://www.yo2loj.ro/hamprojects/%{name}-%{version}.tgz
+Source1: ampr-ripd.service
+Patch0: ampr-ripd-1.11-install-fix.patch
+Patch1: ampr-ripd-1.11-examples-noshebang.patch
+Patch2: ampr-ripd-1.11-pidfile.patch
+
+%description
+Routing daemon written in C similar to Hessu's rip44d including optional
+resending of RIPv2 broadcasts for router injection.
+
+%prep
+%setup -qc
+%patch0 -p1 -b .install-fix
+%patch1 -p1 -b .examples-noshebang
+%patch2 -p1 -b .pidfile
+
+%build
+make %{?_smp_mflags} CFLAGS="%{optflags} %{?cflags_harden}" LDFLAGS="%{?__global_ldflags} %{?ldflags_harden}"
+
+%install
+make %{?_smp_mflags} DESTDIR=%{buildroot} install
+
+# Systemd
+install -Dpm 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
+
+# Examples
+install -Dd %{buildroot}%{_datadir}/%{name}
+install -Dpm 644 -t %{buildroot}%{_datadir}/%{name} ampr-run.sh find_pass.sh
+
+%post
+%systemd_post %{name}.service
+
+%preun
+%systemd_preun %{name}.service
+
+%postun
+%systemd_postun_with_restart %{name}.service
+
+%files
+%doc COPYING manual.txt
+
+%{_sbindir}/ampr-ripd
+%{_datadir}/%{name}
+%{_unitdir}/%{name}.service
+
+%changelog
+* Tue Jul 22 2014 Jaroslav Škarvada <jskarvad at redhat.com> - 1.11-1
+- Initial release
diff --git a/sources b/sources
index e69de29..e87bf1b 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+c459c388c9acc8be0aff29a8bbd85ece ampr-ripd-1.11.tgz
More information about the scm-commits
mailing list