From a5600d9f8491c1253c4d81e81d62dfc33ba36b07 Mon Sep 17 00:00:00 2001 From: tushenmei Date: Fri, 28 Aug 2020 16:01:50 +0800 Subject: [PATCH] package init --- 0001-Add-vim-modelines-to-source-files.patch | 35 ++++++ 0002-test-test.c-Whitespace-cleanup.patch | 44 +++++++ ...st-Implement-self-test-functionality.patch | 114 ++++++++++++++++++ ...ke-self-test-accessible-by-make-test.patch | 48 ++++++++ ...-Allow-setting-custom-compiler-flags.patch | 49 ++++++++ libkeepalive-0.3.tar.gz | Bin 0 -> 4281 bytes libkeepalive.spec | 41 +++++++ libkeepalive.yaml | 5 + 8 files changed, 336 insertions(+) create mode 100644 0001-Add-vim-modelines-to-source-files.patch create mode 100644 0002-test-test.c-Whitespace-cleanup.patch create mode 100644 0003-test-Implement-self-test-functionality.patch create mode 100644 0004-Makefile-Make-self-test-accessible-by-make-test.patch create mode 100644 0005-Makefile-Allow-setting-custom-compiler-flags.patch create mode 100644 libkeepalive-0.3.tar.gz create mode 100644 libkeepalive.spec create mode 100644 libkeepalive.yaml diff --git a/0001-Add-vim-modelines-to-source-files.patch b/0001-Add-vim-modelines-to-source-files.patch new file mode 100644 index 0000000..8517b7f --- /dev/null +++ b/0001-Add-vim-modelines-to-source-files.patch @@ -0,0 +1,35 @@ +From 6b41a8a337db852ec47635fcd724d73c9e1046c1 Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 25 Nov 2016 11:34:18 +0100 +Subject: [PATCH] Add vim modelines to source files + +This automatically sets up vim to use two space indenting if modelines +is active. + +Signed-off-by: Phil Sutter +--- + src/libkeepalive.c | 1 + + test/test.c | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/src/libkeepalive.c b/src/libkeepalive.c +index a08bd98abe7b8..06b66ca7a8ea5 100644 +--- a/src/libkeepalive.c ++++ b/src/libkeepalive.c +@@ -1,3 +1,4 @@ ++/* vim: set ts=2 sw=2 et: */ + /* + _ _ _ _ _ _ + | (_) |__ | | _____ ___ _ __ __ _| (_)_ _____ +diff --git a/test/test.c b/test/test.c +index 756d7ae631f4a..c793225eaa820 100644 +--- a/test/test.c ++++ b/test/test.c +@@ -1,3 +1,4 @@ ++/* vim: set ts=2 sw=2 et: */ + /* + _ _ _ _ _ _ + | (_) |__ | | _____ ___ _ __ __ _| (_)_ _____ +-- +2.10.0 + diff --git a/0002-test-test.c-Whitespace-cleanup.patch b/0002-test-test.c-Whitespace-cleanup.patch new file mode 100644 index 0000000..83ce786 --- /dev/null +++ b/0002-test-test.c-Whitespace-cleanup.patch @@ -0,0 +1,44 @@ +From ce70d7a39f384c526e0a0e5fdfd1d3ed523f4942 Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 25 Nov 2016 11:36:14 +0100 +Subject: [PATCH] test/test.c: Whitespace cleanup + +Signed-off-by: Phil Sutter +--- + test/test.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/test/test.c b/test/test.c +index c793225eaa820..224c1b4944fc5 100644 +--- a/test/test.c ++++ b/test/test.c +@@ -69,7 +69,7 @@ int main() + } + printf("TCP_KEEPCNT = %d\n", optval); + #endif +- ++ + #ifdef TCP_KEEPIDLE + if(getsockopt(s, SOL_TCP, TCP_KEEPIDLE, &optval, &optlen) < 0) { + perror("getsockopt()"); +@@ -78,7 +78,7 @@ int main() + } + printf("TCP_KEEPIDLE = %d\n", optval); + #endif +- ++ + #ifdef TCP_KEEPINTVL + if(getsockopt(s, SOL_TCP, TCP_KEEPINTVL, &optval, &optlen) < 0) { + perror("getsockopt()"); +@@ -88,7 +88,7 @@ int main() + printf("TCP_KEEPINTVL = %d\n", optval); + #endif + } +- ++ + close(s); + + exit(EXIT_SUCCESS); +-- +2.10.0 + diff --git a/0003-test-Implement-self-test-functionality.patch b/0003-test-Implement-self-test-functionality.patch new file mode 100644 index 0000000..47a69ee --- /dev/null +++ b/0003-test-Implement-self-test-functionality.patch @@ -0,0 +1,114 @@ +From c5e5b8415e9c91d132678dcfccde8df848ee70c8 Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 25 Nov 2016 11:38:02 +0100 +Subject: [PATCH] test: Implement self-test functionality + +This allows to run 'test' unattended by setting environment variable +SELFTEST=on. Instead of printing the settings libkeepalive should have +changed, it uses the input values still present in environment to assert +them being set correctly. + +Signed-off-by: Phil Sutter +--- + test/test.c | 42 ++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 38 insertions(+), 4 deletions(-) + +diff --git a/test/test.c b/test/test.c +index 224c1b4944fc5..7eaaaed2e9840 100644 +--- a/test/test.c ++++ b/test/test.c +@@ -32,14 +32,23 @@ + */ + + #define _GNU_SOURCE ++#include + #include + #include ++#include + #include + #include + #include + #include + #include + ++#define assert(x) do { \ ++ if (!(x)) { \ ++ printf("%s:%d: assertion '" #x "' failed!\n", __FILE__, __LINE__); \ ++ exit(EXIT_FAILURE); \ ++ } \ ++} while (0) ++ + int main(void); + + int main() +@@ -47,6 +56,11 @@ int main() + int s; + int optval; + socklen_t optlen = sizeof(optval); ++ const char *env; ++ bool selftest = false; ++ ++ env = getenv("SELFTEST"); ++ selftest = env && !strcasecmp(env, "on"); + + if((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + perror("socket()"); +@@ -58,7 +72,12 @@ int main() + close(s); + exit(EXIT_FAILURE); + } +- printf("SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF")); ++ if (selftest) { ++ env = getenv("KEEPALIVE"); ++ assert((env && !strcasecmp(env, "off")) ^ optval); ++ } else { ++ printf("SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF")); ++ } + + if(optval) { + #ifdef TCP_KEEPCNT +@@ -67,7 +86,12 @@ int main() + close(s); + exit(EXIT_FAILURE); + } +- printf("TCP_KEEPCNT = %d\n", optval); ++ if (selftest) { ++ env = getenv("KEEPCNT"); ++ assert(!env || atoi(env) == optval); ++ } else { ++ printf("TCP_KEEPCNT = %d\n", optval); ++ } + #endif + + #ifdef TCP_KEEPIDLE +@@ -76,7 +100,12 @@ int main() + close(s); + exit(EXIT_FAILURE); + } +- printf("TCP_KEEPIDLE = %d\n", optval); ++ if (selftest) { ++ env = getenv("KEEPIDLE"); ++ assert(!env || atoi(env) == optval); ++ } else { ++ printf("TCP_KEEPIDLE = %d\n", optval); ++ } + #endif + + #ifdef TCP_KEEPINTVL +@@ -85,7 +114,12 @@ int main() + close(s); + exit(EXIT_FAILURE); + } +- printf("TCP_KEEPINTVL = %d\n", optval); ++ if (selftest) { ++ env = getenv("KEEPINTVL"); ++ assert(!env || atoi(env) == optval); ++ } else { ++ printf("TCP_KEEPINTVL = %d\n", optval); ++ } + #endif + } + +-- +2.10.0 + diff --git a/0004-Makefile-Make-self-test-accessible-by-make-test.patch b/0004-Makefile-Make-self-test-accessible-by-make-test.patch new file mode 100644 index 0000000..84b5e57 --- /dev/null +++ b/0004-Makefile-Make-self-test-accessible-by-make-test.patch @@ -0,0 +1,48 @@ +From 22820938a43871b7cd634767809faec31d139f27 Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 25 Nov 2016 11:45:05 +0100 +Subject: [PATCH] Makefile: Make self-test accessible by 'make test' + +This will call 'test' three times: The first call makes sure that +KEEPALIVE=off is respected, the last two calls check that environment +variables KEEPCNT, KEEPIDLE and KEEPINTVL are applied as expected. + +Signed-off-by: Phil Sutter +--- + Makefile | 3 +++ + test/Makefile | 6 ++++++ + 2 files changed, 9 insertions(+) + +diff --git a/Makefile b/Makefile +index 524d6a98c8329..01622771d73c5 100644 +--- a/Makefile ++++ b/Makefile +@@ -13,6 +13,9 @@ default: + cp src/libkeepalive.so libkeepalive.so + strip -s libkeepalive.so + ++test: default ++ make -C test/ runtest ++ + clean: + make -C src/ clean + make -C test/ clean +diff --git a/test/Makefile b/test/Makefile +index 2a0f6e2780d5e..6baf822c2338d 100644 +--- a/test/Makefile ++++ b/test/Makefile +@@ -11,5 +11,11 @@ CC=gcc + + default: test + ++TENV = LD_PRELOAD=../libkeepalive.so SELFTEST=on ++runtest: ++ ${TENV} KEEPALIVE=off ./test ++ ${TENV} KEEPCNT=13 KEEPIDLE=23 KEEPINTVL=42 ./test ++ ${TENV} KEEPCNT=42 KEEPIDLE=13 KEEPINTVL=23 ./test ++ + clean: + rm -f test +-- +2.10.0 + diff --git a/0005-Makefile-Allow-setting-custom-compiler-flags.patch b/0005-Makefile-Allow-setting-custom-compiler-flags.patch new file mode 100644 index 0000000..5ba0536 --- /dev/null +++ b/0005-Makefile-Allow-setting-custom-compiler-flags.patch @@ -0,0 +1,49 @@ +From 910e5ec42b7d04e4d7e650f8bd20afd06f418ae5 Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 25 Nov 2016 12:22:13 +0100 +Subject: [PATCH] Makefile: Allow setting custom compiler flags + +This allows to override CC variable and to extend CFLAGS, LDFLAGS and +LDLIBS variables. + +Signed-off-by: Phil Sutter +--- + src/Makefile | 8 ++++---- + test/Makefile | 2 +- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/Makefile b/src/Makefile +index b8b0188502189..19e3785665a86 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -7,10 +7,10 @@ + # + # (C) Fabio Busatto + +-CC=gcc +-CFLAGS=-fPIC -ansi -pedantic -Wall +-LDFLAGS=-shared -Wl,-soname,libkeepalive.so +-LDLIBS=-ldl ++CC := gcc ++CFLAGS += -fPIC -ansi -pedantic -Wall ++LDFLAGS += -shared -Wl,-soname,libkeepalive.so ++LDLIBS += -ldl + + default: libkeepalive.so + +diff --git a/test/Makefile b/test/Makefile +index 6baf822c2338d..6a279a0ac6b94 100644 +--- a/test/Makefile ++++ b/test/Makefile +@@ -7,7 +7,7 @@ + # + # (C) Fabio Busatto + +-CC=gcc ++CC := gcc + + default: test + +-- +2.10.0 + diff --git a/libkeepalive-0.3.tar.gz b/libkeepalive-0.3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..276852c80220b14ad9dc4f901b3aeab531b4e3b1 GIT binary patch literal 4281 zcmV;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8>bA>D}bU5CP(|6`( znM{C)<0GyW#+$F2c&OnodFo!vjcP%tRcTkQ^se5PTSsDV>WdK9cGsnQH=p^QLzaK) zm@+P!g$TNicx??r72PoKdHFJ^Zv1xfr*a6GU;W5l0b!9do|f_mbb51EdO+D1VKPMh z-Px8QT*aIZkca(S1|U$Gx|&vNHePml(Y)5XYBTW$&XA+drE2b>a(pm^B_;9Fn4|kf zlQDE$OO1EnP*!l|?vT`b<&8Ume(%HaxjV@Is0e+Vylh( zA2~}0w!BLkTfhIQFhBnHCYg%naqA%zrDNFjw3Qb-|%6jDeb bg%naqA%zrDNFjw3{(s=#_ioD?0C)fZz&NU> literal 0 HcmV?d00001 diff --git a/libkeepalive.spec b/libkeepalive.spec new file mode 100644 index 0000000..88c47b1 --- /dev/null +++ b/libkeepalive.spec @@ -0,0 +1,41 @@ +Name: libkeepalive +Version: 0.3 +Release: 1 +Summary: Enable TCP keepalive in dynamic binaries +URL: http://libkeepalive.sourceforge.net/ +BuildRequires: gcc +License: MIT +Source0: https://cfhcable.dl.sourceforge.net/project/%{name}/%{name}/0.3/%{name}-0.3.tar.gz + +# All patches sent to the upstream maintainer directly via email. +Patch1: 0001-Add-vim-modelines-to-source-files.patch +Patch2: 0002-test-test.c-Whitespace-cleanup.patch +Patch3: 0003-test-Implement-self-test-functionality.patch +Patch4: 0004-Makefile-Make-self-test-accessible-by-make-test.patch +Patch5: 0005-Makefile-Allow-setting-custom-compiler-flags.patch +%description +libkeepalive is a library that enables tcp keepalive features in glibc based +binary dynamic executables, without any change in the original program. + +%prep +%autosetup -p1 + +%build +export CFLAGS="%{optflags}" +export LDFLAGS="%{__global_ldflags}" +%make_build + +%check +make test + +%install +install -p -m 0755 -D src/libkeepalive.so %{buildroot}%{_libdir}/libkeepalive.so + +%files +%license LICENSE +%doc README +%{_libdir}/libkeepalive.so + +%changelog +* Thu Aug 13 2020 tuShenmei - 0.3-1 +- package init diff --git a/libkeepalive.yaml b/libkeepalive.yaml new file mode 100644 index 0000000..5d8dd64 --- /dev/null +++ b/libkeepalive.yaml @@ -0,0 +1,5 @@ +--- +version_control: NA +src_repo: NA +tag_prefix: "libkeepalive-" +separator: "."