mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-31 23:36:12 +00:00
rootfs: Add rootfs based on CentOS 7
Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
parent
5b8478c4cf
commit
75a9d5eab7
1
rootfs-builder/centos/Dockerfile
Normal file
1
rootfs-builder/centos/Dockerfile
Normal file
@ -0,0 +1 @@
|
||||
FROM centos:7
|
30
rootfs-builder/centos/RPM-GPG-KEY-CentOS-7
Normal file
30
rootfs-builder/centos/RPM-GPG-KEY-CentOS-7
Normal file
@ -0,0 +1,30 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.4.5 (GNU/Linux)
|
||||
|
||||
mQINBFOn/0sBEADLDyZ+DQHkcTHDQSE0a0B2iYAEXwpPvs67cJ4tmhe/iMOyVMh9
|
||||
Yw/vBIF8scm6T/vPN5fopsKiW9UsAhGKg0epC6y5ed+NAUHTEa6pSOdo7CyFDwtn
|
||||
4HF61Esyb4gzPT6QiSr0zvdTtgYBRZjAEPFVu3Dio0oZ5UQZ7fzdZfeixMQ8VMTQ
|
||||
4y4x5vik9B+cqmGiq9AW71ixlDYVWasgR093fXiD9NLT4DTtK+KLGYNjJ8eMRqfZ
|
||||
Ws7g7C+9aEGHfsGZ/SxLOumx/GfiTloal0dnq8TC7XQ/JuNdB9qjoXzRF+faDUsj
|
||||
WuvNSQEqUXW1dzJjBvroEvgTdfCJfRpIgOrc256qvDMp1SxchMFltPlo5mbSMKu1
|
||||
x1p4UkAzx543meMlRXOgx2/hnBm6H6L0FsSyDS6P224yF+30eeODD4Ju4BCyQ0jO
|
||||
IpUxmUnApo/m0eRelI6TRl7jK6aGqSYUNhFBuFxSPKgKYBpFhVzRM63Jsvib82rY
|
||||
438q3sIOUdxZY6pvMOWRkdUVoz7WBExTdx5NtGX4kdW5QtcQHM+2kht6sBnJsvcB
|
||||
JYcYIwAUeA5vdRfwLKuZn6SgAUKdgeOtuf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BLIC KEY BLOCK-----
|
15
rootfs-builder/centos/config.sh
Normal file
15
rootfs-builder/centos/config.sh
Normal file
@ -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
|
||||
|
||||
# Centos Version
|
||||
OS_VERSION=${OS_VERSION:-7}
|
||||
|
||||
#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"
|
134
rootfs-builder/centos/rootfs_lib.sh
Normal file
134
rootfs-builder/centos/rootfs_lib.sh
Normal file
@ -0,0 +1,134 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
check_program(){
|
||||
type "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
check_root()
|
||||
{
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "Root is needed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
generate_dnf_config()
|
||||
{
|
||||
cat > "${DNF_CONF}" << EOF
|
||||
[main]
|
||||
cachedir=/var/cache/centos-osbuilder
|
||||
keepcache=0
|
||||
debuglevel=2
|
||||
logfile=/var/log/yum-centos.log
|
||||
exactarch=1
|
||||
obsoletes=1
|
||||
gpgcheck=0
|
||||
plugins=0
|
||||
installonly_limit=3
|
||||
#Dont use the default dnf reposdir
|
||||
#this will prevent to use host repositories
|
||||
reposdir=/root/mash
|
||||
|
||||
[base]
|
||||
name=CentOS-7 - Base
|
||||
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&container=container
|
||||
#baseurl=${REPO_URL}/os/x86_64/
|
||||
gpgcheck=1
|
||||
gpgkey=file://${CONFIG_DIR}/RPM-GPG-KEY-CentOS-7
|
||||
|
||||
#released updates
|
||||
[updates]
|
||||
name=CentOS-7 - Updates
|
||||
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&container=container
|
||||
#baseurl=${REPO_URL}/updates/x86_64/
|
||||
gpgcheck=1
|
||||
gpgkey=file://${CONFIG_DIR}/RPM-GPG-KEY-CentOS-7
|
||||
|
||||
#additional packages that may be useful
|
||||
[extras]
|
||||
name=CentOS-7 - Extras
|
||||
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&container=container
|
||||
#baseurl=${REPO_URL}/extras/x86_64/
|
||||
gpgcheck=1
|
||||
gpgkey=file://${CONFIG_DIR}/RPM-GPG-KEY-CentOS-7
|
||||
|
||||
#additional packages that extend functionality of existing packages
|
||||
[centosplus]
|
||||
name=CentOS-7 - Plus
|
||||
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=centosplus&container=container
|
||||
#baseurl=${REPO_URL}/centosplus/x86_64/
|
||||
gpgcheck=1
|
||||
enabled=0
|
||||
gpgkey=file://${CONFIG_DIR}/RPM-GPG-KEY-CentOS-7
|
||||
EOF
|
||||
}
|
||||
|
||||
# - 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:-http://mirror.centos.org/centos/7}
|
||||
|
||||
#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}
|
||||
check_root
|
||||
if [ ! -f "${DNF_CONF}" ]; then
|
||||
DNF_CONF="./kata-centos-dnf.conf"
|
||||
generate_dnf_config
|
||||
fi
|
||||
mkdir -p "${ROOTFS_DIR}"
|
||||
if [ -n "${PKG_MANAGER}" ]; then
|
||||
info "DNF path provided by user: ${PKG_MANAGER}"
|
||||
elif check_program "dnf"; then
|
||||
PKG_MANAGER="dnf"
|
||||
elif check_program "yum" ; then
|
||||
PKG_MANAGER="yum"
|
||||
else
|
||||
die "neither yum nor dnf is installed"
|
||||
fi
|
||||
|
||||
info "Using : ${PKG_MANAGER} to pull packages from ${REPO_URL}"
|
||||
|
||||
DNF="${PKG_MANAGER} --config=$DNF_CONF -y --installroot=${ROOTFS_DIR} --noplugins"
|
||||
$DNF install ${EXTRA_PKGS} ${PACKAGES}
|
||||
|
||||
[ -n "${ROOTFS_DIR}" ] && rm -r "${ROOTFS_DIR}/var/cache/centos-osbuilder"
|
||||
}
|
Loading…
Reference in New Issue
Block a user