Subject: [alpine-aports] [PATCH 1/3] main/libbsd: fix a.out.h bug

From: "Tuan M. Hoang" <[email-masked]>
Date: Wed, 19 Apr 2017 01:11:44 -0400

Ref
https://git.yoctoproject.org/cgit.cgi/poky/tree/meta/recipes-support/libbsd/libbsd
https://patchwork.openembedded.org/patch/133637/

---
 ...001-Replace-__BEGIN_DECLS-and-__END_DECLS.patch | 363 +++++++++++++++++++++
 main/libbsd/0002-Remove-funopen.patch              |  55 ++++
 ...3-Fix-build-breaks-due-to-missing-a.out.h.patch | 130 ++++++++
 main/libbsd/APKBUILD                               |  15 +-
 main/libbsd/musl-fixes.patch                       |  30 --
 5 files changed, 556 insertions(+), 37 deletions(-)
 create mode 100644 main/libbsd/0001-Replace-__BEGIN_DECLS-and-__END_DECLS.patch
 create mode 100644 main/libbsd/0002-Remove-funopen.patch
 create mode 100644 main/libbsd/0003-Fix-build-breaks-due-to-missing-a.out.h.patch
 delete mode 100644 main/libbsd/musl-fixes.patch

diff --git a/main/libbsd/0001-Replace-__BEGIN_DECLS-and-__END_DECLS.patch b/main/libbsd/0001-Replace-__BEGIN_DECLS-and-__END_DECLS.patch
new file mode 100644
index 00000000..e97e30e8
--- /dev/null
+++ b/main/libbsd/0001-Replace-__BEGIN_DECLS-and-__END_DECLS.patch
@@ -0,0 +1,363 @@
+From 88adbe1a855b7aa95bd925c80ed83c86f3fc42e3 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email-masked]>
+Date: Sun, 6 Nov 2016 09:39:31 -0800
+Subject: [PATCH 1/3] Replace __BEGIN_DECLS and __END_DECLS
+
+Signed-off-by: Khem Raj <[email-masked]>
+---
+Upstream-Status: Pending
+
+ include/bsd/err.h            | 10 ++++++++--
+ include/bsd/libutil.h        | 10 ++++++++--
+ include/bsd/md5.h            | 10 ++++++++--
+ include/bsd/nlist.h          | 10 ++++++++--
+ include/bsd/readpassphrase.h | 10 ++++++++--
+ include/bsd/stdio.h          | 10 ++++++++--
+ include/bsd/stdlib.h         | 10 ++++++++--
+ include/bsd/string.h         | 10 ++++++++--
+ include/bsd/stringlist.h     | 10 ++++++++--
+ include/bsd/unistd.h         | 10 ++++++++--
+ include/bsd/vis.h            | 10 ++++++++--
+ include/bsd/wchar.h          | 10 ++++++++--
+ src/hash/sha512.h            | 10 ++++++++--
+ 13 files changed, 104 insertions(+), 26 deletions(-)
+
+diff --git a/include/bsd/err.h b/include/bsd/err.h
+index 12fd051..43dfc32 100644
+--- a/include/bsd/err.h
++++ b/include/bsd/err.h
+@@ -42,7 +42,10 @@
+ 
+ #include <stdarg.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ void warnc(int code, const char *format, ...)
+ 	__printflike(2, 3);
+ void vwarnc(int code, const char *format, va_list ap)
+@@ -51,6 +54,9 @@ void errc(int status, int code, const char *format, ...)
+ 	__printflike(3, 4);
+ void verrc(int status, int code, const char *format, va_list ap)
+ 	__printflike(3, 0);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif
+diff --git a/include/bsd/libutil.h b/include/bsd/libutil.h
+index ebb6160..28b919d 100644
+--- a/include/bsd/libutil.h
++++ b/include/bsd/libutil.h
+@@ -53,7 +53,10 @@ struct pidfh {
+ 	ino_t	pf_ino;
+ };
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ int humanize_number(char *buf, size_t len, int64_t bytes,
+     const char *suffix, int scale, int flags);
+ int expand_number(const char *_buf, uint64_t *_num);
+@@ -66,7 +69,10 @@ int pidfile_close(struct pidfh *pfh);
+ int pidfile_remove(struct pidfh *pfh);
+ 
+ char   *fparseln(FILE *, size_t *, size_t *, const char[3], int);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ /* humanize_number(3) */
+ #define HN_DECIMAL              0x01
+diff --git a/include/bsd/md5.h b/include/bsd/md5.h
+index 9a75fad..3531fd6 100644
+--- a/include/bsd/md5.h
++++ b/include/bsd/md5.h
+@@ -30,7 +30,10 @@ typedef struct MD5Context {
+ #include <sys/cdefs.h>
+ #include <sys/types.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ void	 MD5Init(MD5_CTX *);
+ void	 MD5Update(MD5_CTX *, const uint8_t *, size_t)
+ 		__attribute__((__bounded__(__string__,2,3)));
+@@ -49,6 +52,9 @@ char	*MD5FileChunk(const char *, char *, off_t, off_t)
+ char	*MD5Data(const uint8_t *, size_t, char *)
+ 		__attribute__((__bounded__(__string__,1,2)))
+ 		__attribute__((__bounded__(__minbytes__,3,MD5_DIGEST_STRING_LENGTH)));
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif /* _MD5_H_ */
+diff --git a/include/bsd/nlist.h b/include/bsd/nlist.h
+index 2730237..0389ab7 100644
+--- a/include/bsd/nlist.h
++++ b/include/bsd/nlist.h
+@@ -30,8 +30,14 @@
+ #include <sys/cdefs.h>
+ #include <a.out.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ extern int nlist(const char *filename, struct nlist *list);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif
+diff --git a/include/bsd/readpassphrase.h b/include/bsd/readpassphrase.h
+index e1dacc3..76e0d33 100644
+--- a/include/bsd/readpassphrase.h
++++ b/include/bsd/readpassphrase.h
+@@ -34,8 +34,14 @@
+ #include <sys/cdefs.h>
+ #include <sys/types.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ char * readpassphrase(const char *, char *, size_t, int);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif /* !_READPASSPHRASE_H_ */
+diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h
+index 7697425..b5b3efd 100644
+--- a/include/bsd/stdio.h
++++ b/include/bsd/stdio.h
+@@ -41,7 +41,10 @@
+ #include <sys/cdefs.h>
+ #include <sys/types.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ const char *fmtcheck(const char *, const char *);
+ 
+ /* XXX: The function requires cooperation from the system libc to store the
+@@ -69,7 +72,10 @@ FILE *funopen(const void *cookie,
+ #define fwopen(cookie, fn) funopen(cookie, NULL, fn, NULL, NULL)
+ 
+ int fpurge(FILE *fp);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif
+ #endif
+diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
+index 0604cad..b9f0515 100644
+--- a/include/bsd/stdlib.h
++++ b/include/bsd/stdlib.h
+@@ -46,7 +46,10 @@
+ #include <sys/stat.h>
+ #include <stdint.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ uint32_t arc4random(void);
+ void arc4random_stir(void);
+ void arc4random_addrandom(u_char *dat, int datlen);
+@@ -73,6 +76,9 @@ long long strtonum(const char *nptr, long long minval, long long maxval,
+                    const char **errstr);
+ 
+ char *getbsize(int *headerlenp, long *blocksizep);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif
+diff --git a/include/bsd/string.h b/include/bsd/string.h
+index ee2f953..fbf8c54 100644
+--- a/include/bsd/string.h
++++ b/include/bsd/string.h
+@@ -36,13 +36,19 @@
+ #include <sys/cdefs.h>
+ #include <sys/types.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ size_t strlcpy(char *dst, const char *src, size_t siz);
+ size_t strlcat(char *dst, const char *src, size_t siz);
+ char *strnstr(const char *str, const char *find, size_t str_len);
+ void strmode(mode_t mode, char *str);
+ 
+ void explicit_bzero(void *buf, size_t len);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif
+diff --git a/include/bsd/stringlist.h b/include/bsd/stringlist.h
+index e3c42e9..40d0a52 100644
+--- a/include/bsd/stringlist.h
++++ b/include/bsd/stringlist.h
+@@ -43,12 +43,18 @@ typedef struct _stringlist {
+ 	size_t	  sl_cur;
+ } StringList;
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ StringList	*sl_init(void);
+ int		 sl_add(StringList *, char *);
+ void		 sl_free(StringList *, int);
+ char		*sl_find(StringList *, const char *);
+ int		 sl_delete(StringList *, const char *, int);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif /* _STRINGLIST_H */
+diff --git a/include/bsd/unistd.h b/include/bsd/unistd.h
+index 1f9c5f8..5b2f4c7 100644
+--- a/include/bsd/unistd.h
++++ b/include/bsd/unistd.h
+@@ -45,7 +45,10 @@
+ #define S_ISTXT S_ISVTX
+ #endif
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ extern int optreset;
+ 
+ #ifdef LIBBSD_OVERLAY
+@@ -68,6 +71,9 @@ void setproctitle(const char *fmt, ...)
+ 	__printflike(1, 2);
+ 
+ int getpeereid(int s, uid_t *euid, gid_t *egid);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif
+diff --git a/include/bsd/vis.h b/include/bsd/vis.h
+index 835d2d6..63c951e 100644
+--- a/include/bsd/vis.h
++++ b/include/bsd/vis.h
+@@ -74,7 +74,10 @@
+ 
+ #include <sys/cdefs.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ char	*vis(char *, int, int, int);
+ int	strvis(char *, const char *, int);
+ int	strvisx(char *, const char *, size_t, int);
+@@ -83,6 +86,9 @@ int	strunvis(char *, const char *);
+ int	strunvisx(char *, const char *, int);
+ ssize_t strnunvis(char *, const char *, size_t);
+ int	unvis(char *, int, int *, int);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif /* !_VIS_H_ */
+diff --git a/include/bsd/wchar.h b/include/bsd/wchar.h
+index 33a500e..aa70742 100644
+--- a/include/bsd/wchar.h
++++ b/include/bsd/wchar.h
+@@ -43,12 +43,18 @@
+ #include <sys/cdefs.h>
+ #include <sys/types.h>
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ wchar_t *fgetwln(FILE *stream, size_t *len);
+ 
+ size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
+ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif
+ #endif
+diff --git a/src/hash/sha512.h b/src/hash/sha512.h
+index 4f368a1..27ddc24 100644
+--- a/src/hash/sha512.h
++++ b/src/hash/sha512.h
+@@ -39,7 +39,10 @@ typedef struct SHA512Context {
+ 	unsigned char buf[128];
+ } SHA512_CTX;
+ 
+-__BEGIN_DECLS
++/* __BEGIN_DECLS */
++#ifdef __cplusplus
++extern "C" {
++#endif
+ 
+ void	SHA512_Init(SHA512_CTX *);
+ void	SHA512_Update(SHA512_CTX *, const void *, size_t);
+@@ -48,6 +51,9 @@ char   *SHA512_End(SHA512_CTX *, char *);
+ char   *SHA512_File(const char *, char *);
+ char   *SHA512_FileChunk(const char *, char *, off_t, off_t);
+ char   *SHA512_Data(const void *, unsigned int, char *);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
++/* __END_DECLS */
+ 
+ #endif /* !_SHA512_H_ */
+-- 
+2.10.2
+
diff --git a/main/libbsd/0002-Remove-funopen.patch b/main/libbsd/0002-Remove-funopen.patch
new file mode 100644
index 00000000..83ce7c8d
--- /dev/null
+++ b/main/libbsd/0002-Remove-funopen.patch
@@ -0,0 +1,55 @@
+From 28fc66e8b848709a2e69dba7f07694248e0154e8 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email-masked]>
+Date: Sun, 6 Nov 2016 09:40:43 -0800
+Subject: [PATCH 2/3] Remove funopen()
+
+Musl doesnt have prerequisites for it.
+
+Signed-off-by: Khem Raj <[email-masked]>
+---
+Upstream-Status: Inappropriate [musl specific]
+
+ man/Makefile.am  | 1 -
+ src/Makefile.am  | 1 -
+ test/Makefile.am | 1 -
+ 3 files changed, 3 deletions(-)
+
+diff --git a/man/Makefile.am b/man/Makefile.am
+index e4d6e4a..c701d94 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -29,7 +29,6 @@ dist_man_MANS = \
+ 	flopen.3 \
+ 	fmtcheck.3 \
+ 	fparseln.3 \
+-	funopen.3bsd \
+ 	getbsize.3 \
+ 	getmode.3 \
+ 	getpeereid.3 \
+diff --git a/src/Makefile.am b/src/Makefile.am
+index ad83dbf..13225a3 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -76,7 +76,6 @@ libbsd_la_SOURCES = \
+ 	fmtcheck.c \
+ 	fparseln.c \
+ 	fpurge.c \
+-	funopen.c \
+ 	getbsize.c \
+ 	getpeereid.c \
+ 	hash/md5.c \
+diff --git a/test/Makefile.am b/test/Makefile.am
+index a75c8ff..e3a1d41 100644
+--- a/test/Makefile.am
++++ b/test/Makefile.am
+@@ -36,7 +36,6 @@ check_PROGRAMS = \
+ 	endian \
+ 	humanize \
+ 	fgetln \
+-	funopen \
+ 	fparseln \
+ 	fpurge \
+ 	md5 \
+-- 
+2.10.2
+
diff --git a/main/libbsd/0003-Fix-build-breaks-due-to-missing-a.out.h.patch b/main/libbsd/0003-Fix-build-breaks-due-to-missing-a.out.h.patch
new file mode 100644
index 00000000..176d940f
--- /dev/null
+++ b/main/libbsd/0003-Fix-build-breaks-due-to-missing-a.out.h.patch
@@ -0,0 +1,130 @@
+From a1b93c25311834f2f411e9bfe2e616899ba2122d Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email-masked]>
+Date: Sun, 6 Nov 2016 10:23:55 -0800
+Subject: [PATCH 3/3] Fix build breaks due to missing a.out.h
+
+Signed-off-by: Khem Raj <[email-masked]>
+---
+Upstream-Status: Pending
+
+ include/bsd/nlist.h                     |  1 -
+ include/bsd/nlist.h => src/local-aout.h | 47 ++++++++++++++++++++++-----------
+ src/nlist.c                             |  9 +++++++
+ 3 files changed, 41 insertions(+), 16 deletions(-)
+ copy include/bsd/nlist.h => src/local-aout.h (63%)
+
+diff --git a/include/bsd/nlist.h b/include/bsd/nlist.h
+index 0389ab7..9c7e3d8 100644
+--- a/include/bsd/nlist.h
++++ b/include/bsd/nlist.h
+@@ -28,7 +28,6 @@
+ #define LIBBSD_NLIST_H
+ 
+ #include <sys/cdefs.h>
+-#include <a.out.h>
+ 
+ /* __BEGIN_DECLS */
+ #ifdef __cplusplus
+diff --git a/include/bsd/nlist.h b/src/local-aout.h
+similarity index 63%
+copy from include/bsd/nlist.h
+copy to src/local-aout.h
+index 0389ab7..2adb93e 100644
+--- a/include/bsd/nlist.h
++++ b/src/local-aout.h
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright © 2009 Guillem Jover <[email-masked]>
++ * Copyright © 2016 Khem Raj <[email-masked]>
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+@@ -24,20 +24,37 @@
+  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
+-#ifndef LIBBSD_NLIST_H
+-#define LIBBSD_NLIST_H
++#ifndef LIBBSD_LOCAL_AOUT_H
++#define LIBBSD_LOCAL_AOUT_H
+ 
+-#include <sys/cdefs.h>
+-#include <a.out.h>
++#define N_UNDF  0
++#define N_ABS   2
++#define N_TEXT  4
++#define N_DATA  6
++#define N_BSS   8
++#define N_FN    15
++#define N_EXT   1
++#define N_TYPE  036
++#define N_STAB  0340
++#define N_INDR  0xa
++#define N_SETA  0x14    /* Absolute set element symbol.  */
++#define N_SETT  0x16    /* Text set element symbol.  */
++#define N_SETD  0x18    /* Data set element symbol.  */
++#define N_SETB  0x1A    /* Bss set element symbol.  */
++#define N_SETV  0x1C    /* Pointer to set vector in data area.  */
+ 
+-/* __BEGIN_DECLS */
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-extern int nlist(const char *filename, struct nlist *list);
+-#ifdef __cplusplus
+-}
+-#endif
+-/* __END_DECLS */
++struct nlist
++{
++  union
++    {
++      char *n_name;
++      struct nlist *n_next;
++      long n_strx;
++    } n_un;
++  unsigned char n_type;
++  char n_other;
++  short n_desc;
++  unsigned long n_value;
++};
+ 
+-#endif
++#endif /* LIBBSD_LOCAL_AOUT_H */
+diff --git a/src/nlist.c b/src/nlist.c
+index 0cffe55..625d310 100644
+--- a/src/nlist.c
++++ b/src/nlist.c
+@@ -40,7 +40,11 @@ static char sccsid[] = "@(#)nlist.c	8.1 (Berkeley) 6/4/93";
+ 
+ #include <errno.h>
+ #include <fcntl.h>
++#ifdef __GLIBC__
+ #include <a.out.h>
++#else
++#define __NO_A_OUT_SUPPORT
++#endif
+ #include <stdio.h>
+ #include <string.h>
+ #include <unistd.h>
+@@ -48,12 +52,17 @@ static char sccsid[] = "@(#)nlist.c	8.1 (Berkeley) 6/4/93";
+ #if !defined(__NO_A_OUT_SUPPORT)
+ #define _NLIST_DO_AOUT
+ #endif
++
+ #define _NLIST_DO_ELF
+ 
+ #ifdef _NLIST_DO_ELF
+ #include "local-elf.h"
+ #endif
+ 
++#ifdef _NLIST_DO_ELF
++#include "local-aout.h"
++#endif
++
+ #define SIZE_T_MAX 0xffffffffU
+ 
+ #ifdef _NLIST_DO_AOUT
+-- 
+2.10.2
+
diff --git a/main/libbsd/APKBUILD b/main/libbsd/APKBUILD
index bf95701c..7dc608ae 100644
--- a/main/libbsd/APKBUILD
+++ b/main/libbsd/APKBUILD
@@ -3,7 +3,7 @@
 # Maintainer: William Pitcock <[email-masked]>
 pkgname=libbsd
 pkgver=0.8.3
