repo: accept bare (no-extension) binaries as Linux/macOS release assets (e.g. 'pmm' ELF); install_file chmod +x them

这个提交包含在:
JGZYES
2026-09-01 18:28:09 +08:00
父节点 d9197ef719
当前提交 6a93e16e24
修改 2 个文件,包含 14 行新增2 行删除
+8 -2
查看文件
@@ -223,8 +223,14 @@ int install_file(const char *url, const char *name) {
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"\"%s\" /S /VERYSILENT /quiet --silent 2>nul", pwin); "\"%s\" /S /VERYSILENT /quiet --silent 2>nul", pwin);
} else { } else {
/* unknown type for this OS: just leave in cache and copy if a single file */ /* unknown type for this OS: copy the single file into the install dir;
snprintf(cmd, sizeof(cmd), "cp -f \"%s\" \"%s/\" 2>/dev/null || true", path, dest); * on Linux/macOS make it executable (bare ELF/script releases). */
if (os == OS_LINUX || os == OS_MACOS)
snprintf(cmd, sizeof(cmd),
"cp -f \"%s\" \"%s/\" 2>/dev/null && chmod +x \"%s/%s\" 2>/dev/null || true",
path, dest, dest, bname);
else
snprintf(cmd, sizeof(cmd), "cp -f \"%s\" \"%s/\" 2>/dev/null || true", path, dest);
} }
printf("pmm: installing %s ...\n", bname); printf("pmm: installing %s ...\n", bname);
+6
查看文件
@@ -167,6 +167,7 @@ static int has_ext(const char *name, const char *ext) {
return 1; return 1;
} }
static int asset_is_junk(const char *name);
int asset_matches_os(const char *filename, PmmOS os) { int asset_matches_os(const char *filename, PmmOS os) {
static const char *win_exts[] = { ".exe", ".msi", ".zip", ".7z", NULL }; static const char *win_exts[] = { ".exe", ".msi", ".zip", ".7z", NULL };
static const char *linux_exts[] = { ".deb", ".rpm", ".appimage", ".tar.gz", ".tgz", ".tar.xz", ".tar.bz2", ".pkg.tar.zst", NULL }; static const char *linux_exts[] = { ".deb", ".rpm", ".appimage", ".tar.gz", ".tgz", ".tar.xz", ".tar.bz2", ".pkg.tar.zst", NULL };
@@ -180,6 +181,11 @@ int asset_matches_os(const char *filename, PmmOS os) {
} }
for (int i = 0; exts[i]; i++) for (int i = 0; exts[i]; i++)
if (has_ext(filename, exts[i])) return 1; if (has_ext(filename, exts[i])) return 1;
/* A bare (no-dot) binary counts on Linux/macOS — e.g. a release asset named
* "pmm" that is an ELF. Skip obvious junk like README/LICENCE/checksums. */
if ((os == OS_LINUX || os == OS_MACOS) && strchr(filename, '.') == NULL
&& !asset_is_junk(filename))
return 1;
return 0; return 0;
} }