diff --git a/rootfs-builder/template/Makefile b/rootfs-builder/template/Makefile new file mode 100644 index 000000000..66e04e323 --- /dev/null +++ b/rootfs-builder/template/Makefile @@ -0,0 +1,15 @@ +# Copyright (c) 2017 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# +MK_DIR :=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +## Default destdir is one level up where is rootfs.sh script +DESTDIR ?= "$(realpath $(MK_DIR)/../)/$(ROOTFS_BASE_NAME)" +all: +ifndef ROOTFS_BASE_NAME + $(error ROOTFS_BASE_NAME is not set, use $ make ROOTFS_BASE_NAME=new_supported_os) +endif + mkdir -p $(DESTDIR) + cp "$(MK_DIR)/rootfs_lib_template.sh" "$(DESTDIR)/rootfs_lib.sh" + cp "$(MK_DIR)/config_template.sh" "$(DESTDIR)/config.sh" diff --git a/rootfs-builder/template/config_template.sh b/rootfs-builder/template/config_template.sh new file mode 100644 index 000000000..48ce67663 --- /dev/null +++ b/rootfs-builder/template/config_template.sh @@ -0,0 +1,15 @@ +# This is a configuration file add extra variables to +# be used by build_rootfs() from rootfs_lib.sh the variables will be +# loaded just before call the function. + +# Here there are a couple of variables you may need. +# Remove them or add more + +#Use it rootfs is based in a system has different versions +OS_VERSION=${OS_VERSION:-DEFAULT_VERSION} + +#Mandatory Packages that must be installed +# systemd: An init system that will start kata-agent +# iptables: Need by Kata agent +# udevlib.so: Need by Kata agent +PACKAGES="systemd iptables udevlib.so" diff --git a/rootfs-builder/template/rootfs_lib_template.sh b/rootfs-builder/template/rootfs_lib_template.sh new file mode 100644 index 000000000..133834bf9 --- /dev/null +++ b/rootfs-builder/template/rootfs_lib_template.sh @@ -0,0 +1,43 @@ +# - Arguments +# rootfs_dir=$1 +# +# - Optional environment variables +# +# EXTRA_PKGS: Variable to add extra PKGS provided by the user +# +# BIN_AGENT: Name of the Kata-Agent binary +# +# REPO_URL: URL to distribution repository ( should be configured in +# config.sh file) +# +# Any other configuration variable for a specific distro must be added +# and documented on its own config.sh +# +# - Expected result +# +# rootfs_dir populated with rootfs pkgs +# It must provide a binary in /sbin/init +build_rootfs() { + # Mandatory + local ROOTFS_DIR=$1 + + #Name of the Kata-Agent binary + local BIN_AGENT=${BIN_AGENT} + + # In case of support EXTRA packages, use it to allow + # users add more packages to the base rootfs + local EXTRA_PKGS=${EXTRA_PKGS:-} + + #In case rootfs is created usign repositories allow user to modify + # the default URL + local REPO_URL=${REPO_URL:-YOUR_REPO} + + #PATH where files this script is placed + #Use it to refer to files in the same directory + #Exmaple: ${CONFIG_DIR}/foo + local CONFIG_DIR=${CONFIG_DIR} + + + # Populate ROOTFS_DIR + # Must provide /sbin/init and /bin/${BIN_AGENT} +}