Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
.ci: build nydus image binary
Browse files Browse the repository at this point in the history
Signed-off-by: ChengyuZhu6 <[email protected]>
  • Loading branch information
ChengyuZhu6 authored and fidencio committed Sep 26, 2023
1 parent 68465da commit a3620ba
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions .ci/install_nydus_snapshotter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ cidir=$(dirname "$0")
source "${cidir}/lib.sh"

target_dir="/usr/local/"

nydus_snapshotter_repo=$(get_version "externals.nydus-snapshotter.url")
nydus_snapshotter_version=$(get_version "externals.nydus-snapshotter.version")
nydus_snapshotter_repo_dir="${GOPATH}/src/github.com/containerd/nydus-snapshotter"
nydus_snapshotter_binary_target_dir="${target_dir}/bin"
nydus_snapshotter_config_target_dir="${target_dir}/share/nydus-snapshotter"

nydus_image_binary_target_dir="$nydus_snapshotter_binary_target_dir"
nydus_repo_dir="${GOPATH}/src/github.com/dragonflyoss/image-service"
nydus_repo=${nydus_repo:-"https://github.com/dragonflyoss/image-service"}
nydus_version=${nydus_version:-"v2.2.3"}
nydus_version=${nydus_version:-"main"}

arch="$(uname -m)"

Expand All @@ -38,6 +39,20 @@ clone_nydus_snapshotter_repo() {
fi
}

clone_nydus_repo() {
add_repo_to_git_safe_directory "${nydus_repo_dir}"

if [ ! -d "${nydus_repo_dir}" ]; then
mkdir -p "${nydus_repo_dir}"
git clone ${nydus_repo} "${nydus_repo_dir}" || true
if [ "$nydus_version" != "main" ];then
pushd "${nydus_repo_dir}"
git checkout "${nydus_version}"
popd
fi
fi
}

build_nydus_snapshotter() {
pushd "${nydus_snapshotter_repo_dir}"
if [ "${arch}" = "s390x" ]; then
Expand All @@ -51,6 +66,19 @@ build_nydus_snapshotter() {
popd >/dev/null
}

build_nydus_image() {
if [ "${arch}" = "s390x" ]; then
echo "Skip to build nydus for ${arch}, it doesn't work for ${arch} now."
return
fi
pushd "${nydus_repo_dir}"
make release

sudo install -D -m 755 "target/release/nydus-image" "${nydus_image_binary_target_dir}/nydus-image"
rm -rf "${nydus_repo_dir}/target"
popd >/dev/null
}

download_nydus_snapshotter_config() {
tmp_dir=$(mktemp -d -t install-nydus-snapshotter-config-tmp.XXXXXXXXXX)
curl -L https://raw.githubusercontent.com/containerd/nydus-snapshotter/${nydus_snapshotter_version}/misc/snapshotter/config-coco-guest-pulling.toml -o "${tmp_dir}/config-coco-guest-pulling.toml"
Expand All @@ -65,6 +93,7 @@ download_nydus_from_tarball() {
echo "Skip to download nydus for ${arch}, it doesn't work for ${arch} now."
return
fi

local goarch="$(${cidir}/kata-arch.sh --golang)"
local tarball_url="${nydus_repo}/releases/download/${nydus_version}/nydus-static-${nydus_version}-linux-${goarch}.tgz"
echo "Download tarball from ${tarball_url}"
Expand All @@ -73,7 +102,8 @@ download_nydus_from_tarball() {
sudo install -D -m 755 "${tmp_dir}/nydus-image" "${target_dir}/bin/"
}

download_nydus_from_tarball
clone_nydus_repo
#download_nydus_from_tarball
clone_nydus_snapshotter_repo
build_nydus_snapshotter
download_nydus_snapshotter_config
Expand Down

0 comments on commit a3620ba

Please sign in to comment.