Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

feed_tool: a Linux or Mac package packed on Windows keeps its programs executable (mode from the file header); test

Niko12211b8e88b9e521
diff --git a/packaging/feed_tool.py b/packaging/feed_tool.py
index 4be335c9b..706622434 100644
--- a/packaging/feed_tool.py
+++ b/packaging/feed_tool.py
@@ -94,11 +94,25 @@ def sign_package(folder: Path, key: dict) -> str:
return _sha256(path)
+_NATIVE_MAGIC = (b"\x7fELF", b"\xcf\xfa\xed\xfe", b"\xca\xfe\xba\xbe", b"\xfe\xed\xfa\xcf", b"#!") # ELF, Mach-O (64-bit, fat), script
+
+
+def _is_native_executable(path: Path) -> bool:
+ try:
+ with path.open("rb") as stream:
+ head = stream.read(4)
+ except OSError:
+ return False
+ return any(head.startswith(m) for m in _NATIVE_MAGIC)
+
+
def _mode(path: Path, rel: str, entrypoint: str | None) -> int:
if rel == entrypoint:
return 0o755
try:
- return 0o755 if path.stat().st_mode & stat.S_IXUSR and os.name != "nt" else 0o644
+ if os.name == "nt": # a Linux / Mac package packed on Windows has no execute bits: take them from the file's own header
+ return 0o755 if _is_native_executable(path) else 0o644
+ return 0o755 if path.stat().st_mode & stat.S_IXUSR else 0o644
except OSError:
return 0o644
diff --git a/tests/terminal/test_release_matrix.py b/tests/terminal/test_release_matrix.py
index 00f2f57f0..6b086f7f7 100644
--- a/tests/terminal/test_release_matrix.py
+++ b/tests/terminal/test_release_matrix.py
@@ -3,10 +3,18 @@ packages' engine-component.json), and what `feed.select_engine` hands each kind
reach every installer variant by card, so the app update can stay engine-less (tauri.update.conf.json)."""
from __future__ import annotations
+import os
+import sys
+import tarfile
+import tempfile
import unittest
+from pathlib import Path
from strata_control import feed as feedmod
+sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "packaging"))
+import feed_tool # noqa: E402
+
V = "0.1.45.3"
SM_NEW = ("sm_75", "sm_86", "sm_89", "sm_120", "compute_120") # the CUDA 13 packages
SM_OLD = ("sm_60", "sm_61", "sm_70", "sm_75", "sm_80", "sm_86", "sm_89", "compute_89") # the CUDA 12 packages (Pascal and Volta)
@@ -83,5 +91,24 @@ class ReleaseSelection(unittest.TestCase):
self.assertEqual(self.pick(pc("macos-arm64", "metal"))[0], ("macos-arm64", "metal", ""))
+class PackedOnWindows(unittest.TestCase):
+ def test_programs_are_recognised_by_their_header_so_a_linux_package_packed_on_windows_keeps_them_executable(self):
+ with tempfile.TemporaryDirectory() as t:
+ root = Path(t)
+ (root / "strata-vision").write_bytes(b"\x7fELF\x02\x01" + bytes(20))
+ (root / "libx.dylib").write_bytes(b"\xcf\xfa\xed\xfe" + bytes(20))
+ (root / "run.sh").write_bytes(b"#!/bin/sh\n")
+ (root / "BUILD.json").write_text("{}")
+ (root / "kernel.hsaco").write_bytes(b"\x00\x01\x02\x03")
+ names = ("strata-vision", "libx.dylib", "run.sh", "BUILD.json", "kernel.hsaco")
+ self.assertEqual([feed_tool._is_native_executable(root / n) for n in names], [True, True, True, False, False])
+ if os.name == "nt": # the owner's release PC: the archive is what matters
+ archive = root / "a.tar.gz"
+ feed_tool._write_archive([(n, root / n) for n in ("strata-vision", "BUILD.json")], archive, "tar.gz", None)
+ with tarfile.open(archive) as tar:
+ modes = {m.name: m.mode for m in tar.getmembers()}
+ self.assertEqual(modes, {"strata-vision": 0o755, "BUILD.json": 0o644})
+
+
if __name__ == "__main__":
unittest.main()