git: 4e0f740ddca6 - main - sysutils/debootstrap: Fix several issues

From: Felix Palmen <zirias_at_FreeBSD.org>
Date: Tue, 07 Mar 2023 17:10:13 UTC
The branch main has been updated by zirias:

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

commit 4e0f740ddca6bd6d4cf7017bb3132ee759f6db39
Author:     Felix Palmen <zirias@FreeBSD.org>
AuthorDate: 2023-02-24 08:32:30 +0000
Commit:     Felix Palmen <zirias@FreeBSD.org>
CommitDate: 2023-03-07 17:09:28 +0000

    sysutils/debootstrap: Fix several issues
    
    * Don't use substitutions on Makefile, pass variables instead
    * Eliminate "static" substitutions, use a patch-file instead
    * Fix hardcoded /usr/local in debootstrap script
    
    PR:                     269584
    Approved by:            nc (maintainer), tcberner (mentor)
    Differential Revision:  https://reviews.freebsd.org/D38754
---
 sysutils/debootstrap/Makefile                | 24 +++++++++---------------
 sysutils/debootstrap/files/patch-Makefile    |  2 +-
 sysutils/debootstrap/files/patch-debootstrap |  4 ++--
 sysutils/debootstrap/files/patch-functions   | 20 ++++++++++++++++++++
 4 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/sysutils/debootstrap/Makefile b/sysutils/debootstrap/Makefile
index 47dcc65a4b85..baff0b53bf40 100644
--- a/sysutils/debootstrap/Makefile
+++ b/sysutils/debootstrap/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	debootstrap
 PORTVERSION=	${DEB_VERSION}n${DEB_NMU}
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	DEBIAN
 DISTNAME=	${PORTNAME}_${DEB_VERSION}+nmu${DEB_NMU}
@@ -17,31 +18,24 @@ RUN_DEPENDS=	wget:ftp/wget \
 		gpgv2:security/gnupg \
 		${LOCALBASE}/share/keyrings/ubuntu-archive-keyring.gpg:security/ubuntu-keyring
 
-WRKSRC=		${WRKDIR}/${PORTNAME}
-NO_BUILD=	yes
-NO_ARCH=	yes
 USES=		gmake perl5
 USE_PERL5=	run
 
+MAKE_ENV=	DATADIR="${DATADIR}"
+NO_ARCH=	yes
+NO_BUILD=	yes
+WRKSRC=		${WRKDIR}/${PORTNAME}
+
 # The +nmu suffix used by debian for "non maintainer uploads" of a Debian
 # native package doesn't play well with our versioning
 DEB_VERSION=	1.0.128
 DEB_NMU=	2
 
 post-patch:
-	@${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX},g' \
-		${WRKSRC}/Makefile \
-		${WRKSRC}/debootstrap
-	@${REINPLACE_CMD} -e 's,%%DATADIR%%,${DATADIR},g' \
-		${WRKSRC}/Makefile \
+	@${REINPLACE_CMD} \
+		-e 's,%%DATADIR%%,${DATADIR},g' \
+		-e 's,%%LOCALBASE%%,${LOCALBASE},g' \
 		${WRKSRC}/debootstrap
-	@${REINPLACE_CMD} -e 's,%%LOCALBASE%%,${LOCALBASE},g' \
-		${WRKSRC}/Makefile \
-		${WRKSRC}/debootstrap
-	@${REINPLACE_CMD} -e 's,gpgv,gpgv2,g' \
-		${WRKSRC}/Makefile \
-		${WRKSRC}/debootstrap \
-		${WRKSRC}/functions
 	@${FIND} ${WRKSRC}/scripts -type f | \
 		${XARGS} ${REINPLACE_CMD} -e 's,/usr/share/keyrings,${LOCALBASE}/share/keyrings,g'
 
diff --git a/sysutils/debootstrap/files/patch-Makefile b/sysutils/debootstrap/files/patch-Makefile
index 8d55f3868d54..4627149a0e5a 100644
--- a/sysutils/debootstrap/files/patch-Makefile
+++ b/sysutils/debootstrap/files/patch-Makefile
@@ -5,7 +5,7 @@
  clean:
  
 -DSDIR=$(DESTDIR)/usr/share/debootstrap
-+DSDIR=$(DESTDIR)$(PREFIX)/share/debootstrap
++DSDIR=$(DESTDIR)$(DATADIR)
  install:
  	mkdir -p $(DSDIR)/scripts
 -	mkdir -p $(DESTDIR)/usr/sbin
diff --git a/sysutils/debootstrap/files/patch-debootstrap b/sysutils/debootstrap/files/patch-debootstrap
index 82733b633193..32e164a075f3 100644
--- a/sysutils/debootstrap/files/patch-debootstrap
+++ b/sysutils/debootstrap/files/patch-debootstrap
@@ -2,7 +2,7 @@
 +++ debootstrap
 @@ -1,4 +1,4 @@
 -#!/bin/sh
-+#!/usr/local/bin/bash
++#!%%LOCALBASE%%/bin/bash
  set -e
  
  VERSION='@VERSION@'
@@ -11,7 +11,7 @@
  		DEBOOTSTRAP_DIR=/debootstrap
  	else
 -		DEBOOTSTRAP_DIR=/usr/share/debootstrap
-+		DEBOOTSTRAP_DIR=/usr/local/share/debootstrap
++		DEBOOTSTRAP_DIR=%%DATADIR%%
  	fi
  fi
  
diff --git a/sysutils/debootstrap/files/patch-functions b/sysutils/debootstrap/files/patch-functions
new file mode 100644
index 000000000000..4247a0cef7db
--- /dev/null
+++ b/sysutils/debootstrap/files/patch-functions
@@ -0,0 +1,20 @@
+--- functions.orig	2023-02-24 08:27:34 UTC
++++ functions
+@@ -658,7 +658,7 @@ download_release_sig () {
+ 		info RELEASESIG "Checking Release signature"
+ 		# Don't worry about the exit status from gpgv; parsing the output will
+ 		# take care of that.
+-		(gpgv --status-fd 1 --keyring "$KEYRING" --ignore-time-conflict \
++		(gpgv2 --status-fd 1 --keyring "$KEYRING" --ignore-time-conflict \
+ 		 "$relsigdest" "$reldest" || true) | read_gpg_status
+ 		progress 100 100 DOWNRELSIG "Downloading Release file signature"
+ 	fi
+@@ -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"
+ 	else
+-		error 1 SIGCHECK "Error executing gpgv to check Release signature"
++		error 1 SIGCHECK "Error executing gpgv2 to check Release signature"
+ 	fi
+ }
+