Repository navigation
feat: support building modctl for Windows - #705
NopeCharon wants to merge 2 commits into
Conversation
|
Thanks for working on this. The Linux/macOS side looks like a pure refactor to me, no behaviour change. The Lint failure isn't from this PR. golangci-lint v2.4 panics on the Go 1.26 runner, and that was fixed on main in #716. Could you rebase? The new job pins setup-go v7.0.0 while main is on v7.1.0 now, so that can be aligned at the same time. On Windows One thing outside "it compiles": It would also be nice to run the |
`GOOS=windows GOARCH=amd64 go build ./...` failed because several packages relied on Unix-only APIs or on platform constants that were only defined for Linux and macOS: - pkg/version: `platform` was only declared in platform_linux.go and platform_darwin.go. Use runtime.GOOS instead, which reports the same values on Linux and macOS and works on every other platform. - pkg/xattr: Get/Set call unix.Getxattr/unix.Setxattr. Move them to xattr_unix.go (linux || darwin) and add a stub for other platforms that returns an error wrapping errors.ErrUnsupported. Callers in pkg/codec already treat xattr errors as a cache miss and as a best-effort failure, so extraction keeps working without the metadata cache. - pkg/diskspace: split the statfs query out of Check into availableSpace, implemented with unix.Statfs on Linux/macOS and with windows.GetDiskFreeSpaceEx on Windows (honoring per-user quotas), so the build/pull disk space pre-check now runs natively on Windows instead of being skipped. The no-op stub remains for other platforms. - pkg/backend/build: getFileMetadata asserted *syscall.Stat_t, which does not exist on Windows. Move the UID/GID lookup into fileOwner, implemented for unix and returning zero IDs elsewhere. The test now derives the expected owner per platform as well. - cmd/login: terminal.ReadPassword(syscall.Stdin) does not compile on Windows, where syscall.Stdin is a Handle. Use int(os.Stdin.Fd()). Add a CI job that cross-compiles and vets the module (including tests) for windows/amd64 to prevent regressions. Fixes modelpack#520 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
|
Rebased onto main and bumped the new job to setup-go v7.1.0. |
2e4c443 to
a3976bd
Compare
Problem
GOOS=windows GOARCH=amd64 go build ./...fails onmain:Also, the disk space pre-check added in #471 is only a no-op stub on Windows.
Fixes #520
Changes
CheckintoavailableSpace. It usesunix.Statfson Linux/macOS (same logic as before, overflow cap included) andwindows.GetDiskFreeSpaceExon Windows, which honors per-user quotas. The pre-check now runs natively on Windows. The no-op stub stays for other platforms.Get/Settoxattr_unix.go(linux || darwin). On other platforms both return an error wrappingerrors.ErrUnsupported. Callers inpkg/codecalready treat xattr errors as a cache miss and as a best-effort failure. On Windows, extraction still works but skips the xattr metadata cache, so files are always rewritten. NTFS alternate data streams could be a follow-up if needed.Platformnow usesruntime.GOOSinstead of per-OSplatformconstants. It prints the same values on Linux and macOS.fileOwner(unixvs.!unix). Platforms without numeric owners return zero IDs. The test helper that derives the expected owner is split the same way, so the test package also compiles on Windows.terminal.ReadPassword(int(os.Stdin.Fd()))works on both Unix and Windows.Cross Compile (windows/amd64)job inci.ymlthat runsgo build ./...andgo vet ./...(test files included) withGOOS=windows CGO_ENABLED=0, to prevent regressions.Tests
go test -tags static,system_libgit2 ./...passes on linux/arm64.pkg/diskspace,pkg/xattr,pkg/backend/buildandcmdtests also pass on darwin/arm64.GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./... && go vet ./...passes.GOOS=freebsdvet passes too.golangci-lint run(v2.4) reports 0 issues.