go-hmos-installer

command module
v0.0.0-...-30d840a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

README

go-hmos installer

Versioned commands for the experimental OpenHarmony Go fork, following the golang.org/dl/go1.x / gotip install-then-download pattern. They build a fixed source commit on your development computer without replacing your regular Go installation.

go1.27.2-hmos builds the pinned development snapshot b637b8617624655906b737977f50de5280bf7f65. The resulting toolchain identifies itself as go1.27.2-hmos-devel. The command name is a version selector, not an official release tag. There is no official go-hmos release or prebuilt binary for this snapshot. This remains an experimental OpenHarmony port, with no claim of commercial HarmonyOS NEXT device compatibility.

Go 1.27.4 versioned command

The new, independently named go1.27.4-hmos launcher is pinned to source 81bad8b625b9c845961010ea2af776a3cb426b4a. Its toolchain reports go1.27.4-hmos-devel, never the official Go version name. It uses its own ~/sdk/go1.27.4-hmos/ directory (or an isolated subdirectory under GOHMOS_SDK_HOME) and does not replace go, go1.27.4, or the existing go1.27.2-hmos command.

Install and build the pinned source with:

go install github.com/ZxillyFork/go-hmos-installer/go1.27.4-hmos@latest
go1.27.4-hmos download
go1.27.4-hmos --version

This launcher builds the experimental OpenHarmony fork from source. Linux binary prereleases are available from go-hmos-build. Host/toolchain checks, native SDK linking and device execution are separate validation stages; SDK linking does not prove device execution.

Previous versioned command — Go 1.27.2

The section below documents the retained 1.27.2 command. It remains pinned at its historical revision and is not silently upgraded.

Install official Go 1.24.6 or later and Git first. Linux/macOS also need bash. No host C compiler is required for the installer. In a terminal or PowerShell:

go install github.com/ZxillyFork/go-hmos-installer/go1.27.2-hmos@latest
go1.27.2-hmos download
go1.27.2-hmos version

The first command installs the small launcher in GOBIN (normally the bin directory of GOPATH, usually $HOME/go/bin). That directory must be on PATH; otherwise invoke the launcher by its full path.

The fork's launcher is named go1.27.2-hmos, so it can coexist in the same GOBIN with the official golang.org/dl/go1.27.2 launcher named go1.27.2. Its SDK storage is also separate: ~/sdk/go1.27.2-hmos rather than the official wrapper's ~/sdk/go1.27.2 directory.

If you installed this fork's earlier go1.27.2 command, switch to go1.27.2-hmos. The new command reuses the existing fork SDK at ~/sdk/go1.27.2-hmos; it does not remove or replace the old launcher. You can inspect an existing launcher with go version -m /path/to/go1.27.2 (add .exe on Windows) to identify which module provided it. To restore an official launcher that the earlier command replaced, run go install golang.org/dl/go1.27.2@latest in the same GOBIN. Historical installer revisions remain unchanged, but the current module no longer provides the fork's old go1.27.2 package.

For the default launcher location:

# Linux/macOS
"$HOME/go/bin/go1.27.2-hmos" download
"$HOME/go/bin/go1.27.2-hmos" version
# Windows PowerShell
& "$HOME/go/bin/go1.27.2-hmos.exe" download
& "$HOME/go/bin/go1.27.2-hmos.exe" version

download fetches the fixed source and compiles Go, which can take several minutes. It does not download a prebuilt SDK. Running it again reuses the completed build. It accepts no branch, commit, CL number, or other arguments.

Go installs the launcher using its normal module/checksum mechanisms. To pin that launcher revision too, replace latest with a reviewed full installer commit SHA from this repository. @latest updates the launcher implementation; the go1.27.2-hmos command remains tied to its embedded source commit. A future toolchain version gets a separate command package and executable.

Use and storage

Use the versioned command just like go, including install:

go1.27.2-hmos help
go1.27.2-hmos env GOROOT GOVERSION
go1.27.2-hmos tool dist list
go1.27.2-hmos build ./...
go1.27.2-hmos test ./...
go1.27.2-hmos install example.org/tool@v1.2.3

The final example is a placeholder; substitute the package you want to install. download and --version are launcher commands. --version prints the command, experimental toolchain identity, and source commit without requiring a download. All other arguments, including no arguments and help, go to the built Go tool. Its stdin, stdout, stderr, and exit status are forwarded.

