Setting Up Host Environment for Cross Architecture Target Image Composition#349
Setting Up Host Environment for Cross Architecture Target Image Composition#349
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds cross-architecture build support by setting up the host environment to handle different target architectures. The implementation detects the host OS distribution, installs necessary emulation tools (qemu-user-static), and configures binfmt_misc for cross-architecture execution.
Changes:
- Added OS distribution detection functionality with support for multiple Linux distributions and package managers
- Implemented qemu-user-static installation logic for cross-architecture emulation
- Created comprehensive host environment setup for various architecture combinations (x86_64, aarch64, armv7, riscv64, ppc64le, s390x, mips64)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/utils/system/system.go | Added OS distribution detection types and functions, qemu-user-static installation, and commented-out initial SetupHostEnv implementation |
| internal/utils/system/hostenv.go | New file implementing cross-architecture host environment setup with architecture-specific handlers and emulation configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func contains(s, substr string) bool { | ||
| return len(s) > 0 && len(substr) > 0 && | ||
| (s == substr || len(s) > len(substr) && | ||
| (s[0:len(substr)] == substr || | ||
| s[len(s)-len(substr):] == substr || | ||
| findSubstring(s, substr))) | ||
| } |
There was a problem hiding this comment.
The contains function reimplements string matching logic that is already available in Go's standard library. Use strings.Contains(s, substr) instead, which is more efficient, readable, and well-tested. This would also eliminate the need for the findSubstring helper function.
| func findSubstring(s, substr string) bool { | ||
| for i := 0; i <= len(s)-len(substr); i++ { | ||
| if s[i:i+len(substr)] == substr { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } |
There was a problem hiding this comment.
This helper function is unnecessary and can be removed if contains is replaced with strings.Contains from the standard library. The current implementation duplicates functionality that is already optimized in the standard library.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Merge Checklist
All boxes should be checked before merging the PR
Description
Any Newly Introduced Dependencies
How Has This Been Tested?