From 3d9f05ffc6bdca9429fa6ce70da0438553ef9b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Buchm=C3=BCller?= Date: Sun, 30 Aug 2015 11:31:10 +0200 Subject: [PATCH] snapper: unbreak musl --- srcpkgs/snapper/patches/fix-poll_h.patch | 13 +++++ srcpkgs/snapper/patches/musl-__isleap.patch | 19 +++++++ .../patches/musl-_nl_msg_cat_cntr.patch | 51 +++++++++++++++++++ srcpkgs/snapper/patches/musl-mktime.patch | 15 ++++++ srcpkgs/snapper/patches/musl-mode_t.patch | 12 +++++ .../snapper/patches/musl-stdout_stderr.patch | 15 ++++++ srcpkgs/snapper/patches/musl-strerror_r.patch | 14 +++++ srcpkgs/snapper/patches/musl-unistd.h | 12 +++++ srcpkgs/snapper/template | 8 ++- 9 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/snapper/patches/fix-poll_h.patch create mode 100644 srcpkgs/snapper/patches/musl-__isleap.patch create mode 100644 srcpkgs/snapper/patches/musl-_nl_msg_cat_cntr.patch create mode 100644 srcpkgs/snapper/patches/musl-mktime.patch create mode 100644 srcpkgs/snapper/patches/musl-mode_t.patch create mode 100644 srcpkgs/snapper/patches/musl-stdout_stderr.patch create mode 100644 srcpkgs/snapper/patches/musl-strerror_r.patch create mode 100644 srcpkgs/snapper/patches/musl-unistd.h diff --git a/srcpkgs/snapper/patches/fix-poll_h.patch b/srcpkgs/snapper/patches/fix-poll_h.patch new file mode 100644 index 0000000000..656d974d67 --- /dev/null +++ b/srcpkgs/snapper/patches/fix-poll_h.patch @@ -0,0 +1,13 @@ +The correct location is , not + +--- snapper/SystemCmd.h 2014-02-05 14:22:06.000000000 +0100 ++++ snapper/SystemCmd.h 2015-08-30 10:56:03.685179465 +0200 +@@ -23,7 +23,7 @@ + #ifndef SNAPPER_SYSTEM_CMD_H + #define SNAPPER_SYSTEM_CMD_H + +-#include ++#include + #include + + #include diff --git a/srcpkgs/snapper/patches/musl-__isleap.patch b/srcpkgs/snapper/patches/musl-__isleap.patch new file mode 100644 index 0000000000..0e8358edc3 --- /dev/null +++ b/srcpkgs/snapper/patches/musl-__isleap.patch @@ -0,0 +1,19 @@ +The macro __isleap() is defined in glibc's time.h +If it is not defined, define it the same (for musl libc). + +--- client/utils/equal-date.h 2014-12-11 18:21:17.000000000 +0100 ++++ client/utils/equal-date.h 2015-08-30 11:18:08.181207315 +0200 +@@ -19,6 +19,13 @@ + * find current contact information at www.novell.com. + */ + ++#if !defined(__isleap) ++/* Nonzero if YEAR is a leap year (every 4 years, ++ except every 100th isn't, and every 400th is). */ ++# define __isleap(year) \ ++ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) ++#endif ++ + + bool + equal_year(const struct tm& tmp1, const struct tm& tmp2); diff --git a/srcpkgs/snapper/patches/musl-_nl_msg_cat_cntr.patch b/srcpkgs/snapper/patches/musl-_nl_msg_cat_cntr.patch new file mode 100644 index 0000000000..e28bef5c0c --- /dev/null +++ b/srcpkgs/snapper/patches/musl-_nl_msg_cat_cntr.patch @@ -0,0 +1,51 @@ +There is no _nl_msg_cat_cntr in musl libc and optimizations +based upon its unchanged value are not possible. + +--- snapper/Regex.cc 2014-01-29 16:48:30.000000000 +0100 ++++ snapper/Regex.cc 2015-08-30 11:07:34.613193993 +0200 +@@ -22,7 +22,9 @@ + + #include "snapper/Regex.h" + ++#if defined(__GLIBC__) + extern int _nl_msg_cat_cntr; ++#endif + + + namespace snapper +@@ -34,7 +36,9 @@ + nm (cflags & REG_NOSUB ? 0 : nm) + { + regcomp (&rx, pattern, cflags); ++#if defined(__GLIBC__) + my_nl_msg_cat_cntr = _nl_msg_cat_cntr; ++#endif + rm = new regmatch_t[nm]; + } + +@@ -45,7 +49,9 @@ + nm (cflags & REG_NOSUB ? 0 : nm) + { + regcomp (&rx, pattern.c_str (), cflags); ++#if defined(__GLIBC__) + my_nl_msg_cat_cntr = _nl_msg_cat_cntr; ++#endif + rm = new regmatch_t[nm]; + } + +@@ -60,11 +66,15 @@ + bool + Regex::match (const string& str, int eflags) const + { ++#if defined(__GLIBC__) + if (my_nl_msg_cat_cntr != _nl_msg_cat_cntr) { ++#endif + regfree (&rx); + regcomp (&rx, pattern.c_str (), cflags); ++#if defined(__GLIBC__) + my_nl_msg_cat_cntr = _nl_msg_cat_cntr; + } ++#endif + + last_str = str; + diff --git a/srcpkgs/snapper/patches/musl-mktime.patch b/srcpkgs/snapper/patches/musl-mktime.patch new file mode 100644 index 0000000000..b680b435b5 --- /dev/null +++ b/srcpkgs/snapper/patches/musl-mktime.patch @@ -0,0 +1,15 @@ +According to http://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_21.html +timelocal(2) is functionally identical to mktime(2), but more +mnemonically named. There is no timelocal(2) defined in musl libc. + +--- snapper/AppUtil.cc 2015-02-18 18:54:03.000000000 +0100 ++++ snapper/AppUtil.cc 2015-08-30 10:39:31.318158599 +0200 +@@ -274,7 +274,7 @@ + const char* p = strptime(str.c_str(), "%F %T", &s); + if (!p || *p != '\0') + return (time_t)(-1); +- return utc ? timegm(&s) : timelocal(&s); ++ return utc ? timegm(&s) : mktime(&s); + } + + diff --git a/srcpkgs/snapper/patches/musl-mode_t.patch b/srcpkgs/snapper/patches/musl-mode_t.patch new file mode 100644 index 0000000000..85a321a3c2 --- /dev/null +++ b/srcpkgs/snapper/patches/musl-mode_t.patch @@ -0,0 +1,12 @@ +The mode_t type is defined in fcntl.h + +--- snapper/FileUtils.h 2015-02-18 18:54:03.000000000 +0100 ++++ snapper/FileUtils.h 2015-08-30 10:45:43.285166420 +0200 +@@ -24,6 +24,7 @@ + #define SNAPPER_FILE_UTILS_H + + ++#include + #include + #include + #include diff --git a/srcpkgs/snapper/patches/musl-stdout_stderr.patch b/srcpkgs/snapper/patches/musl-stdout_stderr.patch new file mode 100644 index 0000000000..2a3eb2bb87 --- /dev/null +++ b/srcpkgs/snapper/patches/musl-stdout_stderr.patch @@ -0,0 +1,15 @@ +In musl libc stdout and stderr are macros, thus we need to +undefine them to be able to use SystemCmd::stdout() and ::stderr() +members without renaming them - which may be a better choice. + +--- snapper/SystemCmd.h 2015-08-30 10:59:53.740184303 +0200 ++++ snapper/SystemCmd.h 2015-08-30 11:02:34.229187677 +0200 +@@ -31,6 +31,8 @@ + #include + #include + ++#undef stdout ++#undef stderr + + namespace snapper + { diff --git a/srcpkgs/snapper/patches/musl-strerror_r.patch b/srcpkgs/snapper/patches/musl-strerror_r.patch new file mode 100644 index 0000000000..633bb1bb24 --- /dev/null +++ b/srcpkgs/snapper/patches/musl-strerror_r.patch @@ -0,0 +1,14 @@ +In musl libc the return type of strerror_r(2) is int (XSI-compliant). +We define MUSL_LIBC in CXXFLAGS to skip the wrong #else implementation. + +--- snapper/AppUtil.cc 2015-08-30 15:34:51.106531190 +0200 ++++ snapper/AppUtil.cc 2015-08-30 15:35:41.996532260 +0200 +@@ -209,7 +209,7 @@ + string + stringerror(int errnum) + { +-#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE ++#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) || MUSL_LIBC + char buf1[100]; + if (strerror_r(errno, buf1, sizeof(buf1)-1) == 0) + return string(buf1); diff --git a/srcpkgs/snapper/patches/musl-unistd.h b/srcpkgs/snapper/patches/musl-unistd.h new file mode 100644 index 0000000000..f8db190b9e --- /dev/null +++ b/srcpkgs/snapper/patches/musl-unistd.h @@ -0,0 +1,12 @@ +Need to include unistd.h to define uid_t for musl libc. + +--- snapper/Snapshot.h 2015-02-18 18:54:03.000000000 +0100 ++++ snapper/Snapshot.h 2015-08-30 10:33:14.197150669 +0200 +@@ -25,6 +25,7 @@ + + + #include ++#include + #include + #include + #include diff --git a/srcpkgs/snapper/template b/srcpkgs/snapper/template index afff9a142f..d853f0a5dc 100644 --- a/srcpkgs/snapper/template +++ b/srcpkgs/snapper/template @@ -1,7 +1,7 @@ # Template file for 'snapper' pkgname=snapper version=0.2.8 -revision=1 +revision=2 lib32disabled=yes build_style=gnu-configure configure_args="--disable-zypp --with-conf=/etc/conf.d --sbindir=/usr/bin" @@ -16,6 +16,12 @@ homepage="http://snapper.io" distfiles="ftp://ftp.suse.com/pub/projects/$pkgname/$pkgname-$version.tar.bz2" checksum=a44608648ed21a1346f8ae9345044901c39ad01abb501806a22c9d4a771eadc5 +case "$XBPS_TARGET_MACHINE" in + *-musl) # We define MUSL_LIBC to pick the correct return type + # for strerror_r(2) which is int (XSI-compliant) + CXXFLAGS="-DMUSL_LIBC=1" +esac + pre_configure() { # rename cron scripts sed -i -e 's@suse.de-@@g' scripts/Makefile.am