Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions hack/install/install_runc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,65 @@

set -euo pipefail

readonly RUNC_VERSION="1.0.0-rc6-1"
# keep the first one only
GOPATH="${GOPATH%%:*}"

# runc::check_version checks the command and the version.
runc::check_version() {
local has_installed version
cd "$(dirname "${BASH_SOURCE[0]}")"
source "./check.sh"

has_installed="$(command -v runc || echo false)"
if [[ "${has_installed}" = "false" ]]; then
echo false
exit 0
fi
# runc::ubuntu::install_dependencies() install dependencies
# on ubuntu machine for make runc
runc::ubuntu::install_dependencies() {
sudo apt-get install -y libseccomp-dev/trusty-backports
}

# runc::centos::install_dependencies() install dependencies
# on centos machine for make runc
runc::centos::install_dependencies() {
sudo yum install libseccomp-dev
}

version="$(runc -v | head -1 | cut -d " " -f 3)"
if [[ "${RUNC_VERSION}" != "${version}" ]]; then
# runc::check_install checks the command and the version.
runc::check_install() {
local has_installed

has_installed="$(command -v runc || echo false)"
if [[ "${has_installed}" = "false" ]]; then
echo false
exit 0
return
fi

echo true
}

# runc::install downloads the binary from release url.
runc::install() {
local url

url="https://github.com/alibaba/runc/releases/download"
url="${url}/v${RUNC_VERSION}/runc.amd64"
local gopath

wget --quiet "${url}" -P /usr/local/bin
chmod +x /usr/local/bin/runc.amd64
mv /usr/local/bin/runc.amd64 /usr/local/bin/runc
gopath="${GOPATH}/src/github.com/opencontainers/runc"
git clone -b develop https://github.com/alibaba/runc.git "${gopath}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to update the package script https://github.com/pouchcontainer/project.

cd "${gopath}"
make
make install
}

main() {
local has_installed

has_installed="$(runc::check_version)"
has_installed="$(runc::check_install)"
if [[ "${has_installed}" = "true" ]]; then
echo "runc-${RUNC_VERSION} has been installed."
echo "runc has been installed."
exit 0
fi

echo ">>>> install runc-${RUNC_VERSION} <<<<"
echo ">>>> install runc <<<<"

os_dist="$(detect_os)"
if [[ "${os_dist}" = "Ubuntu" ]]; then
runc::ubuntu::install_dependencies
else
runc::centos::install_dependencies
fi
runc::install

# final check
Expand Down