tziyi1998 on X asked for Scoop and winget. magpie-releases now carries a Scoop bucket and winget manifests beside the Homebrew tap; a magpie they installed has to leave updating to them, as a Homebrew one does, or their next update puts back the version they hold. PackagedBy now knows Windows: Scoop's apps\<name>\<version> (or its current junction) with the scoop-install.json and scoop-manifest.json it writes there (install.json and manifest.json before Scoop 0.6), and winget's WinGet\Packages\<id>_<source> (_Microsoft.Winget.Source_… from the community repository, __DefaultSource from a local manifest). Name and Command give "Scoop" / `scoop update <name>` and `winget upgrade --id <id>`; the CLI, serve and the GUI already say p.Say() for a packaged binary, and the GUI's existing string carries it in every language. update.Executable failed on Scoop's junction: Go's EvalSymlinks says "The system cannot find the path specified" there, so the packaged check was skipped and `magpie update` failed with that error. It now keeps the path the binary was started from when the links can't be resolved, as shortcut, autostart, appdir and daemon already do. Run, at 23c03c6ee (this change rebased onb400566f9): - xiaomi-gpu (Windows 11, Go 1.26.8): go test ./internal/update/: all new tests pass; TestPackagedByDpkg red, the same on main (#4603). TestScoopJunctionStillPackaged makes a real junction with mklink /J. go vet ./internal/update/ ./internal/cli/ ./internal/gui/ ok; GOOS=linux and GOOS=darwin go vet -tags nogui of update and cli ok. - Broken by hand: resolved() returning "" on failure (the old error) turns TestScoopJunctionStillPackaged and TestResolvedKeepsUnresolvablePath red. - Real Scoop 0.6.0 in a sandbox -ScoopDir with the bucket from magpie-releases: this branch's CLI (as 0.1.4477) in apps\magpie\current says "this magpie was installed with Scoop (package magpie), which updates it, not magpie: scoop update magpie" and leaves the file unchanged; the same binary in a plain folder still offers the update. - Real winget 1.29, winget install --manifest yetone.Magpie.CLI: the binary in its package folder says "installed with winget … winget upgrade magpie" (the folder was __DefaultSource, now read as the id too). Uninstalled; LocalManifestFiles turned back off. - mote (macOS): gofmt; go test ./internal/update/ ok; ./internal/cli/ red in TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr, TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and TestUpdateFindsAMagpieThatWroteNoRecord, red the same at origin/mainf1e2ada0fon mote and on Windows (open issues, e.g. #6223). Windows also has TestLibraryProjectCmd red on main (#7119, filed now). Not run: the full ./... suite. mote was at load 28 with another session's full and GUI suites, WSL at load 50 with a GUI suite, and mica ran out of disk partway (its run tested nothing). Not tried: the GUI app under Scoop or winget, arm64.
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package update
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/proc"
|
|
)
|
|
|
|
// Scoop runs an app from apps\<name>\current, a junction to the version
|
|
// folder, and Go's EvalSymlinks fails on it. The binary there is still
|
|
// judged as Scoop's, so `magpie update` names `scoop update` rather than
|
|
// failing with "The system cannot find the path specified".
|
|
func TestScoopJunctionStillPackaged(t *testing.T) {
|
|
root := filepath.Join(t.TempDir(), "scoop")
|
|
ver := filepath.Join(root, "apps", "magpie", "0.1.4478")
|
|
writeFile(t, filepath.Join(ver, "magpie.exe"), "MZ")
|
|
writeFile(t, filepath.Join(ver, "scoop-install.json"), `{"bucket":"magpie"}`)
|
|
writeFile(t, filepath.Join(ver, "scoop-manifest.json"), `{"version":"0.1.4478"}`)
|
|
cur := filepath.Join(root, "apps", "magpie", "current")
|
|
if out, err := proc.Command("cmd", "/c", "mklink", "/J", cur, ver).CombinedOutput(); err != nil {
|
|
t.Fatalf("mklink /J: %v %s", err, out)
|
|
}
|
|
exe := resolved(filepath.Join(cur, "magpie.exe"))
|
|
p := PackagedBy(exe)
|
|
if p == nil || p.Manager != "scoop" || p.Package != "magpie" {
|
|
t.Fatalf("PackagedBy(%q) = %+v", exe, p)
|
|
}
|
|
}
|