dev-vcs/cvs: fix all kinds of Modern C issues

This package release is an extra-vintage 2005 with extra gnulib on top.

Among numerous other issues, the broken autoconf standard macros managed
to break the STDC_HEADERS check, resulting in cvs thinking that there
are no available standard headers, and not bothering to include them.
Ouch!

To fix this, we:
- fix a broken AM_GNU_GETTEXT_VERSION macro to stop autopoint erroring
- rerun eautoreconf, to fix various standard macros with c99 fixes
- add some m4 patches that partially backport gnulib fixes (I think hope
  and pray, since I stopped looking at them after a bit due to the
  inability to backport)

Also, while we are at it, throw in a broken shell quoting fix.

Closes: https://bugs.gentoo.org/898782
Closes: https://bugs.gentoo.org/882225
Closes: https://bugs.gentoo.org/870835
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Eli Schwartz
2024-05-19 22:02:09 -04:00
committed by Sam James
parent 9b4bb85dbd
commit ef52b34d6d
4 changed files with 286 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit autotools pam toolchain-funcs
DESCRIPTION="Concurrent Versions System - source code revision control tools"
HOMEPAGE="https://cvs.nongnu.org/"
SRC_URI="mirror://gnu/non-gnu/cvs/source/feature/${PV}/${P}.tar.bz2
doc? ( mirror://gnu/non-gnu/cvs/source/feature/${PV}/cederqvist-${PV}.html.tar.bz2
mirror://gnu/non-gnu/cvs/source/feature/${PV}/cederqvist-${PV}.pdf
mirror://gnu/non-gnu/cvs/source/feature/${PV}/cederqvist-${PV}.ps )"
LICENSE="GPL-2 LGPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-solaris"
IUSE="crypt doc kerberos nls pam selinux server"
RESTRICT="test"
DEPEND="
>=sys-libs/zlib-1.1.4
kerberos? ( virtual/krb5 )
pam? ( sys-libs/pam )
server? ( virtual/libcrypt:= )
"
RDEPEND="
${DEPEND}
selinux? ( sec-policy/selinux-cvs )
"
src_unpack() {
unpack ${P}.tar.bz2
use doc && unpack cederqvist-${PV}.html.tar.bz2
}
PATCHES=(
"${FILESDIR}"/${P}-cvsbug-tmpfix.patch
"${FILESDIR}"/${P}-openat.patch
"${FILESDIR}"/${P}-block-requests.patch
"${FILESDIR}"/${P}-cvs-gnulib-vasnprintf.patch
"${FILESDIR}"/${P}-install-sh.patch
"${FILESDIR}"/${P}-hash-nameclash.patch # for AIX
"${FILESDIR}"/${P}-getdelim.patch # 314791
"${FILESDIR}"/${PN}-1.12.12-rcs2log-coreutils.patch # 144114
"${FILESDIR}"/${P}-mktime-x32.patch # 395641
"${FILESDIR}"/${P}-fix-massive-leak.patch
"${FILESDIR}"/${P}-mktime-configure-m4.patch #220040 #570208
"${FILESDIR}"/${P}-CVE-2012-0804.patch
"${FILESDIR}"/${P}-format-security.patch
"${FILESDIR}"/${P}-musl.patch
"${FILESDIR}"/${P}-CVE-2017-12836-commandinjection.patch
"${FILESDIR}"/0001-gettext-autoreconf.patch
"${FILESDIR}"/0001-fix-quoting-around-potentially-empty-shell-var.patch
"${FILESDIR}"/c99-roundup.patch
)
DOCS=( BUGS ChangeLog{,.zoo} DEVEL-CVS FAQ HACKING MINOR-BUGS NEWS \
PROJECTS README TESTS TODO )
src_prepare() {
export CONFIG_SHELL=${BASH} # configure fails without
default
eautoreconf
sed -i "/^AR/s:ar:$(tc-getAR):" diff/Makefile.in lib/Makefile.in || die
}
src_configure() {
if tc-is-cross-compiler ; then
# Sane defaults when cross-compiling (as these tests want to
# try and execute code).
export cvs_cv_func_printf_ptr="yes"
fi
econf \
--with-external-zlib \
--with-tmpdir="${EPREFIX}"/tmp \
$(use_enable crypt encryption) \
$(use_with kerberos gssapi) \
$(use_enable nls) \
$(use_enable pam) \
$(use_enable server)
}
src_install() {
# Not installed into emacs site-lisp because it clobbers the normal C
# indentations.
DOCS+=( cvs-format.el )
if use doc; then
DOCS+=( "${DISTDIR}"/cederqvist-${PV}.{pdf,ps} )
HTML_DOCS=( ../cederqvist-${PV}.html/. )
fi
default
use doc && dosym cvs.html /usr/share/doc/${PF}/html/index.html
if use server; then
newdoc "${FILESDIR}"/cvs-1.12.12-cvs-custom.c cvs-custom.c
insinto /etc/xinetd.d
newins "${FILESDIR}"/cvspserver.xinetd.d cvspserver
newenvd "${FILESDIR}"/01-cvs-env.d 01cvs
fi
if use pam; then
newpamd "${FILESDIR}"/cvs.pam-include-1.12.12 cvs
fi
}

View File

@@ -0,0 +1,30 @@
From 6054eb157a25b4b46427baa6eb53b5e18135019a Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz93@gmail.com>
Date: Sun, 19 May 2024 21:15:34 -0400
Subject: [PATCH 1/2] fix quoting around potentially empty shell var
required to handle POSIX `test` command
* QA Notice: Broken syntax in configure script
*
* ./configure: line 8046: test: =: unary operator expected
---
configure.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.in b/configure.in
index d4f3a44..2a9b0ff 100644
--- a/configure.in
+++ b/configure.in
@@ -179,7 +179,7 @@ AC_CHECK_MEMBERS([struct stat.st_blksize])
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_FUNC_FSEEKO
-if test $ac_cv_func_fseeko = no; then
+if test "$ac_cv_func_fseeko" = no; then
AC_LIBOBJ(fseeko)
AC_LIBOBJ(ftello)
fi
--
2.44.1

View File

@@ -0,0 +1,25 @@
From dafaeefa2d81034333ec73594b8209caebb69b23 Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz93@gmail.com>
Date: Sun, 19 May 2024 19:48:33 -0400
Subject: [PATCH] gettext autoreconf
---
configure.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.in b/configure.in
index ada8454..d4f3a44 100644
--- a/configure.in
+++ b/configure.in
@@ -206,7 +206,7 @@ gl_INIT
dnl For one reason or another, the autogenerated m4/gnulib.m4 wants
dnl AM_GNU_GETTEXT([external]) called directly from here.
AM_GNU_GETTEXT([external])
-AM_GNU_GETTEXT_VERSION dnl work around for autoconf-2.57 bug.
+AM_GNU_GETTEXT_VERSION(0.22.4)
# The error module still poses merge problems.
AC_FUNC_STRERROR_R
dnl The following macros can be called by other GNULIB macros but are also
--
2.44.1

View File

@@ -0,0 +1,122 @@
From 4df675986524d0e8e76530a3e1bd7860aef9973d Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz93@gmail.com>
Date: Sun, 19 May 2024 21:27:38 -0400
Subject: [PATCH 1/2] m4: fix various missing includes of headers for feature
test funcs
---
m4/cvs_func_printf_ptr.m4 | 1 +
m4/mkdir-slash.m4 | 6 +++++-
m4/nanosleep.m4 | 1 +
m4/regex.m4 | 1 +
m4/rename.m4 | 1 +
5 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/m4/cvs_func_printf_ptr.m4 b/m4/cvs_func_printf_ptr.m4
index 4348e29..f04c135 100644
--- a/m4/cvs_func_printf_ptr.m4
+++ b/m4/cvs_func_printf_ptr.m4
@@ -24,6 +24,7 @@ AC_DEFUN([CVS_FUNC_PRINTF_PTR],
[AC_CACHE_CHECK(whether printf supports %p,
cvs_cv_func_printf_ptr,
[AC_TRY_RUN([#include <stdio.h>
+#include <stdlib.h>
/* If printf supports %p, exit 0. */
int
main ()
diff --git a/m4/mkdir-slash.m4 b/m4/mkdir-slash.m4
index c1e595b..0ca9a91 100644
--- a/m4/mkdir-slash.m4
+++ b/m4/mkdir-slash.m4
@@ -1,4 +1,4 @@
-#serial 4
+#serial 5
# Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -10,6 +10,7 @@
# trailing slashes.
AC_DEFUN([gl_FUNC_MKDIR_TRAILING_SLASH],
[dnl
+ AC_CHECK_HEADERS_ONCE(unistd.h)
AC_CACHE_CHECK([whether mkdir fails due to a trailing slash],
gl_cv_func_mkdir_trailing_slash_bug,
[
@@ -19,6 +20,9 @@ AC_DEFUN([gl_FUNC_MKDIR_TRAILING_SLASH],
# include <sys/types.h>
# include <sys/stat.h>
# include <stdlib.h>
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
int main ()
{
rmdir ("confdir-slash");
diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4
index 5590b9b..035e440 100644
--- a/m4/nanosleep.m4
+++ b/m4/nanosleep.m4
@@ -39,6 +39,7 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
# include <time.h>
# endif
# endif
+# include <stdlib.h>
int
main ()
diff --git a/m4/regex.m4 b/m4/regex.m4
index 34435de..5988f68 100644
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -36,6 +36,7 @@ AC_DEFUN([gl_INCLUDED_REGEX],
[#include <stdio.h>
#include <string.h>
#include <regex.h>
+#include <stdlib.h>
int
main ()
{
diff --git a/m4/rename.m4 b/m4/rename.m4
index 7d59160..362fdd4 100644
--- a/m4/rename.m4
+++ b/m4/rename.m4
@@ -23,6 +23,7 @@ AC_DEFUN([vb_FUNC_RENAME],
AC_MSG_ERROR([cannot create temporary directory])
AC_TRY_RUN([
# include <stdio.h>
+# include <stdlib.h>
int
main ()
{
--
2.44.1
From f6e7556c404e1cb3ddb088fab480aa39a9ad0306 Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz93@gmail.com>
Date: Sun, 19 May 2024 21:47:06 -0400
Subject: [PATCH 2/2] fix missing config.h includes preventing functions from
being found
_GNU_SOURCE needs to be defined by config.h, so that fputs_unlocked is
provided by stdio.h (as used by gnulib's unlocked-io module).
---
src/add.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/add.c b/src/add.c
index 7f94e2b..025cfc9 100644
--- a/src/add.c
+++ b/src/add.c
@@ -29,6 +29,8 @@
* file to be resurrected.
*/
+#include <config.h>
+
#include <assert.h>
#include "cvs.h"
#include "save-cwd.h"
--
2.44.1