From 6a93e16e2497081d671b109a2917bd4e5923c085 Mon Sep 17 00:00:00 2001 From: JGZYES Date: Tue, 1 Sep 2026 18:28:09 +0800 Subject: [PATCH] repo: accept bare (no-extension) binaries as Linux/macOS release assets (e.g. 'pmm' ELF); install_file chmod +x them --- src/install.c | 10 ++++++++-- src/repo.c | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/install.c b/src/install.c index 2817544..c743a1c 100644 --- a/src/install.c +++ b/src/install.c @@ -223,8 +223,14 @@ int install_file(const char *url, const char *name) { snprintf(cmd, sizeof(cmd), "\"%s\" /S /VERYSILENT /quiet --silent 2>nul", pwin); } else { - /* unknown type for this OS: just leave in cache and copy if a single file */ - snprintf(cmd, sizeof(cmd), "cp -f \"%s\" \"%s/\" 2>/dev/null || true", path, dest); + /* unknown type for this OS: copy the single file into the install dir; + * 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); diff --git a/src/repo.c b/src/repo.c index a3894ab..fcadbb9 100644 --- a/src/repo.c +++ b/src/repo.c @@ -167,6 +167,7 @@ static int has_ext(const char *name, const char *ext) { return 1; } +static int asset_is_junk(const char *name); int asset_matches_os(const char *filename, PmmOS os) { 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 }; @@ -180,6 +181,11 @@ int asset_matches_os(const char *filename, PmmOS os) { } for (int i = 0; exts[i]; i++) 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; }