git: e8eb1a4a6cca - main - sysutils/debootstrap: switch the port from using gnugrep to pcregrep

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Thu, 08 May 2025 12:26:19 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e8eb1a4a6cca09ff800cf2131a470c2eaae6c617

commit e8eb1a4a6cca09ff800cf2131a470c2eaae6c617
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2025-05-08 12:24:56 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2025-05-08 12:24:56 +0000

    sysutils/debootstrap: switch the port from using gnugrep to pcregrep
    
    Dependency on GNU grep had been originally added to avoid a pathological
    corner case in BSD grep, where it's about two orders of magnitude slower
    than GNU grep.  As it occurs with one particular pattern type, it could
    instead be solved by depending on pcregrep rather than gnugrep.
    
    Submitter prefers this solution because pcregrep is already required by
    other programs and does not have potential conflicts with the BSD grep
    from the base.
    
    PR:     255525, 263279
---
 sysutils/debootstrap/Makefile              | 12 ++-----
 sysutils/debootstrap/files/patch-functions | 54 +++++++++++++++++++++++++++++-
 2 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/sysutils/debootstrap/Makefile b/sysutils/debootstrap/Makefile
index 75b4fd2cd320..331caf5869d6 100644
--- a/sysutils/debootstrap/Makefile
+++ b/sysutils/debootstrap/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	debootstrap
 PORTVERSION=	${DEB_VERSION}n${DEB_NMU}
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	sysutils
 MASTER_SITES=	DEBIAN
 DISTNAME=	${PORTNAME}_${DEB_VERSION}+nmu${DEB_NMU}
@@ -14,7 +14,7 @@ LICENSE_FILE=	${WRKSRC}/debian/copyright
 
 RUN_DEPENDS=	wget:ftp/wget \
 		bash:shells/bash \
-		${LOCALBASE}/bin/grep:textproc/gnugrep \
+		pcregrep:devel/pcre \
 		gpgv2:security/gnupg \
 		gtar:archivers/gtar \
 		${LOCALBASE}/share/keyrings/ubuntu-archive-keyring.gpg:security/ubuntu-keyring
@@ -40,14 +40,6 @@ post-patch:
 	@${FIND} ${WRKSRC}/scripts -type f | \
 		${XARGS} ${REINPLACE_CMD} -e 's,/usr/share/keyrings,${LOCALBASE}/share/keyrings,g'
 
-	# Workaround for bin/255525
-	@${REINPLACE_CMD} -e 's,grep,${LOCALBASE}/bin/grep,g' \
-		${WRKSRC}/functions
-
-	# ports/274298
-	@${REINPLACE_CMD} -e 's, tar , ${LOCALBASE}/bin/gtar ,g' \
-		${WRKSRC}/functions
-
 post-install:
 	${INSTALL_MAN} ${WRKSRC}/debootstrap.8 \
 		${STAGEDIR}${PREFIX}/share/man/man8/debootstrap.8
diff --git a/sysutils/debootstrap/files/patch-functions b/sysutils/debootstrap/files/patch-functions
index 4247a0cef7db..1fbffa87489c 100644
--- a/sysutils/debootstrap/files/patch-functions
+++ b/sysutils/debootstrap/files/patch-functions
@@ -1,4 +1,4 @@
---- functions.orig	2023-02-24 08:27:34 UTC
+--- functions.orig	2022-10-18 22:48:32 UTC
 +++ functions
 @@ -658,7 +658,7 @@ download_release_sig () {
  		info RELEASESIG "Checking Release signature"
@@ -9,6 +9,58 @@
  		 "$relsigdest" "$reldest" || true) | read_gpg_status
  		progress 100 100 DOWNRELSIG "Downloading Release file signature"
  	fi
