This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
ci: Add installation scripts #71
Merged
+750
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
clone_build_and_install "github.com/kata-containers/agent" |
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,40 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
cidir=$(dirname "$0") | ||
|
||
OSBUILDER_DISTRO=${OSBUILDER_DISTRO:-clearlinux} | ||
image_name="kata-containers.img" | ||
|
||
# Build Kata agent | ||
bash -f ${cidir}/install_agent.sh | ||
|
||
osbuilder_repo="github.com/kata-containers/osbuilder" | ||
|
||
# Clone os-builder repository | ||
go get -d ${osbuilder_repo} || true | ||
|
||
pushd "${GOPATH}/src/${osbuilder_repo}/rootfs-builder" | ||
sudo -E GOPATH=$GOPATH USE_DOCKER=true ./rootfs.sh ${OSBUILDER_DISTRO} | ||
popd | ||
|
||
# Build the image | ||
pushd "${GOPATH}/src/${osbuilder_repo}/image-builder" | ||
sudo -E USE_DOCKER=true ./image_builder.sh ../rootfs-builder/rootfs | ||
|
||
# Install the image | ||
agent_commit=$("$GOPATH/src/github.com/kata-containers/agent/kata-agent" --version | awk '{print $NF}') | ||
commit=$(git log --format=%h -1 HEAD) | ||
date=$(date +%Y-%m-%d-%T.%N%z) | ||
image="kata-containers-${date}-osbuilder-${commit}-agent-${agent_commit}" | ||
|
||
sudo install -o root -g root -m 0640 -D ${image_name} "/usr/share/kata-containers/${image}" | ||
(cd /usr/share/kata-containers && sudo rm -f ${image_name} && sudo ln -s "$image" ${image_name}) | ||
|
||
popd |
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,92 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# Currently we will use this repository until this issue is solved | ||
# See https://github.com/kata-containers/packaging/issues/1 | ||
|
||
set -e | ||
|
||
cidir=$(dirname "$0") | ||
source "${cidir}/lib.sh" | ||
|
||
repo_owner="clearcontainers" | ||
repo_name="linux" | ||
|
||
linux_releases_url="https://github.com/${repo_owner}/${repo_name}/releases" | ||
#fake repository dir to query kernel version from remote | ||
fake_repo_dir=$(mktemp -t -d kata-kernel.XXXX) | ||
|
||
function cleanup { | ||
rm -rf "${fake_repo_dir}" | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
function usage() { | ||
cat << EOT | ||
Usage: $0 <version> | ||
Install the containers clear kernel image <version> from "${repo_owner}/${repo_name}". | ||
version: Use 'latest' to pull latest kernel or a version from "${cc_linux_releases_url}" | ||
EOT | ||
|
||
exit 1 | ||
} | ||
|
||
#Get latest version by checking remote tags | ||
#We dont ask to github api directly because force a user to provide a GITHUB token | ||
function get_latest_version { | ||
pushd "${fake_repo_dir}" >> /dev/null | ||
git init -q | ||
git remote add origin https://github.com/"${repo_owner}/${repo_name}".git | ||
|
||
cc_release=$(git ls-remote --tags 2>/dev/null \ | ||
| grep -oP '\-\d+\.container' \ | ||
| grep -oP '\d+' \ | ||
| sort -n | \ | ||
tail -1 ) | ||
|
||
tag=$(git ls-remote --tags 2>/dev/null \ | ||
| grep -oP "v\d+\.\d+\.\d+\-${cc_release}.container" \ | ||
| tail -1) | ||
|
||
popd >> /dev/null | ||
echo "${tag}" | ||
} | ||
|
||
function download_kernel() { | ||
local version="$1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, make this function check See:
/cc @jcvenegas. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This issue is still outstanding. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jodh-intel done |
||
arch=$(arch) | ||
[ -n "${version}" ] || die "version not provided" | ||
[ "${version}" == "latest" ] && version=$(get_latest_version) | ||
echo "version to install ${version}" | ||
local binaries_dir="${version}-binaries" | ||
local binaries_tarball="${binaries_dir}.tar.gz" | ||
local shasum_file="SHA512SUMS" | ||
if [ "$arch" = x86_64 ]; then | ||
curl -OL "${linux_releases_url}/download/${version}/${binaries_tarball}" | ||
curl -OL "${linux_releases_url}/download/${version}/${shasum_file}" | ||
sha512sum -c "${shasum_file}" | ||
tar xf "${binaries_tarball}" | ||
else | ||
die "Unsupported architecture: $arch" | ||
fi | ||
|
||
pushd "${binaries_dir}" | ||
sudo make install | ||
popd | ||
} | ||
|
||
cc_kernel_version="$1" | ||
|
||
[ -z "${cc_kernel_version}" ] && usage | ||
download_kernel "${cc_kernel_version}" | ||
|
||
# Make symbolic link to kata-containers | ||
# FIXME: see https://github.com/kata-containers/packaging/issues/1 | ||
sudo ln -s /usr/share/clear-containers/vmlinux.container /usr/share/kata-containers/ | ||
sudo ln -s /usr/share/clear-containers/vmlinuz.container /usr/share/kata-containers/ |
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,14 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
clone_build_and_install "github.com/kata-containers/proxy" |
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,38 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
arch=$(arch) | ||
|
||
if [ "$#" -ne 3 ]; then | ||
echo "Usage: $0 <CLEAR_RELEASE> <QEMU_LITE_VERSION> <DISTRO>" | ||
echo " Install the QEMU_LITE_VERSION from clear CLEAR_RELEASE." | ||
exit 1 | ||
fi | ||
|
||
clear_release="$1" | ||
qemu_lite_version="$2" | ||
distro="$3" | ||
qemu_lite_bin="qemu-lite-bin-${qemu_lite_version}.${arch}.rpm" | ||
qemu_lite_data="qemu-lite-data-${qemu_lite_version}.${arch}.rpm" | ||
|
||
echo -e "Install qemu-lite ${qemu_lite_version}" | ||
|
||
# download packages | ||
curl -LO "https://download.clearlinux.org/releases/${clear_release}/clear/${arch}/os/Packages/${qemu_lite_bin}" | ||
curl -LO "https://download.clearlinux.org/releases/${clear_release}/clear/${arch}/os/Packages/${qemu_lite_data}" | ||
|
||
# install packages | ||
if [ "$distro" == "ubuntu" ]; then | ||
sudo alien -i "./${qemu_lite_bin}" | ||
sudo alien -i "./${qemu_lite_data}" | ||
fi | ||
|
||
# cleanup | ||
rm -f "./${qemu_lite_bin}" | ||
rm -f "./${qemu_lite_data}" |
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,53 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
# Modify the runtimes build-time defaults | ||
|
||
# enable verbose build | ||
export V=1 | ||
|
||
# tell the runtime build to use sane defaults | ||
export SYSTEM_BUILD_TYPE=kata | ||
|
||
# The runtimes config file should live here | ||
export SYSCONFDIR=/etc | ||
|
||
# Artifacts (kernel + image) live below here | ||
export SHAREDIR=/usr/share | ||
|
||
runtime_config_path="${SYSCONFDIR}/kata-containers/configuration.toml" | ||
|
||
PKGDEFAULTSDIR="${SHAREDIR}/defaults/kata-containers" | ||
NEW_RUNTIME_CONFIG="${PKGDEFAULTSDIR}/configuration.toml" | ||
# Note: This will also install the config file. | ||
clone_build_and_install "github.com/kata-containers/runtime" | ||
|
||
# Check system supports running Kata Containers | ||
kata-runtime kata-check | ||
|
||
if [ -e "${NEW_RUNTIME_CONFIG}" ]; then | ||
# Remove the legacy config file | ||
sudo rm -f "${runtime_config_path}" | ||
|
||
# Use the new path | ||
runtime_config_path="${NEW_RUNTIME_CONFIG}" | ||
fi | ||
|
||
echo "Enabling all debug options in file ${runtime_config_path}" | ||
sudo sed -i -e 's/^#\(enable_debug\).*=.*$/\1 = true/g' "${runtime_config_path}" | ||
|
||
echo "Add runtime as a new/default Docker runtime. Docker version \"$(docker --version)\" could change according to updates." | ||
docker_options="-D --add-runtime kata-runtime=/usr/local/bin/kata-runtime" | ||
|
||
echo "Add kata-runtime as a new/default Docker runtime." | ||
"${cidir}/../cmd/container-manager/manage_ctr_mgr.sh" docker configure -r kata-runtime -f |
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,14 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
clone_build_and_install "github.com/kata-containers/shim" |
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,61 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
_runtime_repo="github.com/kata-containers/runtime" | ||
# FIXME: Issue https://github.com/kata-containers/packaging/issues/1 | ||
_versions_file="$GOPATH/src/github.com/clearcontainers/runtime/versions.txt" | ||
|
||
export KATA_RUNTIME=${KATA_RUNTIME:-cc} | ||
|
||
# If we fail for any reason a message will be displayed | ||
die(){ | ||
msg="$*" | ||
echo "ERROR: $msg" >&2 | ||
exit 1 | ||
} | ||
|
||
function clone_and_build() { | ||
github_project="$1" | ||
make_target="$2" | ||
project_dir="${GOPATH}/src/${github_project}" | ||
|
||
echo "Retrieve repository ${github_project}" | ||
go get -d ${github_project} || true | ||
|
||
# fixme: once tool to parse and get branches from github is | ||
# completed, add it here to fetch branches under testing | ||
|
||
pushd ${project_dir} | ||
|
||
echo "Build ${github_project}" | ||
if [ ! -f Makefile ]; then | ||
echo "Run autogen.sh to generate Makefile" | ||
bash -f autogen.sh | ||
fi | ||
|
||
make | ||
|
||
popd | ||
} | ||
|
||
function clone_build_and_install() { | ||
clone_and_build $1 $2 | ||
pushd "${GOPATH}/src/${1}" | ||
echo "Install repository ${1}" | ||
sudo -E PATH=$PATH KATA_RUNTIME=${KATA_RUNTIME} make install | ||
popd | ||
} | ||
|
||
function get_cc_versions(){ | ||
# This is needed in order to retrieve the version for qemu-lite | ||
cc_runtime_repo="github.com/clearcontainers/runtime" | ||
go get -d -u -v "$cc_runtime_repo" || true | ||
[ ! -f "$_versions_file" ] && { echo >&2 "ERROR: cannot find $_versions_file"; exit 1; } | ||
source "$_versions_file" | ||
} |
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,33 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
cidir=$(dirname "$0") | ||
source /etc/os-release | ||
source "${cidir}/lib.sh" | ||
|
||
echo "Set up environment" | ||
if [ "$ID" == ubuntu ];then | ||
bash -f "${cidir}/setup_env_ubuntu.sh" | ||
else | ||
die "ERROR: Unrecognised distribution." | ||
exit 1 | ||
fi | ||
|
||
echo "Install shim" | ||
bash -f ${cidir}/install_shim.sh | ||
|
||
echo "Install proxy" | ||
bash -f ${cidir}/install_proxy.sh | ||
|
||
echo "Install runtime" | ||
bash -f ${cidir}/install_runtime.sh | ||
|
||
echo "Drop caches" | ||
sync | ||
sudo -E PATH=$PATH bash -c "echo 3 > /proc/sys/vm/drop_caches" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: double blank line.