Subject: [alpine-aports] [PATCH] main/libsrtp: modernize, enable test

From: alpine-mips-patches <[email-masked]>
Date: Tue, 17 Nov 2018 20:09:04 +0000

- use cracklib-words for test since there is no /usr/share/dict/words in Alpine (really?);
- built-in test passes on x86_64 and mipsel at least;
- the real motivation was to fix build on mips* (fix-name-collision.patch -- could be safely dropped);
---
 main/libsrtp/APKBUILD                 | 38 +++++++++++++------
 main/libsrtp/fix-name-collision.patch | 54 +++++++++++++++++++++++++++
 main/libsrtp/use-cracklib-words.patch | 11 ++++++
 3 files changed, 92 insertions(+), 11 deletions(-)
 create mode 100644 main/libsrtp/fix-name-collision.patch
 create mode 100644 main/libsrtp/use-cracklib-words.patch

diff --git a/main/libsrtp/APKBUILD b/main/libsrtp/APKBUILD
index 45d9a04d0a..71873f243f 100644
--- a/main/libsrtp/APKBUILD
+++ b/main/libsrtp/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=libsrtp
 pkgver=1.5.4
-pkgrel=0
+pkgrel=1
 pkgdesc="An implementation of the Secure Real-time Transport Protocol (SRTP)"
 url="http://srtp.sourceforge.net"
 arch="all"
@@ -10,29 +10,45 @@ license="BSD"
 depends=""
 depends_dev=""
 makedepends="$depends_dev automake autoconf libtool"
+checkdepends="cracklib-words"
 install=""
 subpackages="$pkgname-dev"
-source="$pkgname-$pkgver.tar.gz::https://github.com/cisco/libsrtp/archive/v$pkgver.tar.gz"
+source="$pkgname-$pkgver.tar.gz::https://github.com/cisco/libsrtp/archive/v$pkgver.tar.gz
+	fix-name-collision.patch
+	use-cracklib-words.patch
+	"
 
 builddir="$srcdir"/libsrtp-$pkgver
 
+prepare() {
+	default_prepare
+	update_config_guess
+	update_config_sub
+}
+
 build() {
 	cd "$builddir"
-	update_config_guess || return 1
-	./configure --prefix=/usr \
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--prefix=/usr \
 		--sysconfdir=/etc \
 		--mandir=/usr/share/man \
 		--infodir=/usr/share/info \
-		--localstatedir=/var \
-		|| return 1
-	make || return 1
+		--localstatedir=/var
+	make
 }
 
 package() {
 	cd "$builddir"
-	make DESTDIR="$pkgdir" install || return 1
+	make DESTDIR="$pkgdir" install
+}
+
+check() {
+	cd "$builddir"
+	make runtest
 }
 