-pkgrel=1
+pkgrel=2
 pkgdesc="commonly-used BSD functions not implemented by all libcs"
 url="http://libbsd.freedesktop.org/"
 arch="all !armhf !aarch64 !ppc64le"
@@ -13,7 +13,10 @@ depends_dev="bsd-compat-headers linux-headers"
 makedepends="$depends_dev autoconf automake libtool"
 subpackages="$pkgname-dev $pkgname-doc"
 source="http://libbsd.freedesktop.org/releases/$pkgname-$pkgver.tar.xz
-	musl-fixes.patch"
+	0001-Replace-__BEGIN_DECLS-and-__END_DECLS.patch
+	0002-Remove-funopen.patch
+	0003-Fix-build-breaks-due-to-missing-a.out.h.patch
+	"
 
 builddir="$srcdir/$pkgname-$pkgver"
 prepare() {
@@ -42,9 +45,7 @@ package() {
 		install || return 1
 }
 
-md5sums="e935c1bb6cc98a4a43cb1da22795493a  libbsd-0.8.3.tar.xz
-21a350d9723d667b5ed8a8b610528843  musl-fixes.patch"
-sha256sums="934b634f4dfd865b6482650b8f522c70ae65c463529de8be907b53c89c3a34a8  libbsd-0.8.3.tar.xz
-cc7d2f2dfe2cc5d823e6ea5f7c1efea236f688c7ee53ec925471264e54c72359  musl-fixes.patch"
 sha512sums="155b895d6bd62b180718d65a2cda7484946c492d52735a57b51005705dfe4528b6a72e8745acea47b01fe68e3bbbe3c036c5e9998a8d06fc79efe2b96a04767f  libbsd-0.8.3.tar.xz
-032b8de7abfe6ffec80957db05fcb02b2cec74f26ecc99ef20d2a314efd0dfd88486e31bd33dd7460ac85b48acdab3ba849cd96bdd0884cd5667e7a43ab30c3a  musl-fixes.patch"
+4ef5d664f04af21da17c5ac9eed6fec4c0c7d06ff3af70e93bfdfdf926c7473954649e315158ec8f90cef93f82524431fa4fbc60374d20007f1234d6afe9edcd  0001-Replace-__BEGIN_DECLS-and-__END_DECLS.patch
+aee969d880bc968b2ad6c1a343bc6733c230fdc55c8ded9c4f211be267dcf26f605e3c23d1ce2abc49616fcf6864c51a6c16a67b945180360bd65d4c4d3ddf86  0002-Remove-funopen.patch
+64b68497c9a638d43f90f148d206d59afabec0a62e39522200f72f9ba27529809c6e578ad670681424b2b940ba32a9fab6c526487fd9c6863e0c9a15749bd80a  0003-Fix-build-breaks-due-to-missing-a.out.h.patch"
diff --git a/main/libbsd/musl-fixes.patch b/main/libbsd/musl-fixes.patch
deleted file mode 100644
index d07f18cb..00000000
--- a/main/libbsd/musl-fixes.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libbsd-0.8.3.orig/include/bsd/nlist.h
-+++ libbsd-0.8.3/include/bsd/nlist.h
-@@ -28,7 +28,7 @@
- #define LIBBSD_NLIST_H
- 
- #include <sys/cdefs.h>
--#include <a.out.h>
-+#include <linux/a.out.h>
- 
- __BEGIN_DECLS
- extern int nlist(const char *filename, struct nlist *list);
---- libbsd-0.8.3.orig/src/funopen.c
-+++ libbsd-0.8.3/src/funopen.c
-@@ -138,5 +138,4 @@
- 	return fopencookie(cookiewrap, mode, funcswrap);
- }
- #else
--#error "Function funopen() needs to be ported."
- #endif
---- libbsd-0.8.3.orig/src/nlist.c
-+++ libbsd-0.8.3/src/nlist.c
-@@ -40,7 +40,7 @@
- 
- #include <errno.h>
- #include <fcntl.h>
--#include <a.out.h>
-+#include <linux/a.out.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
-- 
2.12.2

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

