Skip to content

Commit

Permalink
net-mail/safecat: EAPI 8 bump, some fixes
Browse files Browse the repository at this point in the history
This does not include a full suite of Clang fixes, due to upstream's C
coding style: significant work to fix all of the prototypes in this code
base, and align with modern types.

Signed-off-by: Robin H. Johnson <[email protected]>
Closes: https://bugs.gentoo.org/show_bug.cgi?id=725030
Closes: https://bugs.gentoo.org/show_bug.cgi?id=836088
  • Loading branch information
robbat2 committed Jun 15, 2024
1 parent dde9c70 commit 69ef13e
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 4 deletions.
39 changes: 39 additions & 0 deletions net-mail/safecat/files/safecat-1.13-dup-obj-makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
https://bugs.gentoo.org/740798
https://cgit.freebsd.org/ports/plain/sysutils/safecat/files/patch-Makefile

sysutils/safecat: avoid duplicating object files in library

Previously byte_copy.o and str_len.o were added to str.a, and then
specified as objects on the safecat link command line along with str.
When linking with lld this produces duplicate symbol errors like:

/usr/bin/ld: error: duplicate symbol: byte_copy
>>> defined at byte_copy.c
>>> byte_copy.o:(byte_copy) in archive str.a
>>> defined at byte_copy.c
>>> byte_copy.o(.text+0x0)

As these symbols are provided by str.a just avoid listing the object
files as well.
--- safecat-1.13/Makefile.orig 2004-08-16 20:50:09.000000000 -0400
+++ safecat-1.13/Makefile 2017-11-23 16:49:00.505811000 -0500
@@ -219,14 +219,14 @@

safecat: \
load safecat.o getln.a str.a stralloc.a strerr.a substdio.a alloc.o \
-alloc_re.o byte_copy.o byte_cr.o envread.o error.o error_str.o fmt_uint64.o \
-hostname.o sig.o stat_dir.o str_diffn.o str_len.o substdio_copy.o \
+alloc_re.o byte_cr.o envread.o error.o error_str.o fmt_uint64.o \
+hostname.o sig.o stat_dir.o str_diffn.o substdio_copy.o \
substdi.o substdio.o taia_fmtfrac.o taia_now.o taia_tai.o tempfile.o \
writefile.o
- ./load safecat getln.a str.a stralloc.a strerr.a substdio.a \
- alloc.o alloc_re.o byte_copy.o byte_cr.o envread.o error.o \
+ ./load safecat getln.a stralloc.a strerr.a substdio.a str.a \
+ alloc.o alloc_re.o byte_cr.o envread.o error.o \
error_str.o fmt_uint64.o hostname.o sig.o stat_dir.o str_diffn.o \
- str_len.o substdi.o substdio.o substdio_copy.o taia_fmtfrac.o \
+ substdi.o substdio.o substdio_copy.o taia_fmtfrac.o \
taia_now.o taia_tai.o tempfile.o writefile.o

safecat.0: \
97 changes: 97 additions & 0 deletions net-mail/safecat/files/safecat-1.13-include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
diff '--color=auto' -Nuar safecat-1.13.orig/install.c safecat-1.13/install.c
--- safecat-1.13.orig/install.c 2000-02-28 20:10:12.000000000 -0800
+++ safecat-1.13/install.c 2024-06-15 14:40:24.142699634 -0700
@@ -1,3 +1,10 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "substdio.h"
#include "strerr.h"
#include "error.h"
diff '--color=auto' -Nuar safecat-1.13.orig/instcheck.c safecat-1.13/instcheck.c
--- safecat-1.13.orig/instcheck.c 2000-02-28 20:10:12.000000000 -0800
+++ safecat-1.13/instcheck.c 2024-06-15 14:40:27.502696776 -0700
@@ -1,5 +1,12 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "strerr.h"
#include "error.h"
#include "readwrite.h"
diff '--color=auto' -Nuar safecat-1.13.orig/safecat.c safecat-1.13/safecat.c
--- safecat-1.13.orig/safecat.c 2004-08-16 18:14:34.000000000 -0700
+++ safecat-1.13/safecat.c 2024-06-15 14:40:17.246038832 -0700
@@ -23,6 +23,7 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
+#include <stdlib.h>
#include <unistd.h>

