Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tools/distribution-drafts/scoop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ Each install lands four payloads under Scoop's per-version app dir (`$dir`):
| `lucli-0.3.7.bat` | cybersonic/LuCLI release | `$dir\` |
| `sqlite-jdbc-3.49.1.0.jar` | Maven Central | `$dir\` |

The `post_install` PowerShell block emits a generated `$dir\wheels.cmd` wrapper.
That wrapper is what Scoop's `bin` directive shims onto PATH as `wheels`.
The `pre_install` PowerShell block emits a generated `$dir\wheels.cmd` wrapper.
That wrapper is what Scoop's `bin` directive shims onto PATH as `wheels`. We use
`pre_install` (not `post_install`) because Scoop's install order is
`pre_install` → `bin` shim creation → `post_install` — writing `wheels.cmd` in
`post_install` would fail the shim step with `Can't shim 'wheels.cmd': File
doesn't exist.` and abort the install before the wrapper is ever created.

The wrapper, on every invocation:

Expand Down Expand Up @@ -110,7 +114,7 @@ statements. To pull out the literal CMD content and review it:
python3 -c '
import json, re
m = json.load(open("tools/distribution-drafts/scoop/wheels-be.json"))
for stmt in m["post_install"]:
for stmt in m["pre_install"]:
mm = re.match(r"\$lines\.Add\(\x27(.*)\x27\)", stmt)
if mm:
print(mm.group(1).replace("\x27\x27", "\x27"))'
Expand Down
14 changes: 10 additions & 4 deletions tools/distribution-drafts/scoop/build-manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ def ps_quote_for_addcontent(line: str) -> str:
return "$lines.Add('" + line.replace("'", "''") + "')"


def build_post_install(channel: str) -> list[str]:
"""Generate the post_install PowerShell array for the given channel."""
def build_pre_install(channel: str) -> list[str]:
"""Generate the pre_install PowerShell array for the given channel.

Emitted as `pre_install` rather than `post_install` because Scoop creates the
`bin` shim after pre_install but before post_install. The wheels.cmd launcher
must exist at shim-creation time, otherwise the install aborts with
`Can't shim 'wheels.cmd': File doesn't exist.` and no further hooks run.
"""
lines = cmd_wrapper(channel)
return [
# Use the .NET List to avoid PowerShell's slow array-realloc pattern
Expand Down Expand Up @@ -183,7 +189,7 @@ def manifest_be() -> dict:
}
},
"bin": [["wheels.cmd", "wheels"]],
"post_install": build_post_install("bleeding-edge"),
"pre_install": build_pre_install("bleeding-edge"),
"checkver": {
"url": "https://api.github.com/repos/wheels-dev/wheels-snapshots/releases?per_page=1",
"jsonpath": "$[0].tag_name",
Expand Down Expand Up @@ -250,7 +256,7 @@ def manifest_stable() -> dict:
}
},
"bin": [["wheels.cmd", "wheels"]],
"post_install": build_post_install("stable"),
"pre_install": build_pre_install("stable"),
"checkver": {"github": "https://github.com/wheels-dev/wheels"},
"autoupdate": {
"architecture": {
Expand Down
6 changes: 3 additions & 3 deletions tools/distribution-drafts/scoop/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def info(msg: str) -> None:


def extract_cmd_lines(manifest: dict) -> list[str]:
"""Pull the literal CMD lines back out of the post_install array."""
"""Pull the literal CMD lines back out of the pre_install array."""
cmd_lines: list[str] = []
pattern = re.compile(r"^\$lines\.Add\('(.*)'\)$")
for stmt in manifest.get("post_install", []):
for stmt in manifest.get("pre_install", []):
m = pattern.match(stmt)
if m:
# PowerShell single-quote escape: '' -> '
Expand Down Expand Up @@ -107,7 +107,7 @@ def check_url_reachable(url: str, name: str) -> None:
def check_wrapper(name: str, m: dict) -> None:
cmd_lines = extract_cmd_lines(m)
if not cmd_lines:
fail(f"{name}: post_install emits no CMD wrapper lines")
fail(f"{name}: pre_install emits no CMD wrapper lines")
return

joined = "\n".join(cmd_lines)
Expand Down
2 changes: 1 addition & 1 deletion tools/distribution-drafts/scoop/wheels-be.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"wheels"
]
],
"post_install": [
"pre_install": [
"$lines = New-Object System.Collections.Generic.List[string]",
"$lines.Add('@echo off')",
"$lines.Add('setlocal enabledelayedexpansion')",
Expand Down
2 changes: 1 addition & 1 deletion tools/distribution-drafts/scoop/wheels.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"wheels"
]
],
"post_install": [
"pre_install": [
"$lines = New-Object System.Collections.Generic.List[string]",
"$lines.Add('@echo off')",
"$lines.Add('setlocal enabledelayedexpansion')",
Expand Down
Loading