---

From: "Tuan M. Hoang" <[email-masked]>
Date: Wed, 19 Apr 2017 01:12:20 -0400

Ref : https://github.com/kamailio/kamailio/pull/1068

---
 main/kamailio/APKBUILD               |  4 +++-
 main/kamailio/s390x-big-endian.patch | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 main/kamailio/s390x-big-endian.patch

diff --git a/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index 698448e6d6..1246486875 100644
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -241,6 +241,7 @@ source="http://www.kamailio.org/pub/kamailio/$pkgver/src/${pkgname}-${pkgver}${_
 	0004-remove-spurious-execinfo.patch
 	kamailio.cfg
 	kamailio.initd
+	s390x-big-endian.patch
 	"
 
 snapshot() {
@@ -520,4 +521,5 @@ sha512sums="686ede6afcf275b739297b322be3ac74396d3230a38a52891b03e088447f5befec07
 139fab275e7d01da85bf3422a16966165c72584122513d34b5fb3d9341c430eeb69ec5b86b82ff4acce709f5ab3f651de5954ae38ff9a256a19b22d88cfea830  0003-kamdbctl.base.patch
 e60e8d41e55008f0473e4d645af3b43f2bc097e341bb3bb81daec8bc47abcd6d037cbb56082675c24ffb1c50b2eb93e3c4fc50b0dc2df9cdfe4f28ad7b9fbf9e  0004-remove-spurious-execinfo.patch
 c1abf69b48847dc8c7ab0d11ef9adb531aa4635f9d44db6933981edc5a47df374664fb24867b19aa64abbcc9777bf1cd0360d9aea54e27b081065928c61e0f0b  kamailio.cfg
-cd6e3b677d803cd78561ad14d9b2589fd35ad0096f48047fdcb4ddc7d9103871357efba3b350946844cb53dbb081210746421fc420c22ac845b90251168a628e  kamailio.initd"
+cd6e3b677d803cd78561ad14d9b2589fd35ad0096f48047fdcb4ddc7d9103871357efba3b350946844cb53dbb081210746421fc420c22ac845b90251168a628e  kamailio.initd
+54016ee9a9f729bab317807761580cf2ac5d8e5dde747377f4d66337af37733de504658aaef28e9432e642b87b79c4bb03bcbb1b2d9c67acd515a37080013d0f  s390x-big-endian.patch"
diff --git a/main/kamailio/s390x-big-endian.patch b/main/kamailio/s390x-big-endian.patch
new file mode 100644
index 0000000000..d7d9defba3
--- /dev/null
+++ b/main/kamailio/s390x-big-endian.patch
@@ -0,0 +1,24 @@
+diff --git a/src/modules/acc/diam_message.h b/src/modules/acc/diam_message.h
+index 35ad2d9..e4faaf0 100644
+--- a/src/modules/acc/diam_message.h
++++ b/src/modules/acc/diam_message.h
+@@ -74,7 +74,6 @@
+ 	#define ST_MSG_CODE      0x13010000
+ 	#define MASK_MSG_CODE    0xffffff00
+ #else
+-	#error BIG endian detected!!
+ 	#define AS_MSG_CODE      0x00000112
+ 	#define AC_MSG_CODE      0x0000010f
+ 	#define CE_MSG_CODE      0x00000101
+diff --git a/src/modules/cdp/diameter.h b/src/modules/cdp/diameter.h
+index 38115a9..2be2525 100644
+--- a/src/modules/cdp/diameter.h
++++ b/src/modules/cdp/diameter.h
+@@ -115,7 +115,6 @@
+ 	#define ST_MSG_CODE      0x13010000
+ 	#define MASK_MSG_CODE    0xffffff00
+ #else
+-	#error BIG endian detected!!
+ 	#define AS_MSG_CODE      0x00000112
+ 	#define AC_MSG_CODE      0x0000010f
+ 	#define CE_MSG_CODE      0x00000101
-- 
2.12.2

---

---

From: "Tuan M. Hoang" <[email-masked]>
Date: Wed, 19 Apr 2017 01:12:28 -0400

Ref
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=6f64bfa654fb7e20bb75ec3b0544b81482babb44

---
 community/qt5-qtbase/APKBUILD               |  4 +-
 community/qt5-qtbase/s390x-big-endian.patch | 94 +++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 community/qt5-qtbase/s390x-big-endian.patch

diff --git a/community/qt5-qtbase/APKBUILD b/community/qt5-qtbase/APKBUILD
index 36a8f41573..df1606529f 100644
--- a/community/qt5-qtbase/APKBUILD
+++ b/community/qt5-qtbase/APKBUILD
@@ -57,6 +57,7 @@ source="http://download.qt-project.org/$_rel/qt/${pkgver%.*}/$_ver/submodules/qt
 	qt-musl-iconv-no-bom.patch
 	libressl-compat.patch
 	hack-openssl_test.patch
+	s390x-big-endian.patch
 	"
 
 _qt5_prefix=/usr/lib/qt5
@@ -212,4 +213,5 @@ x11() {
 sha512sums="36a1ba4b0dba02ae65c3b2b0aa3fb3767cbee4dbdf204c9ded7d1700e70144ce85a3a66167f86cc716a1fdd38d832962b2a752e803b0647d03032b2685da5ced  qtbase-opensource-src-5.8.0.tar.xz
 7d68421a14f0259535c977d8a521c98918193c107b76ac664571b12f5b0d7588a0d0e1297af412a26753a393b21f3f44c3274fa8ab5bc87f03705a3a03acb444  qt-musl-iconv-no-bom.patch
 af284ebb51e3d903275f0f43901755fee0d0071a2fa4f5d6e8a4b00d9185d9d9fffba8e5cbda8c4aa2b3acde69fd26a449b23ad104f509fd4156f6908e0b43da  libressl-compat.patch
-3bc1380268f077587114cfa535c58403f59c4c931902d0599633e1365f075d2e253b6f461e22ed3fe3adb12ef45ea97e1dbcbc1bbe0d151435703986f25c44c6  hack-openssl_test.patch"
+3bc1380268f077587114cfa535c58403f59c4c931902d0599633e1365f075d2e253b6f461e22ed3fe3adb12ef45ea97e1dbcbc1bbe0d151435703986f25c44c6  hack-openssl_test.patch
+aef4633243e53dc5c09eafb785d105659ee5f56c6cc9faf927b8207cda774e31df262e2c63dc05496977cd081a9dd9c7545fbcd5b5ed351aab33e4666957909c  s390x-big-endian.patch"
diff --git a/community/qt5-qtbase/s390x-big-endian.patch b/community/qt5-qtbase/s390x-big-endian.patch
new file mode 100644
index 0000000000..384244d44c
--- /dev/null
+++ b/community/qt5-qtbase/s390x-big-endian.patch
@@ -0,0 +1,94 @@
+From 6f64bfa654fb7e20bb75ec3b0544b81482babb44 Mon Sep 17 00:00:00 2001
+From: Shawn Rutledge <[email-masked]>
+Date: Fri, 10 Feb 2017 13:56:58 +0100
+Subject: fix VNC platform plugin build on big-endian machines
+
+Task-number: QTBUG-58734
+Change-Id: I3e44ee4be5003acaba2f1b8ed2658a3ff1bd700e
+Reviewed-by: Lars Knoll <[email-masked]>
+Reviewed-by: Dmitry Shachnev <[email-masked]>
+---
+ src/plugins/platforms/vnc/qvncclient.cpp | 6 +++---
+ src/plugins/platforms/vnc/qvncscreen.cpp | 7 ++++++-
+ src/plugins/platforms/vnc/qvncscreen.h   | 2 +-
+ 3 files changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp
+index dae3e83..58dcfc9 100644
+--- a/src/plugins/platforms/vnc/qvncclient.cpp
++++ b/src/plugins/platforms/vnc/qvncclient.cpp
+@@ -142,7 +142,7 @@ void QVncClient::convertPixels(char *dst, const char *src, int count) const
+         case 16: {
+             quint16 p = *reinterpret_cast<const quint16*>(src);
+ #if Q_BYTE_ORDER == Q_BIG_ENDIAN
+-            if (swapBytes)
++            if (m_swapBytes)
+                 p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8);
+ #endif
+             r = (p >> 11) & 0x1f;
+@@ -484,7 +484,7 @@ void QVncClient::setPixelFormat()
+         m_sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!m_pixelFormat.bigEndian;
+         m_needConversion = pixelConversionNeeded();
+ #if Q_BYTE_ORDER == Q_BIG_ENDIAN
+-        m_swapBytes = qvnc_screen->swapBytes();
++        m_swapBytes = server()->screen()->swapBytes();
+ #endif
+     }
+ }
+@@ -639,7 +639,7 @@ bool QVncClient::pixelConversionNeeded() const
+         return true;
+ 
+ #if Q_BYTE_ORDER == Q_BIG_ENDIAN
+-    if (qvnc_screen->swapBytes())
++    if (server()->screen()->swapBytes())
+         return true;
+ #endif
+ 
+diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp
+index 34def45..64f1bc0 100644
+--- a/src/plugins/platforms/vnc/qvncscreen.cpp
++++ b/src/plugins/platforms/vnc/qvncscreen.cpp
+@@ -43,6 +43,7 @@
+ #include <QtFbSupport/private/qfbcursor_p.h>
+ 
+ #include <QtGui/QPainter>
++#include <QtGui/QScreen>
+ #include <QtCore/QRegularExpression>
+ 
+ 
+@@ -172,14 +173,18 @@ QPixmap QVncScreen::grabWindow(WId wid, int x, int y, int width, int height) con
+ }
+ 
+ #if Q_BYTE_ORDER == Q_BIG_ENDIAN
+-bool QVNCScreen::swapBytes() const
++bool QVncScreen::swapBytes() const
+ {
++    return false;
++
++    /* TODO
+     if (depth() != 16)
+         return false;
+ 
+     if (screen())
+         return screen()->frameBufferLittleEndian();
+     return frameBufferLittleEndian();
++    */
+ }
+ #endif
+ 
+diff --git a/src/plugins/platforms/vnc/qvncscreen.h b/src/plugins/platforms/vnc/qvncscreen.h
+index 785abd6..0b42c3c 100644
+--- a/src/plugins/platforms/vnc/qvncscreen.h
++++ b/src/plugins/platforms/vnc/qvncscreen.h
+@@ -73,7 +73,7 @@ public:
+     void clearDirty() { dirtyRegion = QRegion(); }
+ 
+ #if Q_BYTE_ORDER == Q_BIG_ENDIAN
+-    bool swapBytes() const
++    bool swapBytes() const;
+ #endif
+ 
+     QStringList mArgs;
+-- 
+cgit v1.0-4-g1e03
+
-- 
2.12.2

---

---

From: Natanael Copa <[email-masked]>
Date: Tue, 25 Apr 2017 21:08:17 +0200

On Wed, 19 Apr 2017 01:11:44 -0400

> https://patchwork.openembedded.org/patch/133637/

I ended up using this as it fixes the issue for all arches. I rebased
it and enabled all arches.

Thanks!

---