mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-09 11:58:16 +00:00
rootfs: Add script for Fedora base OS
Add scirpts to build a rootfs based on Fedora. Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
parent
91bf410118
commit
5b8478c4cf
3
rootfs-builder/fedora/Dockerfile
Normal file
3
rootfs-builder/fedora/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
From fedora:27
|
||||||
|
|
||||||
|
RUN dnf -y update && dnf install -y git golang systemd pkgconfig
|
8
rootfs-builder/fedora/config.sh
Normal file
8
rootfs-builder/fedora/config.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2017 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#Fedora version to use
|
||||||
|
OS_VERSION=${OS_VERSION:-27}
|
||||||
|
PACKAGES="systemd iptables"
|
88
rootfs-builder/fedora/rootfs_lib.sh
Executable file
88
rootfs-builder/fedora/rootfs_lib.sh
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
check_program(){
|
||||||
|
type "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_dnf_config()
|
||||||
|
{
|
||||||
|
cat > "${DNF_CONF}" << EOF
|
||||||
|
[main]
|
||||||
|
cachedir=/var/cache/dnf/kata/
|
||||||
|
keepcache=0
|
||||||
|
debuglevel=2
|
||||||
|
logfile=/var/log/dnf.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
|
||||||
|
|
||||||
|
[kata]
|
||||||
|
name=fedora
|
||||||
|
failovermethod=priority
|
||||||
|
baseurl=${REPO_URL}
|
||||||
|
enabled=1
|
||||||
|
gpgcheck=0
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
build_rootfs()
|
||||||
|
{
|
||||||
|
# Mandatory
|
||||||
|
local ROOTFS_DIR=$1
|
||||||
|
|
||||||
|
#In case rootfs is created usig repositories allow user to modify
|
||||||
|
# the default URL
|
||||||
|
local REPO_URL=${REPO_URL:-http://mirror.math.princeton.edu/pub/fedora/linux/releases/$OS_VERSION/Everything/x86_64/os/}
|
||||||
|
|
||||||
|
# In case of support EXTRA packages, use it to allow
|
||||||
|
# users add more packages to the base rootfs
|
||||||
|
local EXTRA_PKGS=${EXTRA_PKGS:-""}
|
||||||
|
|
||||||
|
#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}
|
||||||
|
|
||||||
|
check_root
|
||||||
|
if [ ! -f "${DNF_CONF}" ]; then
|
||||||
|
DNF_CONF="./kata-fedora-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/dnf"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_root()
|
||||||
|
{
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "Root is needed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user