Repository navigation
feat: support building modctl for Windows - #705
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
`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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.