Nerves.BuildAction behaviour (nerves v2.0.0-pre.2)

Copy Markdown View Source

Behaviour for all functionality in the Nerves firmware build process

Implementations should add use Nerves.BuildAction and only implement the callbacks they use. Most actions will only implement one callback

Summary

Callbacks

Callback for creating the firmware image

Callback for processing the release right after assembly, but before rootfs creation

Callback for updating the build plan once artifacts are extracted

Callback for everything after firmware image creation

Callback for anything that should run before the Mix release gets assembled

Callback for updating the build plan before any downloads occur

Callback for everything after rootfs creation and before making the firmware image

Callback for creating the rootfs

Callbacks

image_creation(build_plan, opts)

@callback image_creation(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) :: :ok

Callback for creating the firmware image

post_assemble_steps(build_plan, release, opts)

@callback post_assemble_steps(
  build_plan :: Nerves.BuildPlan.t(),
  release :: Mix.Release.t(),
  opts :: keyword()
) :: Mix.Release.t()

Callback for processing the release right after assembly, but before rootfs creation

post_extract(build_plan, opts)

@callback post_extract(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) ::
  Nerves.BuildPlan.t()

Callback for updating the build plan once artifacts are extracted

This can be used to look through artifact contents to adjust to plan. Since actions can be added dynamically up to this callback, It's the only callback that can modify the build plan that's guaranteed to be called. However, as it is past the extraction phase, no new files can be downloaded.

post_image_creation(build_plan, opts)

@callback post_image_creation(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) ::
  :ok

Callback for everything after firmware image creation

pre_assemble_steps(build_plan, release, opts)

@callback pre_assemble_steps(
  build_plan :: Nerves.BuildPlan.t(),
  release :: Mix.Release.t(),
  opts :: keyword()
) :: Mix.Release.t()

Callback for anything that should run before the Mix release gets assembled

pre_download(build_plan, opts)

@callback pre_download(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) ::
  Nerves.BuildPlan.t()

Callback for updating the build plan before any downloads occur

It's possible to add files to be downloaded to the plan in this callback.

This is the only callback that may not be called. If an action is registered in another action's post_extract/2 callback, then that's after the download phase and therefore after pre_download/2 functions are called.

pre_image_creation(build_plan, opts)

@callback pre_image_creation(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) :: :ok

Callback for everything after rootfs creation and before making the firmware image

rootfs_creation_steps(build_plan, release, opts)

@callback rootfs_creation_steps(
  build_plan :: Nerves.BuildPlan.t(),
  release :: Mix.Release.t(),
  opts :: keyword()
) :: Mix.Release.t()

Callback for creating the rootfs