tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pbulk: add strict mode



This time with the diff.

On Tue, Jan 21, 2025 at 04:34:27PM +0100, Thomas Klausner wrote:
> Hi!
> 
> In case anyone is interested, here is a patch adding a 'strict_mode'
> option to pbulk.
> 
> When this is set to 'yes', pbulk will just exit if there is an
> unresolvable dependency in the resolve phase, like it did before my
> recent commit (i.e. before pbulk-base-0.58/pbulk-0.74).
> 
> It survived the same tests I did for the previous change
> (strict_mode=yes or unset or no; limited or full bulk for only
> SUBDIR=ham).
> 
> I will happily commit this if anyone speaks up for this option.
> 
> Let me know!
> 
> Thanks,
>  Thomas
Index: pbulk/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/Makefile,v
retrieving revision 1.93
diff -u -r1.93 Makefile
--- pbulk/Makefile	13 Jan 2025 11:03:03 -0000	1.93
+++ pbulk/Makefile	21 Jan 2025 15:29:31 -0000
@@ -1,6 +1,6 @@
 # $NetBSD: Makefile,v 1.93 2025/01/13 11:03:03 wiz Exp $
 
-PKGNAME=	pbulk-0.74
+PKGNAME=	pbulk-0.75
 COMMENT=	Modular bulk build framework
 
 .include "../../pkgtools/pbulk/Makefile.common"
Index: pbulk/files/pbulk/pbulk.conf
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/pbulk.conf,v
retrieving revision 1.28
diff -u -r1.28 pbulk.conf
--- pbulk/files/pbulk/pbulk.conf	13 Jan 2025 11:03:03 -0000	1.28
+++ pbulk/files/pbulk/pbulk.conf	21 Jan 2025 15:29:31 -0000
@@ -44,6 +44,11 @@
 # The file is a newline separated list of package locations (e.g. lang/perl5).
 #limited_list=/limited_list
 
+# In strict mode, unresolvable dependencies lead to pbulk stopping
+# with an error in the scan phase. Otherwise, these packages are
+# reported as broken in the bulk build report instead.
+strict_mode=no
+
 # If yes, consider a package up-to-date, if the dependency list matches
 # the existing binary package and the recorded RCS IDs match the pkgsrc
 # tree. Otherwise, additionally require that the package is not older
Index: pbulk/files/pbulk/presolve/pbulk-resolve.1
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/presolve/pbulk-resolve.1,v
retrieving revision 1.2
diff -u -r1.2 pbulk-resolve.1
--- pbulk/files/pbulk/presolve/pbulk-resolve.1	13 Jan 2025 11:03:03 -0000	1.2
+++ pbulk/files/pbulk/presolve/pbulk-resolve.1	21 Jan 2025 15:29:31 -0000
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 6, 2025
+.Dd January 20, 2025
 .Dt PBULK-RESOLVE 1
 .Os
 .Sh NAME
@@ -34,7 +34,7 @@
 output
 .Sh SYNOPSIS
 .Nm
-.Op Fl v
+.Op Fl sv
 .Op Fl i Ar missing
 .Ar input Op ...
 .Sh DESCRIPTION
@@ -63,6 +63,9 @@
 dependencies.
 The location of each unresolved dependency is written to
 .Ar missing .
+.It Fl s
+Enter strict mode (see
+.Sx EXIT STATUS ) .
 .It Fl v
 If
 .Fl v
@@ -76,7 +79,9 @@
 .El
 .Sh EXIT STATUS
 .Nm
-exits with return value 0.
+exits with return value 0,
+except in strict mode where it will return 1 if a dependency could not
+be resolved.
 .Pp
 In incremental mode,
 .Ar missing
Index: pbulk/files/pbulk/presolve/presolve.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/presolve/presolve.c,v
retrieving revision 1.5
diff -u -r1.5 presolve.c
--- pbulk/files/pbulk/presolve/presolve.c	13 Jan 2025 11:03:03 -0000	1.5
+++ pbulk/files/pbulk/presolve/presolve.c	21 Jan 2025 15:29:31 -0000
@@ -46,13 +46,14 @@
 
 #include "pbulk.h"
 
-static int verbosity;
 static FILE *incremental = NULL;
+static int strict;
+static int verbosity;
 
 static void
 usage(void)
 {
-	(void)fprintf(stderr, "usage: pbulk-resolve [-v] [-i missing] <pscan output> [ ... ]\n");
+	(void)fprintf(stderr, "usage: pbulk-resolve [-sv] [-i missing] <pscan output> [ ... ]\n");
 	exit(1);
 }
 
@@ -87,7 +88,7 @@
 
 	setprogname("pbulk-resolve");
 
-	while ((ch = getopt(argc, argv, "i:pv")) != -1) {
+	while ((ch = getopt(argc, argv, "i:sv")) != -1) {
 		switch (ch) {
 		case 'i':
 			if (incremental != NULL)
@@ -95,6 +96,9 @@
 			if ((incremental = fopen(optarg, "w")) == NULL)
 				err(1, "Cannot open output file");
 			break;
+                case 's':
+			++strict;
+                        break;
 		case 'v':
 			++verbosity;
 			break;
@@ -305,7 +309,9 @@
 	free(depends_list);
 	if (ret == 1) {
 		free(pkg->depends);
-		pkg->depends = NULL;
+                pkg->depends = NULL;
+                if (strict)
+			return 1;
 	}
 	return 0;
 }
@@ -403,7 +409,7 @@
 		if (pkgs[i].active == 0)
 			continue;
 		/* if package is ok, just print existing entry */
-		if (pkgs[i].broken == NULL) {
+		if (pkgs[i].broken == NULL || strict) {
 			(void)fwrite(pkgs[i].begin, 1, pkgs[i].end - pkgs[i].begin, stdout);
 		} else {
 			/* otherwise, replace PKG_FAIL_REASON line with reason for brokenness */
Index: pbulk/files/pbulk/scripts/scan
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/scripts/scan,v
retrieving revision 1.11
diff -u -r1.11 scan
--- pbulk/files/pbulk/scripts/scan	13 Jan 2025 11:03:03 -0000	1.11
+++ pbulk/files/pbulk/scripts/scan	21 Jan 2025 15:29:32 -0000
@@ -47,6 +47,17 @@
 	extra_pscan_args=""
 fi
 
+case "${strict_mode}" in
+[yY][eE][sS])
+	extra_presolve_args="-s"
+	strict_mode=yes
+	;;
+*)
+	extra_presolve_args=""
+	strict_mode=no
+	;;
+esac
+
 if [ -n "${ignore_missing_dependencies}" ]; then
 	echo "The 'ignore_missing_dependencies' configuration variable is obsolete and has no effect." >&2
 fi
@@ -66,7 +77,10 @@
 		;;
 	esac
 	echo "Resolving..."
-	${presolve} -v ${loc}/pscan > ${loc}/presolve 2> ${loc}/presolve-err.log
+	if ! ${presolve} ${extra_presolve_args} -v ${loc}/pscan > ${loc}/presolve 2> ${loc}/presolve-err.log; then
+		# can only happen in strict mode
+		echo "Global dependency resolution failed, check ${loc}/presolve-err.log for details" >&2
+	fi
 else
 	initial=1
 	mkdir -p ${loc}
@@ -99,6 +113,11 @@
 	done
 
 	if [ -s ${loc}/missing ]; then
+		if [ "${strict_mode}" = "yes" ]; then
+			echo "Unresolvable dependencies found, exiting"
+			cat ${loc}/missing
+			exit 1
+		fi
 		echo "Unresolvable dependencies found, marking packages depending on them as broken:"
 		cat ${loc}/missing
 		${presolve} -v ${loc}/presolve ${loc}/pscan > ${loc}/presolve.new
Index: pbulk-base/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk-base/Makefile,v
retrieving revision 1.29
diff -u -r1.29 Makefile
--- pbulk-base/Makefile	13 Jan 2025 11:03:03 -0000	1.29
+++ pbulk-base/Makefile	21 Jan 2025 15:29:32 -0000
@@ -1,6 +1,6 @@
 # $NetBSD: Makefile,v 1.29 2025/01/13 11:03:03 wiz Exp $
 
-DISTNAME=	pbulk-base-0.58
+DISTNAME=	pbulk-base-0.59
 COMMENT=	Core components of the modular bulk build framework
 
 .include "../../pkgtools/pbulk/Makefile.common"


Home | Main Index | Thread Index | Old Index