Nerves v0.4.6 Nerves.Package

Defines a Nerves package struct and helper functions.

A Nerves package is an application which defines a Nerves package configuration file at the root of the application path. The configuration file is nerves.exs and uses Mix.Config to list configuration values.

Example Configuration

  use Mix.Config

  version =
    Path.join(__DIR__, "VERSION")
    |> File.read!
    |> String.strip

  pkg =

  config pkg, :nerves_env,
    type: :system,
    version: version,
    compiler: :nerves_package,
    artifact_url: [
      "https://github.com/nerves-project/#{pkg}/releases/download/v#{version}/#{pkg}-v#{version}.tar.gz",
    ],
    platform: Nerves.System.BR,
    platform_config: [
      defconfig: "nerves_defconfig",
    ],
    checksum: [
      "linux",
      "rootfs-additions",
      "uboot",
      "bbb-busybox.config",
      "fwup.conf",
      "nerves_defconfig",
      "nerves.exs",
      "post-createfs.sh",
      "uboot-script.cmd",
      "VERSION"
    ]

Keys

Required

  • :type - The Nerves package type. Can be any one of the following

    • :system - A Nerves system.
    • :system_platform - A set of build tools for a Nerves system.
    • :toolchain - A Nerves toolchain
    • :toolchain_platform - A set of build tools for a Nerves toolchain.
  • :version - The package version

Optional

  • :compiler - The Mix.Project compiler for the package. Example: :nerves_package
  • :platform - The application which is the packages build platform.
  • :checksum - A list of files and top level folders to expand paths for use when calculating the checksum of the package source.

Summary

Functions

Builds the package and produces an artifact. See Nerves.Package.Artifact for more information

Produce a base16 encoded checksum for the package from the list of files and expanded folders listed in the checksum config key

Takes the path to the package and returns the path to its package config

Loads the package config and parses it into a %Package{}

Starts an interactive shell with the working directory set to the package path

Determines if the artifact for a package is stale and needs to be rebuilt

Types

t()
t() :: %Nerves.Package{app: atom, compiler: atom, config: Keyword.t, dep: :project | :path | :hex | :git, path: binary, platform: atom, provider: atom, type: :system | :package | :toolchain, version: Version.t}

Functions

artifact(pkg, toolchain)

Builds the package and produces an artifact. See Nerves.Package.Artifact for more information.

checksum(pkg)
checksum(Nerves.Package.t) :: String.t

Produce a base16 encoded checksum for the package from the list of files and expanded folders listed in the checksum config key.

config_path(path)
config_path(String.t) :: String.t

Takes the path to the package and returns the path to its package config.

load_config(arg)
load_config({app :: atom, path :: String.t}) :: Nerves.Package.t

Loads the package config and parses it into a %Package{}

shell(pkg)
shell(Nerves.Package.t) :: :ok

Starts an interactive shell with the working directory set to the package path

stale?(pkg, toolchain)
stale?(Nerves.Package.t, Nerves.Package.t) :: boolean

Determines if the artifact for a package is stale and needs to be rebuilt.