Skip to content

Detect HarmonyOS/OpenHarmony as the openharmony RID - #752

Open
springmin wants to merge 2 commits into
dotnet:mainfrom
springmin:upstream/openharmony-os-detection
Open

springmin wants to merge 2 commits into
dotnet:mainfrom
springmin:upstream/openharmony-os-detection

Conversation

@springmin

Copy link
Copy Markdown

Summary

dotnet-install.sh cannot be used on HarmonyOS/OpenHarmony today because OS detection fails before any download happens:

  • uname -s reports HarmonyOS on HarmonyOS/OpenHarmony devices, not Linux, so get_current_os_name exits with OS name could not be detected: UName = HarmonyOS.
  • /etc/os-release is typically absent on these devices, so the distro-detection path cannot help.
  • The portable RID for the platform is openharmony-arm64 (arm64 only today).

This change adds detection and the corresponding --os value only. It does not add a feed, assets, code signing or packaging; those remain downstream for now.

Changes

  • get_current_os_name: recognize HarmonyOS, OpenHarmony and OHOS; for Linux, recognize ID/ID_LIKE containing openharmony/ohos (covers OpenHarmony systems that report Linux).
  • get_normalized_os: accept openharmony and map harmonyos/ohos to it, so the name matches the RID components the script composes.
  • Update the --os help text and the unsupported-value error.
  • get_machine_architecture: only query getconf LONG_BIT when getconf exists (minimal images may not ship it).
  • Tests: dry-run cases that put a uname shim on PATH and serve a file:// feed, asserting dotnet-sdk-<version>-openharmony-arm64.tar.gz for both the detected OS and the --os aliases.

Testing

Verified on a HarmonyOS device (aarch64) with the same shim/feed setup:

$ PATH=<shim>:$PATH bash src/dotnet-install.sh --dryrun -version 11.0.100 -azurefeed file://.../feed
dotnet-install: URL #0 - primary: .../Sdk/11.0.100/dotnet-sdk-11.0.100-openharmony-arm64.tar.gz
dotnet-install: Repeatable invocation: ... --os "openharmony"

The added xunit cases run in the Unix leg of the PR pipeline.

NOTE: AI-assisted.

`uname -s` reports `HarmonyOS` on HarmonyOS/OpenHarmony devices, which the
script does not recognize, and `/etc/os-release` may be absent. Detect it
before the generic Linux branch, also recognize `ID=openharmony`/`ohos` in
os-release, and accept `--os openharmony` (plus the `harmonyos`/`ohos`
aliases). Guard the `getconf LONG_BIT` probe used for aarch64.

Adds dry-run tests that put a `uname` shim on PATH and serve a file feed.
@springmin
springmin requested a review from a team as a code owner November 25, 2026 00:21
springmin added a commit to springmin/install-scripts-ohos that referenced this pull request Nov 25, 2026
- src/ohos-install-from-pins.sh installs the SDK pinned in a sdk-ohos
  versions.env through the shared installer, so both installers use the
  same download, checksum, extraction, signing and workload steps.
- tests/ohos: cover the wrapper and its refusal to install without a
  pinned digest (18 cases in total).
- docs/harmonyos.md: document the wrapper and link the detection-only
  upstream PR (dotnet#752).
springmin added a commit to springmin/runtime-ohos that referenced this pull request Nov 25, 2026
Add dotnet/install-scripts#752 (openharmony OS detection) to the
upstream-PR list and the new install-scripts-ohos fork to the sibling
repository table.
File.SetUnixFileMode is unsupported on Windows and the analyzer flags the
call site even though the test is skipped there. Guard it with
OperatingSystem.IsWindows().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant