Skip to content

Commit

Permalink
fixup! Add support for FreeBSD ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Jul 11, 2023
1 parent 47e1c3d commit bbf1c25
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 7 deletions.
48 changes: 46 additions & 2 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.

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
}
}
2 changes: 1 addition & 1 deletion src/operating_systems/freebsd/freebsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class FreeBsd extends os.OperatingSystem {
ssHostPort: this.ssHostPort,
firmware: path.join(
firmwareDirectory.toString(),
this.architecture.efiHypervisor.firmwareFile
this.architecture.hypervisor.firmwareFile
),

// qemu
Expand Down

0 comments on commit bbf1c25

Please sign in to comment.