Browse Source

initial package creation

Signed-off-by: Toshaan Bharvani <toshaan@powerel.org>
master
Toshaan Bharvani 3 years ago
commit
ee3c09e995
  1. 28
      SOURCES/libbsd-0.8.3-deprecated.patch
  2. 18
      SOURCES/libbsd-0.8.6-compat.patch
  3. 167
      SOURCES/libbsd-symver.patch
  4. 220
      SPECS/libbsd.spec

28
SOURCES/libbsd-0.8.3-deprecated.patch

@ -0,0 +1,28 @@
diff -up libbsd-0.8.3/include/bsd/stdio.h~ libbsd-0.8.3/include/bsd/stdio.h
--- libbsd-0.8.3/include/bsd/stdio.h~ 2015-09-22 23:59:34.000000000 -0600
+++ libbsd-0.8.3/include/bsd/stdio.h 2016-12-23 00:47:24.464930157 -0700
@@ -41,15 +41,21 @@
#include <sys/cdefs.h>
#include <sys/types.h>
+#if (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 5))
+#define DEPRECATED(x) __attribute__((deprecated))
+#else
+#define DEPRECATED(x) __attribute__((deprecated(x)))
+#endif
+
__BEGIN_DECLS
const char *fmtcheck(const char *, const char *);
/* XXX: The function requires cooperation from the system libc to store the
* line buffer in the FILE struct itself. */
char *fgetln(FILE *fp, size_t *lenp)
- __attribute__((deprecated("This functions cannot be safely ported, "
- "use getline(3) instead, as it is supported "
- "by GNU and POSIX.1-2008.")));
+ DEPRECATED("This functions cannot be safely ported, "
+ "use getline(3) instead, as it is supported "
+ "by GNU and POSIX.1-2008.");
/*
* Note: We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations,

18
SOURCES/libbsd-0.8.6-compat.patch

@ -0,0 +1,18 @@
diff -up libbsd-0.8.6/src/explicit_bzero.c.compat libbsd-0.8.6/src/explicit_bzero.c
--- libbsd-0.8.6/src/explicit_bzero.c.compat 2018-05-22 16:06:09.926108522 -0600
+++ libbsd-0.8.6/src/explicit_bzero.c 2018-05-22 16:06:43.102873673 -0600
@@ -17,3 +17,5 @@ explicit_bzero(void *buf, size_t len)
memset(buf, 0, len);
__explicit_bzero_hook(buf, len);
}
+
+asm(".symver explicit_bzero,explicit_bzero@LIBBSD_0.8");
diff -up libbsd-0.8.6/src/reallocarray.c.compat libbsd-0.8.6/src/reallocarray.c
--- libbsd-0.8.6/src/reallocarray.c.compat 2018-05-22 16:07:32.247007073 -0600
+++ libbsd-0.8.6/src/reallocarray.c 2018-05-22 16:08:10.687893640 -0600
@@ -36,3 +36,5 @@ reallocarray(void *optr, size_t nmemb, s
}
return realloc(optr, size * nmemb);
}
+
+asm(".symver reallocarray,reallocarray@LIBBSD_0.8");

167
SOURCES/libbsd-symver.patch

@ -0,0 +1,167 @@
diff --git a/configure.ac b/configure.ac
index 6e9496d..abf891e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,7 +96,7 @@ AC_CACHE_CHECK(
[[
static int rc = 1;
static void init(int argc) { if (argc == 1) rc = 0; }
-void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
+__attribute__ ((used)) void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
int main() { return rc; }
]]
)],
@@ -183,4 +183,13 @@ AC_CONFIG_FILES([
test/Makefile
])
AC_CONFIG_HEADERS([config.h])
+
+# GCC tries to be "helpful" and only issue a warning for unrecognized
+# attributes. So we compile the test with Werror, so that if the
+# attribute is not recognized the compilation fails
+AC_LANG(C)
+AC_LANG_WERROR
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[__attribute__ ((symver ("foo@foo_1"))) void frob (void) { }]])],
+ [AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], [1], [Checking for symver attribute])], [])
+
AC_OUTPUT
diff --git a/src/local-link.h b/src/local-link.h
index 0d4351a..5f98656 100644
--- a/src/local-link.h
+++ b/src/local-link.h
@@ -32,16 +32,22 @@
__attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg;
#ifdef __ELF__
-#define libbsd_symver_default(alias, symbol, version) \
- __asm__(".symver " #symbol "," #alias "@@" #version)
-
-#define libbsd_symver_variant(alias, symbol, version) \
- __asm__(".symver " #symbol "," #alias "@" #version)
+# if HAVE_ATTRIBUTE_SYMVER
+# define libbsd_symver_default(alias, symbol, version) \
+ __attribute__ ((symver (#alias "@@" #version)))
+# define libbsd_symver_variant(alias, symbol, version) \
+ __attribute__ ((symver (#alias "@" #version)))
+# else
+# define libbsd_symver_default(alias, symbol, version) \
+ __asm__(".symver " #symbol "," #alias "@@" #version);
+# define libbsd_symver_variant(alias, symbol, version) \
+ __asm__(".symver " #symbol "," #alias "@" #version);
+# endif
#else
-#define libbsd_symver_default(alias, symbol, version) \
+# define libbsd_symver_default(alias, symbol, version) \
extern __typeof(symbol) alias __attribute__((__alias__(#symbol)))
-#define libbsd_symver_variant(alias, symbol, version)
+# define libbsd_symver_variant(alias, symbol, version)
#endif
#endif
diff --git a/src/setproctitle.c b/src/setproctitle.c
index ff32aa3..f8ede26 100644
--- a/src/setproctitle.c
+++ b/src/setproctitle.c
@@ -222,6 +222,7 @@ setproctitle_init(int argc, char *argv[], char *envp[])
#define SPT_MAXTITLE 255
#endif
+libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5)
void
setproctitle_impl(const char *fmt, ...)
{
@@ -281,7 +282,6 @@ setproctitle_impl(const char *fmt, ...)
*++nul = '\0';
}
}
-libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5);
/* The original function introduced in 0.2 was a stub, it only got implemented
* in 0.5, make the implementation available in the old version as an alias
@@ -289,11 +289,12 @@ libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5);
* new version, so that new code depends on the implemented version. */
#ifdef HAVE_TYPEOF
extern __typeof__(setproctitle_impl)
+libbsd_symver_variant(setproctitle, setproctitle_stub, LIBBSD_0.2)
setproctitle_stub
__attribute__((__alias__("setproctitle_impl")));
#else
void
+libbsd_symver_variant(setproctitle, setproctitle_stub, LIBBSD_0.2)
setproctitle_stub(const char *fmt, ...)
__attribute__((__alias__("setproctitle_impl")));
#endif
-libbsd_symver_variant(setproctitle, setproctitle_stub, LIBBSD_0.2);
diff --git a/src/unvis.c b/src/unvis.c
index 166421a..218ec47 100644
--- a/src/unvis.c
+++ b/src/unvis.c
@@ -563,16 +563,16 @@ strunvis(char *dst, const char *src)
* OpenBSD, 2001: strnunvis(char *dst, const char *src, size_t dlen);
* NetBSD: 2012, strnunvis(char *dst, size_t dlen, const char *src);
*/
+libbsd_symver_default(strnunvis, strnunvis_openbsd, LIBBSD_0.2)
ssize_t
strnunvis_openbsd(char *dst, const char *src, size_t dlen)
{
return strnunvisx(dst, dlen, src, 0);
}
-libbsd_symver_default(strnunvis, strnunvis_openbsd, LIBBSD_0.2);
+libbsd_symver_variant(strnunvis, strnunvis_netbsd, LIBBSD_0.9.1)
int
strnunvis_netbsd(char *dst, size_t dlen, const char *src)
{
return strnunvisx(dst, dlen, src, 0);
}
-libbsd_symver_variant(strnunvis, strnunvis_netbsd, LIBBSD_0.9.1);
diff --git a/src/vis.c b/src/vis.c
index c8e5ae8..254f209 100644
--- a/src/vis.c
+++ b/src/vis.c
@@ -732,19 +732,19 @@ strvis(char *mbdst, const char *mbsrc, int flags)
* OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
* NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
*/
+libbsd_symver_default(strnvis, strnvis_openbsd, LIBBSD_0.2)
int
strnvis_openbsd(char *mbdst, const char *mbsrc, size_t dlen, int flags)
{
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
}
-libbsd_symver_default(strnvis, strnvis_openbsd, LIBBSD_0.2);
+libbsd_symver_variant(strnvis, strnvis_netbsd, LIBBSD_0.9.1)
int
strnvis_netbsd(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
}
-libbsd_symver_variant(strnvis, strnvis_netbsd, LIBBSD_0.9.1);
int
stravis(char **mbdstp, const char *mbsrc, int flags)
diff --git a/test/nlist.c b/test/nlist.c
index 82e24e9..0bfdb46 100644
--- a/test/nlist.c
+++ b/test/nlist.c
@@ -38,14 +38,15 @@ extern int data_pub_init;
extern int data_pub_uninit[2048];
extern int *data_pub_ptr;
-int *data_pub_ptr = &data_prv_init;
-int data_pub_init = 10;
-int data_pub_uninit[2048];
+__attribute__ ((used)) int *data_pub_ptr = &data_prv_init;
+__attribute__ ((used)) int data_pub_init = 10;
+__attribute__ ((used)) int data_pub_uninit[2048];
extern int
func_pub(void);
int
+__attribute__ ((used))
func_pub(void)
{
return 42;

220
SPECS/libbsd.spec

@ -0,0 +1,220 @@
Name: libbsd
Version: 0.10.0
Release: 8%{?dist}
Summary: Library providing BSD-compatible functions for portability
URL: http://libbsd.freedesktop.org/
License: BSD and ISC and Copyright only and Public Domain

Source0: http://libbsd.freedesktop.org/releases/libbsd-%{version}.tar.xz
Patch1: %{name}-0.8.3-deprecated.patch
Patch2: %{name}-0.8.6-compat.patch
Patch3: %{name}-symver.patch

BuildRequires: gcc
BuildRequires: autoconf automake libtool
BuildRequires: make

%description
libbsd provides useful functions commonly found on BSD systems, and
lacking on others like GNU systems, thus making it easier to port
projects with strong BSD origins, without needing to embed the same
code over and over again on each project.

%package devel
Summary: Development files for libbsd
Requires: %{name}%{?_isa} = %{version}-%{release}

%description devel
Development files for the libbsd library.

%package ctor-static
Summary: Development files for libbsd
Requires: %{name}%{?_isa} = %{version}-%{release}

%description ctor-static
The libbsd-ctor static library is required if setproctitle() is to be used
when libbsd is loaded via dlopen() from a threaded program. This can be
configured using "pkg-config --libs libbsd-ctor".
# See the libbsd mailing list message by Guillem Jover on Jul 14 2013:
# http://lists.freedesktop.org/archives/libbsd/2013-July/000091.html

%prep
%setup -q
%if 0%{?rhel} && 0%{?rhel} < 7
%patch1 -p1 -b .deprecated
%patch2 -p1 -b .compat
%endif

%patch3 -p1 -b .symver

%build
autoreconf -fiv
%configure
%make_build V=1

%check
%make_build check V=1

%install
%make_install V=1

# don't want static library or libtool archive
rm %{buildroot}%{_libdir}/%{name}.a
rm %{buildroot}%{_libdir}/%{name}.la

# remove manual pages that conflict with man-pages package
rm %{buildroot}%{_mandir}/man3/explicit_bzero.3bsd


%ldconfig_scriptlets

%files
%license COPYING
%doc README TODO ChangeLog
%{_libdir}/%{name}.so.*

%files devel
%{_mandir}/man3/*.3bsd.*
%{_mandir}/man7/%{name}.7.*
%{_includedir}/bsd
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/pkgconfig/%{name}-overlay.pc

%files ctor-static
%{_libdir}/%{name}-ctor.a
%{_libdir}/pkgconfig/%{name}-ctor.pc

%changelog
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.10.0-8
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Sep 09 2020 Jeff Law <law@redhat.com> - 0.10.0-5
- Use symver attribute for symbol versioning
Fix configure test compromised by LTO
Fix nlist test compromised by LTO
Re-enable LTO

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Wed Jul 1 2020 Jeff Law <law@redhat.com> - 0.10.0-3
- Disable LTO

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Aug 22 2019 Eric Smith <brouhaha@fedoraproject.org> - 0.10.0-1
- Update to 0.10.1. (#1742611)

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue May 22 2018 Eric Smith <brouhaha@fedoraproject.org> - 0.9.1-1
- Update to 0.9.1. (#1538853)

* Tue May 22 2018 Eric Smith <brouhaha@fedoraproject.org> - 0.8.6-3
- Mark explicit_bzero() and reallocarray() as compat symbols. (#1408465)

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Tue Nov 21 2017 Jens Petersen <petersen@redhat.com> - 0.8.6-1
- update to 0.8.6 (#1462722)
- fixes manpage conflict (#1504831)
- condition the gcc deprecation patch on epel < 7
- clean up spec file

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Fri Dec 23 2016 Eric Smith <brouhaha@fedoraproject.org> - 0.8.3-2
- Add patch for GCC deprecated attribute to allow building on GCC < 4.5
(needed for EL5 and EL6).

* Thu Dec 22 2016 Eric Smith <brouhaha@fedoraproject.org> - 0.8.3-1
- Update to latest upstream release.

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Mon Jul 28 2014 Eric Smith <brouhaha@fedoraproject.org> - 0.7.0-1
- Update to latest upstream release.

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Sun Jul 14 2013 Eric Smith <brouhaha@fedoraproject.org> - 0.6.0-1
- Update to latest upstream release. Remove patch 0.
- Added ctor-static subpackage.

* Sun Jul 07 2013 Eric Smith <brouhaha@fedoraproject.org> - 0.5.2-3
- Still having problems with setproctitle(), bug #981799, upstream
freedesktop.org bug #66679. Added patch to noop out setproctitle().

* Tue Jun 11 2013 Eric Smith <brouhaha@fedoraproject.org> - 0.5.2-2
- Added check section.
- Add BuildRoot for EL5.

* Mon Jun 10 2013 Eric Smith <brouhaha@fedoraproject.org> - 0.5.2-1
- Update to latest upstream release. Remove patch 0.

* Thu Jun 06 2013 Eric Smith <brouhaha@fedoraproject.org> - 0.5.1-2
- Add patch to avoid calling clearenv() in setproctitle.c, bug #971513.

* Tue Jun 04 2013 Eric Smith <brouhaha@fedoraproject.org> - 0.5.1-1
- Update to latest upstream release.

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sun Jul 08 2012 Eric Smith <eric@brouhaha.com> - 0.4.2-1
- Update to latest upstream release.
- No longer need to change encoding of flopen(3) man page.

* Sun Jun 03 2012 Eric Smith <eric@brouhaha.com> - 0.4.1-1
- Update to latest upstream release.

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Sat Oct 08 2011 Eric Smith <eric@brouhaha.com> - 0.3.0-1
- Update to latest upstream release.
- Removed Patch0, fixed upstream.
- Removed BuildRoot, clean, defattr.

* Fri Jan 29 2010 Eric Smith <eric@brouhaha.com> - 0.2.0-3
- changes based on review by Sebastian Dziallas

* Fri Jan 29 2010 Eric Smith <eric@brouhaha.com> - 0.2.0-2
- changes based on review comments by Jussi Lehtola and Ralf Corsepious

* Thu Jan 28 2010 Eric Smith <eric@brouhaha.com> - 0.2.0-1
- initial version
Loading…
Cancel
Save