-md5sums="64a9580f86a9c3e1c4986e944e6a5a84  libsrtp-1.5.4.tar.gz"
-sha256sums="56a7b521c25134f48faff26b0b1e3d4378a14986a2d3d7bc6fefb48987304ff0  libsrtp-1.5.4.tar.gz"
-sha512sums="fcf6a36a0f687a6aa2b245e4055332ae892c953e19ebe3bfb7d091da0a7afbfcb804d9f602bd2d849235b559d3ca7924ee00c7f0da419c23b053b096ef4ccd19  libsrtp-1.5.4.tar.gz"
+sha512sums="fcf6a36a0f687a6aa2b245e4055332ae892c953e19ebe3bfb7d091da0a7afbfcb804d9f602bd2d849235b559d3ca7924ee00c7f0da419c23b053b096ef4ccd19  libsrtp-1.5.4.tar.gz
+9e0dd1e04852d217e195e1677d5b4b6dc60f0732ca376e7957aa3d8f400bb75ca19fb169908741420adc7d740a9023309a251da3f648e03ff18bf297a167f845  fix-name-collision.patch
+69f0d6cb8886a9751fbc6be8886a987c4f22dd191fbb38034dacf78c7723bc979e93b766fc81a656bdad8af8f4ae18b7625aba17da9c5b9c120c967134fb9506  use-cracklib-words.patch"
diff --git a/main/libsrtp/fix-name-collision.patch b/main/libsrtp/fix-name-collision.patch
new file mode 100644
index 0000000000..4f109a4190
--- /dev/null
+++ b/main/libsrtp/fix-name-collision.patch
@@ -0,0 +1,54 @@
+--- a/test/srtp_driver.c
++++ b/test/srtp_driver.c
+@@ -341,7 +341,7 @@
+   if (do_codec_timing) {
+     srtp_policy_t policy;
+     int ignore;
+-    double mips = mips_estimate(1000000000, &ignore);
++    double mips_est = mips_estimate(1000000000, &ignore);
+ 
+     crypto_policy_set_rtp_default(&policy.rtp);
+     crypto_policy_set_rtcp_default(&policy.rtcp);
+@@ -353,33 +353,33 @@
+     policy.allow_repeat_tx = 0;
+     policy.next = NULL;
+ 
+-    printf("mips estimate: %e\n", mips);
++    printf("mips estimate: %e\n", mips_est);
+ 
+     printf("testing srtp processing time for voice codecs:\n");
+     printf("codec\t\tlength (octets)\t\tsrtp instructions/second\n");
+     printf("G.711\t\t%d\t\t\t%e\n", 80, 
+-           (double) mips * (80 * 8) / 
++           (double) mips_est * (80 * 8) / 
+ 	   srtp_bits_per_second(80, &policy) / .01 );
+     printf("G.711\t\t%d\t\t\t%e\n", 160, 
+-           (double) mips * (160 * 8) / 
++           (double) mips_est * (160 * 8) / 
+ 	   srtp_bits_per_second(160, &policy) / .02);
+     printf("G.726-32\t%d\t\t\t%e\n", 40, 
+-           (double) mips * (40 * 8) / 
++           (double) mips_est * (40 * 8) / 
+ 	   srtp_bits_per_second(40, &policy) / .01 );
+     printf("G.726-32\t%d\t\t\t%e\n", 80, 
+-           (double) mips * (80 * 8) / 
++           (double) mips_est * (80 * 8) / 
+ 	   srtp_bits_per_second(80, &policy) / .02);
+     printf("G.729\t\t%d\t\t\t%e\n", 10, 
+-           (double) mips * (10 * 8) / 
++           (double) mips_est * (10 * 8) / 
+ 	   srtp_bits_per_second(10, &policy) / .01 );
+     printf("G.729\t\t%d\t\t\t%e\n", 20, 
+-           (double) mips * (20 * 8) /
++           (double) mips_est * (20 * 8) /
+ 	   srtp_bits_per_second(20, &policy) / .02 );
+     printf("Wideband\t%d\t\t\t%e\n", 320, 
+-           (double) mips * (320 * 8) /
++           (double) mips_est * (320 * 8) /
+ 	   srtp_bits_per_second(320, &policy) / .01 );
+     printf("Wideband\t%d\t\t\t%e\n", 640, 
+-           (double) mips * (640 * 8) /
++           (double) mips_est * (640 * 8) /
+ 	   srtp_bits_per_second(640, &policy) / .02 );
+   }
+ 
diff --git a/main/libsrtp/use-cracklib-words.patch b/main/libsrtp/use-cracklib-words.patch
new file mode 100644
index 0000000000..ed33c15e1e
--- /dev/null
+++ b/main/libsrtp/use-cracklib-words.patch
@@ -0,0 +1,11 @@
+--- a/test/rtpw.c
++++ b/test/rtpw.c
+@@ -93,7 +93,7 @@
+ #ifdef RTPW_USE_WINSOCK2
+ # define DICT_FILE        "words.txt"
+ #else
+-# define DICT_FILE        "/usr/share/dict/words"
++# define DICT_FILE        "/usr/share/dict/cracklib-words"
+ #endif
+ #define USEC_RATE        (5e5)
+ #define MAX_WORD_LEN     128  
-- 
2.19.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---