From 456693eef1c3c2f97cf27d777e4e00464e01ff82 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 29 Jun 2026 15:17:47 -0400 Subject: Implement --force-repeatable option --- src/lib/delivery/delivery_test.c | 71 ++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 10 deletions(-) (limited to 'src/lib/delivery/delivery_test.c') diff --git a/src/lib/delivery/delivery_test.c b/src/lib/delivery/delivery_test.c index 4ea3b3d..f8da208 100644 --- a/src/lib/delivery/delivery_test.c +++ b/src/lib/delivery/delivery_test.c @@ -178,17 +178,69 @@ void delivery_tests_run(struct Delivery *ctx) { if (pushd(destdir)) { COE_CHECK_ABORT(1, "Unable to enter repository directory"); } else { - const int dep_status = check_python_package_dependencies("."); + struct StrList *setup_files = strlist_init(); + if (!setup_files) { + SYSERROR("unable to to allocate bytes for setup file list"); + exit(1); + } + + struct StrList *matches = strlist_init(); + if (!matches) { + SYSERROR("unable to allocate bytes for matches list"); + guard_strlist_free(&setup_files); + exit(1); + } + + const int dep_status = check_python_package_dependencies(".", &setup_files, &matches); if (dep_status) { - SYSERROR("Please replace all occurrences above with standard package specs:\n" - "\n" - " package==x.y.z\n" - " package>=x.y.z\n" - " package<=x.y.z\n" - " ...\n" - "\n"); - COE_CHECK_ABORT(true, "Unreproducible delivery"); + const char *warning_message = "Please replace all occurrences above with standard package specs:\n" + "\n" + " package==x.y.z\n" + " package>=x.y.z\n" + " package<=x.y.z\n" + " ...\n" + "\n"; + if (globals.force_repeatable) { + SYSWARN("--force-repeatable is enabled"); + SYSWARN(warning_message); + } else { + SYSERROR(warning_message); + COE_CHECK_ABORT(true, "Unreproducible delivery"); + } + + // VCS records have been found, force_repeatable or COE is enabled, so we don't care about integrity + // Replace the records in the file(s) + if (strlist_count(setup_files) && strlist_count(matches)) { + SYSDEBUG("Will replace %zu string(s) in %zu file(s)...", strlist_count(matches), strlist_count(setup_files)); + for (size_t f = 0; f < strlist_count(setup_files); f++) { + const char *setup_file = strlist_item(setup_files, f); + for (size_t m = 0; m < strlist_count(matches); m++) { + const char *match = strlist_item(matches, m); + + // copy the original match string + char *replacement = strdup(match); + if (!replacement) { + SYSERROR("unable to allocate bytes for replacement value"); + exit(1); + } + + // Truncate the replacement string at the first space character or @ symbol + char *stop = strpbrk(replacement, " @"); + if (stop) { + *stop = '\0'; + SYSINFO("%s: replacing '%s' with '%s'", setup_file, match, replacement); + if (file_replace_text(setup_file, match, replacement, 0)) { + SYSERROR("%s: replacement failed", setup_file); + exit(1); + } + } + guard_free(replacement); + } + } + } } + guard_strlist_free(&setup_files); + guard_strlist_free(&matches); char *cmd = calloc(strlen(test->script) + STASIS_BUFSIZ, sizeof(*cmd)); if (!cmd) { @@ -256,7 +308,6 @@ void delivery_tests_run(struct Delivery *ctx) { guard_free(runner_cmd); guard_free(cmd); popd(); - } } -- cgit From 15c1c3d905dfbb46bac2f69ff0f4a0e93518b405 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 6 Jul 2026 19:53:58 -0400 Subject: Replace duplicate VCS version check code with delivery_autoresolve_vcs_urls() call --- src/lib/delivery/delivery_test.c | 64 +--------------------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) (limited to 'src/lib/delivery/delivery_test.c') diff --git a/src/lib/delivery/delivery_test.c b/src/lib/delivery/delivery_test.c index f8da208..d3f7a17 100644 --- a/src/lib/delivery/delivery_test.c +++ b/src/lib/delivery/delivery_test.c @@ -178,69 +178,7 @@ void delivery_tests_run(struct Delivery *ctx) { if (pushd(destdir)) { COE_CHECK_ABORT(1, "Unable to enter repository directory"); } else { - struct StrList *setup_files = strlist_init(); - if (!setup_files) { - SYSERROR("unable to to allocate bytes for setup file list"); - exit(1); - } - - struct StrList *matches = strlist_init(); - if (!matches) { - SYSERROR("unable to allocate bytes for matches list"); - guard_strlist_free(&setup_files); - exit(1); - } - - const int dep_status = check_python_package_dependencies(".", &setup_files, &matches); - if (dep_status) { - const char *warning_message = "Please replace all occurrences above with standard package specs:\n" - "\n" - " package==x.y.z\n" - " package>=x.y.z\n" - " package<=x.y.z\n" - " ...\n" - "\n"; - if (globals.force_repeatable) { - SYSWARN("--force-repeatable is enabled"); - SYSWARN(warning_message); - } else { - SYSERROR(warning_message); - COE_CHECK_ABORT(true, "Unreproducible delivery"); - } - - // VCS records have been found, force_repeatable or COE is enabled, so we don't care about integrity - // Replace the records in the file(s) - if (strlist_count(setup_files) && strlist_count(matches)) { - SYSDEBUG("Will replace %zu string(s) in %zu file(s)...", strlist_count(matches), strlist_count(setup_files)); - for (size_t f = 0; f < strlist_count(setup_files); f++) { - const char *setup_file = strlist_item(setup_files, f); - for (size_t m = 0; m < strlist_count(matches); m++) { - const char *match = strlist_item(matches, m); - - // copy the original match string - char *replacement = strdup(match); - if (!replacement) { - SYSERROR("unable to allocate bytes for replacement value"); - exit(1); - } - - // Truncate the replacement string at the first space character or @ symbol - char *stop = strpbrk(replacement, " @"); - if (stop) { - *stop = '\0'; - SYSINFO("%s: replacing '%s' with '%s'", setup_file, match, replacement); - if (file_replace_text(setup_file, match, replacement, 0)) { - SYSERROR("%s: replacement failed", setup_file); - exit(1); - } - } - guard_free(replacement); - } - } - } - } - guard_strlist_free(&setup_files); - guard_strlist_free(&matches); + delivery_autoresolve_vcs_urls("."); char *cmd = calloc(strlen(test->script) + STASIS_BUFSIZ, sizeof(*cmd)); if (!cmd) { -- cgit