kernels

package
v0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GitBinary  = "git"
	MakeBinary = "make"

	Binaries = []string{GitBinary}
)
View Source
var (
	ConfigFname    = "kernels.json"
	KernelsDirName = "kernels"
)
View Source
var ConfigOptGroups = map[string][]ConfigOption{
	"basic": []ConfigOption{
		{"--enable", "CONFIG_LOCALVERSION_AUTO"},
		{"--enable", "CONFIG_DEBUG_INFO"},
		{"--enable", "CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT"},
		{"--disable", "CONFIG_WERROR"},
	},
	"minimize": []ConfigOption{
		{"--disable", "CONFIG_DRM"},
		{"--disable", "CONFIG_GPU"},

		{"--disable", "CONFIG_ISO9669_FS"},
		{"--disable", "CONFIG_CFG80211"},
		{"--disable", "CONFIG_WIRELESS"},
		{"--disable", "CONFIG_RFKILL"},
		{"--disable", "CONFIG_MACINTOSH_DRIVERS"},
		{"--disable", "CONFIG_SOUND"},
		{"--disable", "CONFIG_AGP"},
		{"--disable", "CONFIG_USB_SUPPORT"},
		{"--disable", "CONFIG_USB"},
		{"--disable", "CONFIG_WLAN"},
		{"--disable", "CONFIG_HID"},
		{"--disable", "CONFIG_I2C"},
		{"--disable", "CONFIG_PCMCIA"},
		{"--disable", "CONFIG_MD"},
		{"--disable", "CONFIG_DMADEVICES"},
		{"--disable", "CONFIG_THERMAL"},
	},
	"bpf": []ConfigOption{
		{"--enable", "CONFIG_BPF"},
		{"--enable", "CONFIG_BPF_SYSCALL"},

		{"--enable", "CONFIG_NET_CLS_BPF"},
		{"--enable", "CONFIG_NET_ACT_BPF"},
		{"--enable", "CONFIG_BPF_JIT"},
		{"--enable", "CONFIG_BPF_JIT_DEFAULT_ON"},
		{"--enable", "CONFIG_BPF_EVENTS"},
		{"--enable", "CONFIG_BPF_STREAM_PARSER"},

		{"--enable", "CONFIG_DEBUG_INFO_BTF"},
		{"--enable", "CONFIG_DEBUG_INFO_BTF_MODULES"},
		{"--enable", "CONFIG_BPF_LSM"},
		{"--enable", "CONFIG_CGROUP_BPF"},
		{"--enable", "CONFIG_FTRACE_SYSCALLS"},

		{"--enable", "CONFIG_SKB_EXTENSIONS"},
		{"--enable", "CONFIG_NET_TC_SKB_EXT"},
	},
	"virtio": []ConfigOption{
		{"--enable", "CONFIG_VIRTIO"},
		{"--enable", "CONFIG_VIRTIO_MENU"},
		{"--enable", "CONFIG_VIRTIO_PCI_LIB"},
		{"--enable", "CONFIG_VIRTIO_PCI"},
		{"--enable", "CONFIG_VIRTIO_NET"},
		{"--enable", "CONFIG_NET_9P"},
		{"--enable", "CONFIG_9P_FS"},
		{"--enable", "CONFIG_NET_9P_VIRTIO"},
		{"--enable", "CONFIG_VIRTIO_BLK"},
	},
	"namespaces": []ConfigOption{
		{"--enable", "CONFIG_NAMESPACES"},
		{"--enable", "CONFIG_UTS_NS"},
		{"--enable", "CONFIG_TIME_NS"},
		{"--enable", "CONFIG_IPC_NS"},
		{"--enable", "CONFIG_USER_NS"},
		{"--enable", "CONFIG_PID_NS"},
		{"--enable", "CONFIG_NET_NS"},
	},
}
View Source
var DefaultConfigGroups = []string{"basic", "bpf", "virtio", "minimize", "namespaces"}
View Source
var MainGitDir = "git"
View Source
var UrlExamples = []UrlExample{
	{
		Name: "bpf-next",
		URL:  "git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git",
		// contains filtered or unexported fields
	}, {
		Name: "5.18",
		URL:  "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git#linux-5.18.y",
		// contains filtered or unexported fields
	}, {
		Name: "5.15",
		URL:  "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git?depth=1#linux-5.15.y",
		// contains filtered or unexported fields
	},
}

