Module: Bsdkrun::System

Defined in:
lib/bsdkrun/system.rb

Overview

Host-level toolchain / image operations.

Class Method Summary collapse

Class Method Details

.fetch_image(os, version: nil, force: false) ⇒ String

Download + prepare a BSD image ahead of time.

Parameters:

  • os (String)

    "freebsd" or "netbsd".

  • version (String, nil) (defaults to: nil)
  • force (Boolean) (defaults to: false)

    re-download even if cached.

Returns:

  • (String)

    the command output.



21
22
23
24
25
26
# File 'lib/bsdkrun/system.rb', line 21

def fetch_image(os, version: nil, force: false)
  args = ["fetch", "--os", os.to_s]
  args.push("--version", version.to_s) if version
  args << "--force" if force
  Process.run!(args, label: "bsdkrun fetch").stdout
end

.grow_disk(disk, size) ⇒ void

This method returns an undefined value.

Grow a raw disk image (the guest expands its root FS on next boot).

Parameters:

  • disk (String)
  • size (String)


42
43
44
45
# File 'lib/bsdkrun/system.rb', line 42

def grow_disk(disk, size)
  Process.run!(["grow", "--disk", disk, "--size", size], label: "bsdkrun grow")
  nil
end

.probeBoolean

Sanity-check the toolchain: verify libkrun links and a context can be created/configured. Does not boot.

Returns:

  • (Boolean)

    true on success.



11
12
13
# File 'lib/bsdkrun/system.rb', line 11

def probe
  Process.run(["probe"]).exit_code.zero?
end

.versions(os) ⇒ Array<String>

List the builds available to fetch for a BSD, one version per line.

Parameters:

  • os (String)

    "freebsd" or "netbsd".

Returns:

  • (Array<String>)

    version strings (non-empty output lines).



32
33
34
35
# File 'lib/bsdkrun/system.rb', line 32

def versions(os)
  res = Process.run!(["versions", "--os", os.to_s], label: "bsdkrun versions")
  res.stdout.split("\n").map(&:strip).reject(&:empty?)
end