Each version has its own directory under ~/sdk, for example ~/sdk/go1.27.2-hmos/toolchains/<source-commit>-<host-os>-<host-arch>. Set GOHMOS_SDK_HOME to a different parent SDK directory if needed; each command still gets its own command-named subdirectory. Use the same setting for download and subsequent commands. A versioned command does not use the legacy GOHMOS_HOME variable or current.json selection, and cannot select another version's cached toolchain.

Target settings such as GOOS, GOARCH, CGO_ENABLED, and CC are preserved when forwarding. For the child process, the launcher sets GOROOT to its pinned toolchain, adds that toolchain's bin to the front of PATH for nested Go commands, and sets GOTOOLCHAIN=local. This prevents automatic switching to a stock Go toolchain that lacks the OpenHarmony port. Installation never changes your persistent PATH, replaces a command named go, or runs go env -w.

During source bootstrap, target/compiler/Go configuration is isolated, cgo is disabled, and build concurrency is limited to four. The build is completed in a temporary sibling directory and atomically moved into place only after both OpenHarmony targets and the expected toolchain identity are verified. Failed builds leave completed toolchains intact. Concurrent downloads fail with a lock message. If a forcibly terminated process leaves an empty .install-lock directory, check that no installer is running before removing it and retrying. Unfinished .build-* directories can be removed when no installer is running.

The source revision is verified against Git's fetched commit ID. This pins content; it is not a code-signing or device-compatibility guarantee. Git uses normal HTTPS and your existing network/proxy configuration. No token is needed for the public repository, and no credentials are saved by this installer.

Legacy root command

The original root entry remains available for compatibility:

go run github.com/ZxillyFork/go-hmos-installer@latest install

It retains source commit 50a9db343e53ec569374c328998b3ffbada8f850 (go1.27.1-hmos-devel), the gohmos launcher, and its original behavior: install / download, --home, GOHMOS_HOME, root, --version, and the selection in ~/sdk/go-hmos/current.json. The installed launcher discovers a custom home beside its own bin directory. It forwards other Go arguments with GOTOOLCHAIN=local.

Installing or using go1.27.2-hmos does not upgrade that legacy toolchain or change its selection. Use the new versioned command explicitly for the newer source. Future versioned commands can coexist in the same launcher directory.

OpenHarmony SDK is still required

Installation produces host Go tools. Cross-linking OpenHarmony executables or native libraries still requires the official SDK's matching Clang and sysroot, CGO_ENABLED=1, and external linking. The target is GOOS=openharmony with GOARCH=arm64 or amd64; the SDK triples are aarch64-linux-ohos and x86_64-linux-ohos.

Read the pinned port documentation and implementation and verification status before building for devices. This installer does not download the SDK, deploy to a phone, or establish commercial HarmonyOS NEXT compatibility.

Verification

go test ./...
go vet ./...
# Optional fresh builds of both fixed source versions:
GOHMOS_TEST_REPOSITORY=https://github.com/ZxillyFork/go-hmos.git \
  go test ./internal/toolchain -run '^TestReal(Version)?Installation$' -timeout 65m -v

GOHMOS_TEST_REPOSITORY can instead point to a local checkout containing the pinned commits. Tests build real command packages, including the exact go install ...@latest form against an isolated local module proxy; nothing is published by that test. Unit/subprocess coverage checks the legacy pin, separate state, cached downloads, forwarding, environment isolation, and exit codes.

CI is configured for Linux, macOS, and Windows source builds, plus Go 1.24.6 compatibility. Each real install test checks paths with spaces, relocation, a cached install, a host program, and the installed command. The new version's test also checks its exact identity and runs the installed fork's selected os.Root regressions in the standard library module. On Windows it requires explicit passes for the dangling-junction cases covering CVE-2026-56857. Host tests do not substitute for OpenHarmony SDK linking or device execution.

Documentation

Overview

The root command preserves the original gohmos installer and source pin.

Directories

Path Synopsis
The go1.27.2-hmos command builds and runs an experimental OpenHarmony Go fork.
The go1.27.2-hmos command builds and runs an experimental OpenHarmony Go fork.
The go1.27.4-hmos command builds an experimental OpenHarmony Go fork.
The go1.27.4-hmos command builds an experimental OpenHarmony Go fork.
internal
toolchain
Package toolchain implements the legacy and versioned OpenHarmony Go commands.
Package toolchain implements the legacy and versioned OpenHarmony Go commands.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL