tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pbulk: don't break on unresolvable dependencies
Hi!
I've modified pbulk so that by default, when it finds an unresolvable
dependency, it marks the package depending on the unresolvable
dependency as broken (by setting PKG_FAIL_REASON). These broken
packages are then visible e.g. in the HTML report as
local/py-xdist311 py313-xdist311-0.0.2 pkgsrc-users%NetBSD.org@localhost prefailed
could not resolve dependency cwrappers>=20150314
I did some local testing using a limited bulk build and a "full" bulk
build where I only allowed a couple packages by restricting SUBDIRS,
but I'd appreciate if other people could also test it.
The change is actually quite small, the biggest part is writing a
modified scan entry that changes PKG_FAIL_REASON.
Other changes:
- document pbulk-resolve -p
- remove ignore_missing_dependencies config setting because it's now
unnecessary
Please give it a try.
Cheers,
Thomas
Index: pbulk.conf
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/pbulk.conf,v
retrieving revision 1.27
diff -u -r1.27 pbulk.conf
--- pbulk.conf 12 Oct 2024 10:43:52 -0000 1.27
+++ pbulk.conf 3 Jan 2025 10:48:54 -0000
@@ -44,11 +44,6 @@
# The file is a newline separated list of package locations (e.g. lang/perl5).
#limited_list=/limited_list
-# Optionally ignore unresolvable dependencies for a full build (e.g.
-# a build without limited_list set). Default behavior is to bail out.
-#
-ignore_missing_dependencies=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: presolve/pbulk-resolve.1
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/presolve/pbulk-resolve.1,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 pbulk-resolve.1
--- presolve/pbulk-resolve.1 19 Jun 2007 19:49:57 -0000 1.1.1.1
+++ presolve/pbulk-resolve.1 3 Jan 2025 10:48:54 -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 June 12, 2007
+.Dd January 2, 2025
.Dt PBULK-RESOLVE 1
.Os
.Sh NAME
@@ -35,7 +35,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl v
-.Op Fl i Ar missing
+.Op Fl i Ar missing | Fl p
.Ar input Op ...
.Sh DESCRIPTION
.Nm
@@ -57,6 +57,11 @@
.Ar missing .
In normal mode, unresolvable dependencies are printed and the
program exits with an error.
+.It Fl p
+Enter partial mode.
+In partial mode, unresolvable dependencies are marked as broken
+using
+.Dv PKG_FAIL_REASON .
.It Fl v
If
.Fl v
@@ -72,6 +77,11 @@
.Nm
exits with return value 1 if an error occurred, or 0 if all
dependencies have been resolved successfully.
+.Pp
+In incremental and partial mode,
+.Nm
+always exits with return value 0.
+.Pp
In incremental mode,
.Ar missing
contains all correct, but unresolvable dependencies.
Index: presolve/presolve.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/presolve/presolve.c,v
retrieving revision 1.4
diff -u -r1.4 presolve.c
--- presolve/presolve.c 16 Sep 2008 18:21:30 -0000 1.4
+++ presolve/presolve.c 3 Jan 2025 10:48:54 -0000
@@ -52,7 +52,7 @@
static void
usage(void)
{
- (void)fprintf(stderr, "usage: pbulk-resolve [ -pv ] [ -i <missing> ] <pscan output> [ ... ]\n");
+ (void)fprintf(stderr, "usage: pbulk-resolve [-v] [-i missing | -p] <pscan output> [ ... ]\n");
exit(1);
}
@@ -63,7 +63,7 @@
char *depends;
char *pkglocation;
int active;
- int broken; /* Entry has missing dependencies */
+ char *broken; /* Entry has missing dependencies */
const char *begin;
const char *end;
SLIST_ENTRY(pkg_entry) hash_link;
@@ -109,7 +109,7 @@
argc -= optind;
argv += optind;
- if (argc == 0 || (incremental == NULL && argc > 1))
+ if (argc == 0)
usage();
if (partial && incremental != NULL)
@@ -286,6 +286,10 @@
if (best_match == NULL) {
ret = 1;
+ if (partial && pkg->broken == NULL) {
+ /* only keep first broken dependency */
+ pkg->broken = xstrndup(pattern_begin, pattern_end - pattern_begin);
+ }
continue;
}
@@ -376,6 +380,7 @@
pkgs[len_pkgs].begin = input_iter;
pkgs[len_pkgs].end = pbulk_item_end(input_iter);
pkgs[len_pkgs].depends = NULL;
+ pkgs[len_pkgs].broken = NULL;
if (pkgs[len_pkgs].end == NULL)
errx(1, "Invalid input");
input_iter = pkgs[len_pkgs].end;
@@ -397,15 +402,35 @@
errx(1, "Invalid input");
}
+#define PKG_FAIL_REASON "PKG_FAIL_REASON="
static void
write_entries(void)
{
size_t i;
+ const char *line, *line_end;
for (i = 0; i < len_pkgs; ++i) {
if (pkgs[i].active == 0)
continue;
- (void)fwrite(pkgs[i].begin, 1, pkgs[i].end - pkgs[i].begin, stdout);
+ /* if package is ok, just print existing entry */
+ if (pkgs[i].broken == NULL) {
+ (void)fwrite(pkgs[i].begin, 1, pkgs[i].end - pkgs[i].begin, stdout);
+ } else {
+ /* otherwise, replace PKG_FAIL_REASON line with reason for brokenness */
+ line = strstr(pkgs[i].begin, PKG_FAIL_REASON);
+ if (line == NULL) {
+ (void)fwrite(pkgs[i].begin, 1, pkgs[i].end -
+ pkgs[i].begin, stdout); continue;
+ }
+ (void)fwrite(pkgs[i].begin, 1, line - pkgs[i].begin,
+ stdout);
+ line_end = strchr(line, '\n');
+ (void)printf(PKG_FAIL_REASON
+ "\"could not resolve dependency \"%s\"\"\n",
+ pkgs[i].broken);
+ (void)fwrite(line_end + 1,
+ 1, pkgs[i].end - (line_end + 1), stdout);
+ }
if (pkgs[i].depends != NULL)
(void)printf("DEPENDS=%s\n", pkgs[i].depends);
}
Index: scripts/scan
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pbulk/files/pbulk/scripts/scan,v
retrieving revision 1.10
diff -u -r1.10 scan
--- scripts/scan 8 Jan 2020 15:12:01 -0000 1.10
+++ scripts/scan 3 Jan 2025 10:48:54 -0000
@@ -64,17 +64,7 @@
echo "Resolving..."
if ! ${presolve} -v ${loc}/pscan > ${loc}/presolve 2> ${loc}/presolve-err.log; then
echo "Global dependency resolution failed, check ${loc}/presolve-err.log for details" >&2
- case "${ignore_missing_dependencies}" in
- [nN][oO])
- exit 1
- ;;
- [yY][eE][sS])
- ${presolve} -p -v ${loc}/pscan > ${loc}/presolve 2> /dev/null
- ;;
- *)
- echo "Unsupported value for ignore_missing_dependencies."
- ;;
- esac
+ ${presolve} -p -v ${loc}/pscan > ${loc}/presolve 2> /dev/null
fi
else
initial=1
@@ -108,9 +98,10 @@
done
if [ -s ${loc}/missing ]; then
- echo "Unresolvable dependencies found, exiting:"
+ echo "Unresolvable dependencies found, marking them as broken:"
cat ${loc}/missing
- exit 1
+ ${presolve} -p -v ${loc}/presolve ${loc}/pscan > ${loc}/presolve.new
+ mv ${loc}/presolve.new ${loc}/presolve
fi
fi
date '+SCAN_END_EPOCHE=%s' >> ${loc}/status
Home |
Main Index |
Thread Index |
Old Index