From e87371e8cabacb29144c5763cc55105e3bf622eb Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 4 Oct 2024 17:31:58 -0400 Subject: Do not truncate test->name --- src/delivery.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index a689db2..e8c3a28 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -220,7 +220,6 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { // Override test->version when a version is provided by the (pip|conda)_package list item guard_free(test->version); if (spec_begin && spec_end) { - *spec_begin = '\0'; test->version = strdup(spec_end); } else { // There are too many possible default branches nowadays: master, main, develop, xyz, etc. -- cgit From 4ea0e522551b8d77ed79df9e7edd6ec891019d19 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 4 Oct 2024 17:32:57 -0400 Subject: Record the package name in a separate variable --- src/delivery.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index e8c3a28..dfe9209 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -191,19 +191,25 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { // no data continue; } - msg(STASIS_MSG_L3, "package '%s': ", name); // Compile a list of packages that are *also* to be tested. char *version; char *spec_begin = strpbrk(name, "@~=<>!"); char *spec_end = spec_begin; + char package_name[255] = {0}; + if (spec_end) { // A version is present in the package name. Jump past operator(s). while (*spec_end != '\0' && !isalnum(*spec_end)) { spec_end++; } + strncpy(package_name, name, spec_begin - name); + } else { + strncpy(package_name, name, sizeof(package_name) - 1); } + msg(STASIS_MSG_L3, "package '%s': ", package_name); + // When spec is present in name, set tests->version to the version detected in the name for (size_t x = 0; x < sizeof(ctx->tests) / sizeof(ctx->tests[0]) && ctx->tests[x].name != NULL; x++) { struct Test *test = &ctx->tests[x]; -- cgit From ace6fe586ff30be57e708f81489b120204d6dd62 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 4 Oct 2024 17:35:12 -0400 Subject: Use nametmp instead of test->name (i.e. name) --- src/delivery.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index dfe9209..563ef8f 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -235,8 +235,8 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { version = test->version; // Is the list item a git+schema:// URL? - if (strstr(name, "git+") && strstr(name, "://")) { - char *xrepo = strstr(name, "+"); + if (strstr(nametmp, "git+") && strstr(nametmp, "://")) { + char *xrepo = strstr(nametmp, "+"); if (xrepo) { xrepo++; guard_free(test->repository); @@ -244,7 +244,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { xrepo = NULL; } // Extract the name of the package - char *xbasename = path_basename(name); + char *xbasename = path_basename(nametmp); if (xbasename) { // Replace the git+schema:// URL with the package name strlist_set(&dataptr, i, xbasename); @@ -252,9 +252,11 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } } - if (DEFER_PIP == type && pip_index_provides(PYPI_INDEX_DEFAULT, name, version)) { - fprintf(stderr, "(%s present on index %s): ", version, PYPI_INDEX_DEFAULT); - ignore_pkg = 0; + ignore_pkg = 0; + if (DEFER_PIP == type && pip_index_provides(PYPI_INDEX_DEFAULT, nametmp, version)) { + fprintf(stderr, "(%s provided by index %s): ", version, PYPI_INDEX_DEFAULT); + } else if (DEFER_CONDA == type && conda_provides(nametmp)) { + fprintf(stderr, "(%s provided by conda channel): ", version); } else { ignore_pkg = 1; } @@ -263,12 +265,6 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } if (ignore_pkg) { - char build_at[PATH_MAX]; - if (DEFER_CONDA == type) { - sprintf(build_at, "%s=%s", name, version); - name = build_at; - } - printf("BUILD FOR HOST\n"); strlist_append(&deferred, name); } else { -- cgit From 82d3840534d10050bbcd70d42e13d2659251431d Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 7 Oct 2024 12:47:18 -0400 Subject: Fail immediately when an unknown package manager "type" is discovered --- src/delivery.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index 563ef8f..b0918c8 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -178,6 +178,9 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { dataptr = ctx->conda.pip_packages; deferred = ctx->conda.pip_packages_defer; strcpy(mode, "pip"); + } else { + SYSERROR("BUG: type %d does not map to a supported package manager!\n", type); + exit(1); } msg(STASIS_MSG_L2, "Filtering %s packages by test definition...\n", mode); -- cgit From 54a4bd4ee9a608f8a8220db9e2954f33fc68ac5a Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 7 Oct 2024 12:47:53 -0400 Subject: Rename ignore_pkg variable to build_for_host because it was plain confusing to look at it --- src/delivery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index b0918c8..6c7a675 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -187,7 +187,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { struct StrList *filtered = NULL; filtered = strlist_init(); for (size_t i = 0; i < strlist_count(dataptr); i++) { - int ignore_pkg = 0; + int build_for_host = 0; name = strlist_item(dataptr, i); if (!strlen(name) || isblank(*name) || isspace(*name)) { -- cgit From 4b6fd13d290f9de731589f936c304c7bc74e6b88 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 7 Oct 2024 12:50:30 -0400 Subject: Don't bother extracting the version from the spec --- src/delivery.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index 6c7a675..e7dfece 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -196,7 +196,6 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } // Compile a list of packages that are *also* to be tested. - char *version; char *spec_begin = strpbrk(name, "@~=<>!"); char *spec_end = spec_begin; char package_name[255] = {0}; @@ -216,9 +215,8 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { // When spec is present in name, set tests->version to the version detected in the name for (size_t x = 0; x < sizeof(ctx->tests) / sizeof(ctx->tests[0]) && ctx->tests[x].name != NULL; x++) { struct Test *test = &ctx->tests[x]; - version = NULL; - char nametmp[1024] = {0}; + if (spec_end != NULL && spec_begin != NULL) { strncpy(nametmp, name, spec_begin - name); } else { @@ -235,7 +233,6 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { // HEAD is a safe bet. test->version = strdup("HEAD"); } - version = test->version; // Is the list item a git+schema:// URL? if (strstr(nametmp, "git+") && strstr(nametmp, "://")) { -- cgit From 4d525473d1f2b4d02e29747a45d2a02ffcff4398 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 7 Oct 2024 12:52:03 -0400 Subject: Break down the existence check * These checks can fail due to external factors, so handle those first * Build the package for the host system the package isn't found in the index/channel * Change EXISTING to EXTERNAL to be more clear. The package exists... externally --- src/delivery.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index e7dfece..07e04c8 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -252,23 +252,36 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } } - ignore_pkg = 0; - if (DEFER_PIP == type && pip_index_provides(PYPI_INDEX_DEFAULT, nametmp, version)) { - fprintf(stderr, "(%s provided by index %s): ", version, PYPI_INDEX_DEFAULT); - } else if (DEFER_CONDA == type && conda_provides(nametmp)) { - fprintf(stderr, "(%s provided by conda channel): ", version); + int upstream_exists = 0; + if (DEFER_PIP == type) { + upstream_exists = pip_index_provides(PYPI_INDEX_DEFAULT, name); + } else if (DEFER_CONDA == type) { + upstream_exists = conda_provides(name); } else { - ignore_pkg = 1; + fprintf(stderr, "\nUnknown package type: %d\n", type); + exit(1); } + + if (upstream_exists < 0) { + fprintf(stderr, "%s's existence command failed for '%s'\n" + "(This may be due to a network/firewall issue!)\n", mode, name); + exit(1); + } + if (!upstream_exists) { + build_for_host = 1; + } else { + build_for_host = 0; + } + break; } } - if (ignore_pkg) { + if (build_for_host) { printf("BUILD FOR HOST\n"); strlist_append(&deferred, name); } else { - printf("USE EXISTING\n"); + printf("USE EXTERNAL\n"); strlist_append(&filtered, name); } } -- cgit