Skip to content

Commit

Permalink
Add support for FreeBSD ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Jul 17, 2023
1 parent 6e970dd commit 27369a9
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 33 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,46 @@ jobs:
hardware: amd64
release: 13.2-RELEASE

- name: FreeBSD
architecture: ARM64
version: '12.4'
host: ubuntu-latest
# /home is symlinked to /usr/home. pwd will return the resolved path.
workDirectory: /usr/home/runner/work/action/action
uname:
hardware: arm64
release: 12.4-RELEASE

- name: FreeBSD
architecture: ARM64
version: '13.0'
host: ubuntu-latest
# /home is symlinked to /usr/home. pwd will return the resolved path.
workDirectory: /usr/home/runner/work/action/action
uname:
hardware: arm64
release: 13.0-RELEASE

- name: FreeBSD
architecture: ARM64
version: '13.1'
host: ubuntu-latest
# /home is symlinked to /usr/home. pwd will return the resolved path.
workDirectory: /usr/home/runner/work/action/action
uname:
hardware: arm64
release: 13.1-RELEASE

- name: FreeBSD
architecture: ARM64
version: '13.2'
host: ubuntu-latest
# /home is symlinked to /usr/home. pwd will return the resolved path.
workDirectory: /usr/home/runner/work/action/action
uname:
hardware: arm64
release: 13.2-RELEASE

- name: OpenBSD
version: '6.8'
host: macos-12
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Add support for FreeBSD ARM64 ([#55](https://github.com/cross-platform-actions/action/issues/55))

## [0.15.0] - 2023-06-12
### Changed
Expand Down
65 changes: 55 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ operating system will list which versions are supported.

### [FreeBSD][freebsd_builder] (`freebsd`)

| Version | x86-64 |
| ------- | ------ |
| 13.2 | ✅ |
| 13.1 | ✅ |
| 13.0 | ✅ |
| 12.4 | ✅ |
| 12.2 | ✅ |
| Version | x86-64 | arm64 |
| ------- | ------ | ------ |
| 13.2 | ✅ | ✅ |
| 13.1 | ✅ | ✅ |
| 13.0 | ✅ | ✅ |
| 12.4 | ✅ | ✅ |
| 12.2 | ✅ | ❌ |

### [NetBSD][netbsd_builder] (`netbsd`)

Expand Down
5 changes: 3 additions & 2 deletions src/architecture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export enum Kind {

export abstract class Architecture {
readonly kind: Kind
readonly host: Host

protected readonly resourceBaseUrl = ResourceUrls.create().resourceBaseUrl
protected readonly host: Host

constructor(kind: Kind, host: Host) {
this.kind = kind
Expand Down Expand Up @@ -62,7 +63,7 @@ export abstract class Architecture {
return this.host.qemu
}

private static readonly Arm64 = class extends Architecture {
static readonly Arm64 = class extends Architecture {
override get name(): string {
return 'arm64'
}
Expand Down
8 changes: 8 additions & 0 deletions src/operating_systems/freebsd/arm64.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {Architecture} from '../../architecture'
import {Hypervisor} from '../../hypervisor'

export default class Arm64 extends Architecture.Arm64 {
override get hypervisor(): Hypervisor {
return this.host.efiHypervisor
}
}
12 changes: 11 additions & 1 deletion src/operating_systems/freebsd/factory.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as architecture from '../../architecture'
import Arm64 from './arm64'
import {Hypervisor, Kind as HypervisorKind} from '../../hypervisor'
import {OperatingSystem} from '../../operating_system'
import {factory, Factory as BaseFactory} from '../factory'
Expand All @@ -11,10 +13,18 @@ class FreeBsdFactory extends BaseFactory {
}

override create(version: string, hypervisor: Hypervisor): OperatingSystem {
return new FreeBsd(this.architecture, version, hypervisor)
return new FreeBsd(this.resolveArchitecture(), version, hypervisor)
}

override validateHypervisor(kind: HypervisorKind): void {
this.architecture.validateHypervisor(kind)
}

private resolveArchitecture(): architecture.Architecture {
if (this.architecture.kind == architecture.Kind.arm64) {
return new Arm64(this.architecture.kind, this.architecture.host)
}

return this.architecture
}
}
18 changes: 7 additions & 11 deletions src/operating_systems/freebsd/freebsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ export default class FreeBsd extends os.OperatingSystem {
}

get actionImplementationKind(): action.ImplementationKind {
return this.architecture.resolve({
x86_64: action.ImplementationKind.xhyve,
default: action.ImplementationKind.qemu
})
if (this.architecture.kind === architecture.Kind.x86_64) {
return this.architecture.resolve({
x86_64: action.ImplementationKind.xhyve,
default: action.ImplementationKind.qemu
})
} else return action.ImplementationKind.qemu
}

override async prepareDisk(
Expand Down Expand Up @@ -67,19 +69,13 @@ export default class FreeBsd extends os.OperatingSystem {
): vmModule.Vm {
core.debug('Creating FreeBSD VM')

if (this.architecture.kind !== architecture.Kind.x86_64) {
throw Error(
`Not implemented: FreeBSD guests are not implemented on ${this.architecture.name}`
)
}

const config: vmModule.Configuration = {
...configuration,

ssHostPort: this.ssHostPort,
firmware: path.join(
firmwareDirectory.toString(),
this.hypervisor.firmwareFile
this.architecture.hypervisor.firmwareFile
),

// qemu
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const version = {
operating_system: {
freebsd: 'v0.4.0',
freebsd: 'v0.5.0',
netbsd: 'v0.2.0',
openbsd: 'v0.6.0'
},
Expand Down

0 comments on commit 27369a9

Please sign in to comment.