Skip to content

Commit

Permalink
Add support for NetBSD ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Apr 3, 2024
1 parent cbda22d commit e53c593
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 95 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -124,20 +124,34 @@ jobs:
fail-fast: false
matrix:
version:
- '10.0'
- '9.3'
- '9.2'

architecture:
- name: x86-64
uname: amd64

- name: arm64
uname: aarch64

host:
- name: ubuntu-latest
work_directory: /home/runner/work/action/action

- name: macos-latest
work_directory: /Users/runner/work/action/action

exclude:
- version: '9.3'
architecture: { name: arm64 }

- version: '9.2'
architecture: { name: arm64 }

- architecture: { name: arm64 }
host: { name: macos-latest }

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/support/test/action.yml
Expand Up @@ -34,12 +34,14 @@ runs:
shutdown_vm: false
run: |
uname -a
uname -m
uname -p
echo $SHELL
pwd
ls -lah
whoami
env | sort
[ "`uname -s`" = '${{ inputs.name }}' ]
[ "`uname -r`" = '${{ inputs.uname_release || inputs.version }}' ]
[ "`uname -m`" = '${{ inputs.uname_hardware }}' ]
[ "`uname -m`" = '${{ inputs.uname_hardware }}' ] || [ "`uname -p`" = '${{ inputs.uname_hardware }}' ]
[ "`pwd`" = '${{ inputs.work_directory }}' ]
62 changes: 9 additions & 53 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.

2 changes: 1 addition & 1 deletion src/architecture.ts
Expand Up @@ -105,7 +105,7 @@ export abstract class Architecture {
}

override get hypervisor(): hypervisor.Hypervisor {
return new hypervisor.Qemu()
return this.host.efiHypervisor
}

override get efiHypervisor(): hypervisor.Hypervisor {
Expand Down
8 changes: 0 additions & 8 deletions src/operating_systems/freebsd/arm64.ts

This file was deleted.

25 changes: 3 additions & 22 deletions src/operating_systems/freebsd/factory.ts
@@ -1,35 +1,16 @@
import * as architecture from '../../architecture'
import Arm64 from './arm64'
import {Hypervisor, Kind as HypervisorKind} from '../../hypervisor'
import {Kind as HypervisorKind} from '../../hypervisor'
import {OperatingSystem} from '../../operating_system'
import {factory, Factory as BaseFactory} from '../factory'
import FreeBsd from './freebsd'

@factory
//@ts-ignore
class FreeBsdFactory extends BaseFactory {
override createImpl(
version: string,
hypervisor: Hypervisor
): OperatingSystem {
return new FreeBsd(this.resolveArchitecture(hypervisor), version)
override createImpl(version: string): OperatingSystem {
return new FreeBsd(this.architecture, version)
}

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

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

return this.architecture
}
}
6 changes: 0 additions & 6 deletions src/operating_systems/netbsd/netbsd.ts
Expand Up @@ -43,12 +43,6 @@ export default class NetBsd extends Qemu {
): vmModule.Vm {
core.debug('Creating NetBSD VM')

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

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

Expand Down
13 changes: 11 additions & 2 deletions src/operating_systems/qemu.ts
@@ -1,9 +1,18 @@
import {Hypervisor, Qemu as QemuHypervisor} from '../hypervisor'
import {
Hypervisor,
Qemu as QemuHypervisor,
QemuEfi as QemuEfiHypervisor
} from '../hypervisor'
import {OperatingSystem} from '../operating_system'

export abstract class Qemu extends OperatingSystem {
override get hypervisor(): Hypervisor {
return new QemuHypervisor()
const cls = this.architecture.resolve({
arm64: QemuEfiHypervisor,
x86_64: QemuHypervisor
})

return new cls()
}

get ssHostPort(): number {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
@@ -1,7 +1,7 @@
const version = {
operating_system: {
freebsd: 'v0.5.0',
netbsd: 'v0.2.0',
netbsd: 'v0.3.0',
openbsd: 'v0.7.0'
},

Expand Down

0 comments on commit e53c593

Please sign in to comment.