Functions

func AddKernel

func AddKernel(ctx context.Context, log *logrus.Logger, dir string, cnf *KernelConf, flags AddKernelFlags) error

func BuildKernel

func BuildKernel(ctx context.Context, log *logrus.Logger, dir, kname string, fetch bool, arch string) error

func CheckEnvironment

func CheckEnvironment() error

NB(kkourt): for now, just a single check for everything

func FetchKernel

func FetchKernel(ctx context.Context, log *logrus.Logger, dir, kname string) error

func FindKernel

func FindKernel(installDir string) (string, error)

func GetConfigGroupNames

func GetConfigGroupNames() []string

func GetExamplesText

func GetExamplesText() string

func InitDir

func InitDir(log *logrus.Logger, dir string, conf *Conf, flags InitDirFlags) error

Initalizes a new directory for kernels (it will create it if it does not exist).

the provided conf will be saved in the directory. if conf is nil, an empty configuration will be used.

func RemoveKernel

func RemoveKernel(ctx context.Context, log_ *logrus.Logger, dir string, name string, backupConf bool) error

RemoveKernel will remove a kernel. It will typically try to continue, even if it encounters an error

Types

type AddKernelFlags

type AddKernelFlags struct {
	BackupConf bool
	Fetch      bool
}

type Conf

type Conf struct {
	Kernels    []KernelConf   `json:"kernels"`
	CommonOpts []ConfigOption `json:"common_opts,omitempty"`
}

func (*Conf) AddGroupsCommonOpts

func (c *Conf) AddGroupsCommonOpts(gs ...string) error

func (*Conf) SaveTo

func (cnf *Conf) SaveTo(log logrus.FieldLogger, dir string, backup bool) error

type ConfigOption

type ConfigOption []string

ConfigOption are switches passed to scripts/config in a kernel dir

type GitURL

type GitURL struct {
	Repo string

	// Branch in remote (by default, master)
	Branch string

	// depth for shallow directories (-1 means clone the full repo)
	ShallowDepth int
}

type InitDirFlags

type InitDirFlags struct {
	Force      bool
	BackupConf bool
}

type KernelConf

type KernelConf struct {
	Name string `json:"name"`
	// URL of the kernel source
	URL string `json:"url"`
	// config options
	Opts []ConfigOption `json:"opts,omitempty"`
	// Extra make args
	ExtraMakeArgs []string `json:"extra_make_args,omitempty"`
}

KernelConf is the configuration of a kernel (to build from source)

func (*KernelConf) AddGroupsOpts

func (kc *KernelConf) AddGroupsOpts(gs ...string) error

func (*KernelConf) Validate

func (kc *KernelConf) Validate() error

type KernelURL

type KernelURL interface {
	// contains filtered or unexported methods
}

func NewGitURL

func NewGitURL(kurl *url.URL) (KernelURL, error)

func ParseURL

func ParseURL(s string) (KernelURL, error)

type KernelsDir

type KernelsDir struct {
	Dir  string
	Conf Conf
}

func LoadDir

func LoadDir(dir string) (*KernelsDir, error)

Load configuration from a directory

func (*KernelsDir) ConfigureKernel

func (kd *KernelsDir) ConfigureKernel(ctx context.Context, log *logrus.Logger, kernName string, targetArch string) error

func (*KernelsDir) KernelConfig

func (kd *KernelsDir) KernelConfig(name string) *KernelConf

func (*KernelsDir) RawConfigure added in v0.0.14

func (kd *KernelsDir) RawConfigure(ctx context.Context, log *logrus.Logger, kernDir, kernName string, targetArch string) error

func (*KernelsDir) RemoveKernelConfig

func (kd *KernelsDir) RemoveKernelConfig(name string) *KernelConf

RemoveKernelConfig returns the removed kernel config if it was found

type UrlExample

type UrlExample struct {
	Name string
	URL  string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL