This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
osbuilder: Add support for suse rootfs
Fixes: #33 Signed-off-by: Marco Vedovati <mvedovati@suse.com>
- Loading branch information
Showing
7 changed files
with
199 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Copyright (c) 2018 SUSE | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
#suse: docker image to be used to create a rootfs | ||
#@OS_VERSION@: Docker image version to build this dockerfile | ||
from opensuse/leap | ||
|
||
# This dockerfile needs to provide all the componets need to build a rootfs | ||
# Install any package need to create a rootfs (package manager, extra tools) | ||
|
||
# RUN commands | ||
RUN zypper refresh; \ | ||
zypper --non-interactive install --no-recommends --force-resolution curl git gcc make python3-kiwi tar; \ | ||
zypper clean --all | ||
|
||
# This will install the proper golang to build Kata components | ||
@INSTALL_GO@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright (c) 2018 SUSE | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# May also be "Tumbleweed" | ||
OS_DISTRO="Leap" | ||
|
||
# Leave this empty for distro "Tumbleweed" | ||
OS_VERSION=${OS_VERSION:-15.0} | ||
|
||
OS_IDENTIFIER="$OS_DISTRO${OS_VERSION:+:$OS_VERSION}" | ||
|
||
PACKAGES="systemd iptables libudev1" | ||
|
||
REPO_URL_OBS="obs://openSUSE:$OS_IDENTIFIER/standard" | ||
REPO_URL_BASE="http://download.opensuse.org" | ||
REPO_URL_PATH="/distribution/${OS_DISTRO,,}/$OS_VERSION/repo/oss" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) 2018 SUSE | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
<image schemaversion="6.8" name="openSUSE-rootfs-for-Kata-vm"> | ||
<description type="system"> | ||
<author>SUSE</author> | ||
<contact>mvedovati@suse.com</contact> | ||
<specification>openSUSE rootfs for Kata Containers guest vm</specification> | ||
</description> | ||
<preferences> | ||
<version>1.0.0</version> | ||
<packagemanager>zypper</packagemanager> | ||
<locale>en_US</locale> | ||
<keytable>us</keytable> | ||
<rpm-excludedocs>true</rpm-excludedocs> | ||
<type image="vmx" filesystem="ext4" /> | ||
</preferences> | ||
<repository type="rpm-md"> | ||
<!-- NOTE: the following is a placeholder, specify the actual path with kiwi option set-repo=... --> | ||
<source path="obs://"/> | ||
</repository> | ||
<packages type="image"> | ||
<package name=""/> | ||
</packages> | ||
<packages type="bootstrap" patternType="onlyRequired"> | ||
<package name="filesystem"/> | ||
</packages> | ||
<packages type="delete"> | ||
<package name="zypper"/> | ||
<package name="rpm"/> | ||
</packages> | ||
</image> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# | ||
# Copyright (c) 2018 SUSE | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# - 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 | ||
# | ||
# Note: For some distros, the build_rootfs() function provided in scripts/lib.sh | ||
# will suffice. If a new distro is introduced with a special requirement, | ||
# then, a rootfs_builder/<distro>/rootfs_lib.sh file should be created | ||
# using this template. | ||
|
||
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:-} | ||
|
||
#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} | ||
if [ -e "$ROOTFS_DIR" ] && ! [ -z "$(ls -A $ROOTFS_DIR)" ]; then | ||
echo "ERROR: $ROOTFS_DIR is not empty" | ||
exit 1 | ||
fi | ||
|
||
local addPackages="" | ||
for p in $PACKAGES $EXTRA_PKGS; do | ||
addPackages+=" --add-package=$p" | ||
done | ||
|
||
if [ -z "$REPO_URL" ]; then | ||
local arch="$(uname -m)" | ||
case $arch in | ||
x86_64) | ||
REPO_URL_PORT="" | ||
;; | ||
ppc|ppc64le) | ||
REPO_URL_PORT="/ports/ppc" | ||
;; | ||
*) | ||
REPO_URL_PORT="/ports/$arch" | ||
;; | ||
esac | ||
REPO_URL="${REPO_URL_BASE}${REPO_URL_PORT}${REPO_URL_PATH}" | ||
fi | ||
|
||
# set-repo format: <source,type,alias,priority,imageinclude,package_gpgcheck> | ||
# man kiwi::system::build for details | ||
local setRepo=" --set-repo $REPO_URL,rpm-md,$OS_IDENTIFIER,99,false,false" | ||
|
||
kiwi system prepare \ | ||
--description $CONFIG_DIR \ | ||
--allow-existing-root \ | ||
--root $ROOTFS_DIR \ | ||
$addPackages \ | ||
$setRepo | ||
install -d $ROOTFS_DIR/lib/systemd | ||
ln -s /usr/lib/systemd/systemd $ROOTFS_DIR/lib/systemd/systemd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters