镜像自地址
https://github.com/JGZYES/ParlzPackageManger.git
已同步 2026-09-11 05:42:44 +08:00
diag: PMM_DEBUG logging in http_get/curl_capture/install_from_registry to trace Linux mirror lookup
这个提交包含在:
+6
@@ -45,6 +45,7 @@ static char *run_capture(const char *cmd, size_t *out_len) {
|
|||||||
if (n == 0) break;
|
if (n == 0) break;
|
||||||
}
|
}
|
||||||
int rc = PMM_PCLOSE(f);
|
int rc = PMM_PCLOSE(f);
|
||||||
|
if (getenv("PMM_DEBUG")) fprintf(stderr, "[http] pclose rc=%d len=%zu\n", rc, len);
|
||||||
if (rc != 0 && len == 0) { free(buf); return NULL; }
|
if (rc != 0 && len == 0) { free(buf); return NULL; }
|
||||||
if (out_len) *out_len = len;
|
if (out_len) *out_len = len;
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
@@ -66,6 +67,7 @@ static char *curl_capture(const char *args, const char *url, size_t *out_len) {
|
|||||||
}
|
}
|
||||||
*p++ = '"';
|
*p++ = '"';
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
if (getenv("PMM_DEBUG")) fprintf(stderr, "[http] cmd: %s\n", cmd);
|
||||||
char *res = run_capture(cmd, out_len);
|
char *res = run_capture(cmd, out_len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
return res;
|
return res;
|
||||||
@@ -75,7 +77,10 @@ char *http_get(const char *url, int *status) {
|
|||||||
/* The status marker has NO backslash/newline, so it's immune to shell
|
/* The status marker has NO backslash/newline, so it's immune to shell
|
||||||
* interpretation differences: body + "__PMM_HTTP_<code>" */
|
* interpretation differences: body + "__PMM_HTTP_<code>" */
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
if (getenv("PMM_DEBUG")) fprintf(stderr, "[http] GET %s\n", url);
|
||||||
char *body = curl_capture("-sSL --max-time 60 -w __PMM_HTTP_%{http_code}", url, &len);
|
char *body = curl_capture("-sSL --max-time 60 -w __PMM_HTTP_%{http_code}", url, &len);
|
||||||
|
if (getenv("PMM_DEBUG")) fprintf(stderr, "[http] captured len=%zu head=%.60s\n",
|
||||||
|
body ? len : 0, body ? body : "(null)");
|
||||||
if (!body) return NULL;
|
if (!body) return NULL;
|
||||||
/* find the LAST marker occurrence, take the digits after it */
|
/* find the LAST marker occurrence, take the digits after it */
|
||||||
const char *mk = "__PMM_HTTP_";
|
const char *mk = "__PMM_HTTP_";
|
||||||
@@ -91,6 +96,7 @@ char *http_get(const char *url, int *status) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (status) *status = code;
|
if (status) *status = code;
|
||||||
|
if (getenv("PMM_DEBUG")) fprintf(stderr, "[http] status=%d\n", code);
|
||||||
} else {
|
} else {
|
||||||
/* no marker (some curl/quirk): keep body, status unknown -> later logic
|
/* no marker (some curl/quirk): keep body, status unknown -> later logic
|
||||||
* in install accepts non-404 bodies */
|
* in install accepts non-404 bodies */
|
||||||
|
|||||||
@@ -357,6 +357,8 @@ int install_from_registry(const char *name, const char *spec, const char *mirror
|
|||||||
snprintf(url, sizeof(url), "%s/%s.json", bases[i], name);
|
snprintf(url, sizeof(url), "%s/%s.json", bases[i], name);
|
||||||
printf("pmm: looking up %s in mirror %s\n", name, bases[i]);
|
printf("pmm: looking up %s in mirror %s\n", name, bases[i]);
|
||||||
body = http_get(url, &status);
|
body = http_get(url, &status);
|
||||||
|
if (getenv("PMM_DEBUG")) fprintf(stderr, "[reg] %s -> body=%s status=%d\n",
|
||||||
|
bases[i], body ? "set" : "NULL", status);
|
||||||
/* accept any body that isn't an explicit not-found/server error; some
|
/* accept any body that isn't an explicit not-found/server error; some
|
||||||
* curl builds don't emit the status marker the way we expect, so a
|
* curl builds don't emit the status marker the way we expect, so a
|
||||||
* non-NULL body with an indeterminate status should still be parsed */
|
* non-NULL body with an indeterminate status should still be parsed */
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户