/* Support for large files (on Linux systems, if the appropriate
--- safecat-1.13.orig/alloc.c 2000-02-28 20:10:12.000000000 -0800
+++ safecat-1.13/alloc.c 2024-06-15 14:41:26.985979033 -0700
@@ -1,7 +1,6 @@
+#include <stdlib.h>
#include "alloc.h"
#include "error.h"
-extern char *malloc();
-extern void free();

#define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */
#define SPACE 4096 /* must be multiple of ALIGNMENT */
@@ -18,7 +17,7 @@
char *x;
n = ALIGNMENT + n - (n & (ALIGNMENT - 1)); /* XXX: could overflow */
if (n <= avail) { avail -= n; return space + avail; }
- x = malloc(n);
+ x = (char*)malloc(n);
if (!x) errno = error_nomem;
return x;
}
--- safecat-1.13.orig/readwrite.h 2024-06-15 14:46:41.472362482 -0700
+++ safecat-1.13/readwrite.h 2024-06-15 14:46:21.755714187 -0700
@@ -1,7 +1,8 @@
#ifndef READWRITE_H
#define READWRITE_H

-extern int read();
-extern int write();
+#include <unistd.h>
+//extern int read();
+//extern int write();

#endif
--- safecat-1.13/stralloc.h 2000-02-28 20:10:12.000000000 -0800
+++ safecat-1.13/stralloc.h 2024-06-15 14:55:46.678492988 -0700
@@ -7,14 +7,14 @@

extern int stralloc_ready();
extern int stralloc_readyplus();
-extern int stralloc_copy();
-extern int stralloc_cat();
+extern int stralloc_copy(stralloc *sato, stralloc *safrom);
+extern int stralloc_cat(stralloc *sato, stralloc *safrom);
extern int stralloc_copys();
-extern int stralloc_cats();
-extern int stralloc_copyb();
-extern int stralloc_catb();
+extern int stralloc_cats(stralloc *sa, char *s);
+extern int stralloc_copyb(stralloc *sa, char *s, unsigned int n);
+extern int stralloc_catb(stralloc *sa, char *s, unsigned int n);
extern int stralloc_append(); /* beware: this takes a pointer to 1 char */
-extern int stralloc_starts();
+extern int stralloc_starts(stralloc *sa, char *s);

#define stralloc_0(sa) stralloc_append(sa,"")

51 changes: 51 additions & 0 deletions net-mail/safecat/safecat-1.13-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit toolchain-funcs

DESCRIPTION="Safecat implements qmail's maildir algorithm, safely copying standard input"
HOMEPAGE="http://www.jeenyus.net/linux/software/safecat.html"
SRC_URI="http://www.jeenyus.net/linux/software/${PN}/${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~hppa ~mips ~ppc ~sparc ~x86"
RESTRICT="test"

DEPEND="sys-apps/groff"

PATCHES=(
# applying maildir-patch
"${FILESDIR}"/safecat-1.11-gentoo.patch
# Fix parallel make errors
"${FILESDIR}"/${P}-makefile.patch
# Fix POSIX head/tail syntax
"${FILESDIR}"/${P}-head-tail-POSIX.patch
# Fix dup objects
"${FILESDIR}"/${P}-dup-obj-makefile.patch
# Headers
"${FILESDIR}"/${P}-include.patch
)

src_prepare() {
default

sed -ni '/man\|doc/!p' hier.c || die
}

src_configure() {
echo "/usr" > conf-root || die
echo "$(tc-getCC) ${CFLAGS}" > conf-cc || die
echo "$(tc-getCC) ${LDFLAGS}" > conf-ld || die
echo "$(tc-getAR)" > conf-ar || die
}

src_install() {
# ${D} is not valid in src_configure
echo "${D}/usr" > conf-root || die
emake setup check
einstalldocs
doman maildir.1 safecat.1
}
7 changes: 3 additions & 4 deletions net-mail/safecat/safecat-1.13.ebuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2018 Gentoo Foundation
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6
Expand All @@ -12,11 +12,9 @@ SRC_URI="http://www.jeenyus.net/linux/software/${PN}/${P}.tar.gz"
LICENSE="BSD"
SLOT="0"
KEYWORDS="amd64 ~hppa ~mips ppc ~sparc x86"
IUSE=""
RESTRICT="test"

DEPEND="sys-apps/groff"
RDEPEND=""

PATCHES=(
# applying maildir-patch
Expand All @@ -37,12 +35,13 @@ src_prepare() {
}

src_configure() {
echo "${D}/usr" > conf-root || die
echo "/usr" > conf-root || die
echo "$(tc-getCC) ${CFLAGS}" > conf-cc || die
echo "$(tc-getCC) ${LDFLAGS}" > conf-ld || die
}

src_install() {
echo "${D}/usr" > conf-root || die
emake setup check
einstalldocs
doman maildir.1 safecat.1
Expand Down

0 comments on commit 69ef13e

Please sign in to comment.