+@@ -978,7 +978,7 @@ extract_dpkg_deb_field () {
+ extract_dpkg_deb_data () {
+ 	local pkg="$1"
+ 
+-	dpkg-deb --fsys-tarfile "$pkg" | tar $EXTRACT_DEB_TAR_OPTIONS -xf - || error 1 FILEEXIST "Tried to extract package, but file already exists. Exit..."
++	dpkg-deb --fsys-tarfile "$pkg" | gtar $EXTRACT_DEB_TAR_OPTIONS -xf - || error 1 FILEEXIST "Tried to extract package, but file already exists. Exit..."
+ }
+ 
+ # Raw .deb extractors
+@@ -998,7 +998,7 @@ extract_ar_deb_field () {
+ 
+ 	if in_path $cat_cmd; then
+ 		ar -p "$pkg" "$tarball" | $cat_cmd |
+-		    tar -O -xf - control ./control 2>/dev/null |
++		    gtar -O -xf - control ./control 2>/dev/null |
+ 		    grep -i "^$field:" | sed -e 's/[^:]*: *//' | head -n 1
+ 	else
+ 		error 1 UNPACKCMDUNVL "Extracting %s requires the %s command, which is not available" "$pkg" "$cat_cmd"
+@@ -1020,7 +1020,7 @@ extract_ar_deb_data () {
+ 	esac
+ 
+ 	if in_path "$cat_cmd"; then
+-		ar -p "$pkg" "$tarball" | "$cat_cmd" | tar $EXTRACT_DEB_TAR_OPTIONS -xf -
++		ar -p "$pkg" "$tarball" | "$cat_cmd" | gtar $EXTRACT_DEB_TAR_OPTIONS -xf -
+ 	else
+ 		error 1 UNPACKCMDUNVL "Extracting %s requires the %s command, which is not available" "$pkg" "$cat_cmd"
+ 	fi
+@@ -1515,7 +1515,7 @@ while (read STDIN, $x, 1) {
+ }' "$@"
+ 		elif [ "$1" = "GETDEPS" ]; then
+ 			local pkgdest="$2"; shift; shift
+-LC_ALL=C grep "$gropt" '^$|^Package:|^Depends:|^Pre-Depends:'  $pkgdest | perl -e '
++LC_ALL=C pcregrep '^$|^Package:|^Depends:|^Pre-Depends:' $pkgdest | perl -e '
+ %seen = map { $_ => 1 } @ARGV;
+ while (<STDIN>) {
+ 	if (/^Package: (.*)$/) {
+@@ -1543,13 +1543,13 @@ while (<STDIN>) {
+ 			local m="$2"
+ 			local p="$3"
+ 			shift; shift; shift
+-			LC_ALL=C grep "$gropt" '^$|^Architecture:|^Filename:|^MD5sum:|^Package:|^Priority:|^SHA256:|^Size:|^Version:|^Depends:|^Pre-Depends:' "$p" | pkgdetails_field 1 Package: "$m" "$@"
++			LC_ALL=C pcregrep '^$|^Architecture:|^Filename:|^MD5sum:|^Package:|^Priority:|^SHA256:|^Size:|^Version:|^Depends:|^Pre-Depends:' "$p" | pkgdetails_field 1 Package: "$m" "$@"
+ 		elif [ "$1" = "FIELD" ]; then
+ 			local f="$2"
+ 			local m="$3"
+ 			local p="$4"
+ 			shift; shift; shift; shift
+-			LC_ALL=C grep "$gropt" '^$|^Package:|^Priority:' "$p" | pkgdetails_field 0 "$f" "$m" "$@"
++			LC_ALL=C pcregrep '^$|^Package:|^Priority:' "$p" | pkgdetails_field 0 "$f" "$m" "$@"
+ 		elif [ "$1" = "STANZAS" ]; then
+ 			local pkgdest="$2"; shift; shift
+ 			perl -e '
 @@ -1706,7 +1706,7 @@ read_gpg_status () {
  	elif [ "$unkkey" ]; then
  		error 1 UNKNOWNRELSIG "Release signed by unknown key (key id %s)\n   The specified keyring $KEYRING may be incorrect or out of date.\n   You can find the latest Debian release key at https://ftp-master.debian.org/keys.html" "$unkkey"