Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 15 additions & 4 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
images: ['fedora:37', 'fedora:39', 'ubuntu:22', 'centos:9']
images: ['fedora:37', 'fedora:39', 'centos:9']
fail-fast: false

steps:
Expand All @@ -18,7 +18,8 @@ jobs:

- name: Run
run: bash tests/test.sh ${{ matrix.images }}
install_master:

install_repo:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -29,8 +30,18 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set QEMU_REF to master
run: echo 'QEMU_REF=master' >> dependencies.sh
- name: Disable QEMU_PACKAGE
run: |
echo 'QEMU_PACKAGE=' > bootstrap
echo 'QEMU_GIT=https://github.com/qemu/qemu.git' >> bootstrap
echo 'QEMU_REF=v9.0.0' >> bootstrap


- name: Disable VIRTIOFSD_PACKAGE
run: |
echo 'VIRTIOFSD_PACKAGE=' >> bootstrap
echo 'VIRTIOFSD_GIT=https://gitlab.com/virtio-fs/virtiofsd.git' >> bootstrap
echo 'VIRTIOFSD_REF=v1.11.0' >> bootstrap

- name: Run
run: bash tests/test.sh ${{ matrix.images }}
10 changes: 6 additions & 4 deletions dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ DEPENDENCIES=(
AUTOHCK
)

VIRTIOFSD_GIT=https://gitlab.com/virtio-fs/virtiofsd.git
VIRTIOFSD_REF=v1.11.0
# VIRTIOFSD_GIT=https://gitlab.com/virtio-fs/virtiofsd.git
# VIRTIOFSD_REF=v1.11.0
# VIRTIOFSD_DIR=
VIRTIOFSD_PACKAGE=TRUE

QEMU_GIT=https://github.com/qemu/qemu.git
QEMU_REF=v9.0.0
# QEMU_GIT=https://github.com/qemu/qemu.git
# QEMU_REF=v9.0.0
# QEMU_DIR=
QEMU_PACKAGE=TRUE

HLK_SETUP_SCRIPTS_GIT=https://github.com/HCK-CI/HLK-Setup-Scripts.git
HLK_SETUP_SCRIPTS_REF=d003b5e7209f70432acba34ab30e8269d64dfd2b
Expand Down
90 changes: 51 additions & 39 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,66 +62,78 @@ for dependency in "${DEPENDENCIES[@]}"; do
dependency_dir_var="${dependency}_DIR"
dependency_git_var="${dependency}_GIT"
dependency_ref_var="${dependency}_REF"
dependency_package_var="${dependency}_PACKAGE"

if is_redefined_by_file "${dependency_ref_var}" "${dependencies}"; then
echo "${dependency_ref_var}='${!dependency_ref_var}'" >>"${bootstrap}"
fi

repo_url="${!dependency_git_var}"
repo_name="$(basename ${repo_url})"
repo_ref="${!dependency_ref_var}"

if [ -z "${!dependency_dir_var}" ]; then
repo_path="${repos_dir}/${repo_name}"
else
log_info "${dependency} dir overridden: ${!dependency_dir_var}"
repo_path="${!dependency_dir_var}"
if is_redefined_by_file "${dependency_package_var}" "${dependencies}"; then
echo "${dependency_package_var}='${!dependency_package_var}'" >>"${bootstrap}"
fi
echo "${dependency_dir_var}='${repo_path}'" >>"${bootstrap}"

source "${bootstrap}"
dependency_package="${!dependency_package_var}"

if [ -d "${repo_path}" ]; then
(
cd "${repo_path}"
if [ -n "${dependency_package}" ]; then
log_info "Package for ${dependency} is defined"
echo "${dependency_package_var}='${!dependency_package_var}'" >>"${bootstrap}"
else
repo_url="${!dependency_git_var}"
repo_name="$(basename ${repo_url})"
repo_ref="${!dependency_ref_var}"

git fetch
mapfile -d ' ' -t current_refs < <(git log -n1 --format='%h %H %D')
if [ -z "${!dependency_dir_var}" ]; then
repo_path="${repos_dir}/${repo_name}"
else
log_info "${dependency} dir overridden: ${!dependency_dir_var}"
repo_path="${!dependency_dir_var}"
fi
echo "${dependency_dir_var}='${repo_path}'" >>"${bootstrap}"

already_ref=0
for ref in "${current_refs[@]}"; do
if [ "$(echo ${ref} | tr -d '\n' | tr -d ',')" == "${repo_ref}" ]; then
already_ref=1
fi
done
source "${bootstrap}"

if [ -d "${repo_path}" ]; then
(
cd "${repo_path}"

if [ "${already_ref}" == "0" ]; then
git fetch
mapfile -d ' ' -t current_refs < <(git log -n1 --format='%h %H %D')

already_ref=0
for ref in "${current_refs[@]}"; do
if [ "$(echo ${ref} | tr -d '\n' | tr -d ',')" == "${repo_ref}" ]; then
already_ref=1
fi
done

if [ "${already_ref}" == "0" ]; then
git fetch
git checkout "${repo_ref}"
if [ "$(LC_ALL=C type -t "post_clone_${dependency}")" == "function" ]; then
log_info "Execution post_clone_${dependency} ${repo_path}"
"post_clone_${dependency}" "${repo_path}"
fi
else
log_info "${repo_name} already at ${repo_ref}"
fi
)
else
git clone "${repo_url}" "${repo_path}"
(
cd "${repo_path}"
git checkout "${repo_ref}"

if [ "$(LC_ALL=C type -t "post_clone_${dependency}")" == "function" ]; then
log_info "Execution post_clone_${dependency} ${repo_path}"
"post_clone_${dependency}" "${repo_path}"
fi
else
log_info "${repo_name} already at ${repo_ref}"
fi
)
else
git clone "${repo_url}" "${repo_path}"
(
cd "${repo_path}"
git checkout "${repo_ref}"

if [ "$(LC_ALL=C type -t "post_clone_${dependency}")" == "function" ]; then
log_info "Execution post_clone_${dependency} ${repo_path}"
"post_clone_${dependency}" "${repo_path}"
fi
)
)
fi
fi

if [ "$(LC_ALL=C type -t "process_${dependency}")" == "function" ]; then
log_info "Execution "process_${dependency}" ${repo_path}"
"process_${dependency}" "${repo_path}"
"process_${dependency}" "${repo_path}" "${dependency_package}"
fi
done

Expand Down
94 changes: 78 additions & 16 deletions qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,38 @@ install_deps_qemu() {
esac
}

install_qemu_package() {
log_info "Installing QEMU package"

lsb_dist="$( get_distribution )"

case "$lsb_dist" in
ubuntu)
sudo apt-get update
sudo apt-get install -y qemu-system
;;
centos | rhel)
sudo dnf makecache
sudo dnf install -y qemu-kvm
;;
fedora)
case "$( get_distribution_variant )" in
silverblue)
rpm-ostree install -A --allow-inactive --idempotent qemu
;;
*)
sudo dnf makecache
sudo dnf install -y qemu
;;
esac
;;

*)
log_fatal "Distributive '$lsb_dist' is unsupported. Please compile QEMU manually."
;;
esac
}

compile_qemu() {
log_info "Compiling QEMU"

Expand All @@ -86,8 +118,6 @@ compile_qemu() {
}

check_qemu() {
qemu_dir="$(realpath "${1}")"

qemu_args=(
-monitor stdio
-nographic
Expand All @@ -102,18 +132,19 @@ check_qemu() {
fi

unshare --user --net --map-root-user \
"${qemu_dir}/build/qemu-system-x86_64" "${qemu_args[@]}" <<< q
[ -f "${qemu_dir}/build/qemu-img" ] || return 1
[ -f "${qemu_dir}/build/contrib/ivshmem-server/ivshmem-server" ] || return 1
"${QEMU_BIN}" "${qemu_args[@]}" <<< q
[ -f "${QEMU_IMG_BIN}" ] || return 1

if [ ! -f "${qemu_dir}/build/tools/virtiofsd/virtiofsd" ]; then
[ -f "${FS_DAEMON_BIN}" ] || return 1
if [ -n "${IVSHMEM_SERVER_BIN}" ]; then
[ -f "${IVSHMEM_SERVER_BIN}" ] || return 1
fi

[ -f "${FS_DAEMON_BIN}" ] || return 1

return 0
}

get_config_qemu() {
get_config_qemu_repo() {
qemu_dir="$(realpath "${1}")"

echo "QEMU_BIN='${qemu_dir}/build/qemu-system-x86_64'"
Expand All @@ -122,25 +153,56 @@ get_config_qemu() {
[ -f "${FS_DAEMON_BIN}" ] || echo "FS_DAEMON_BIN='${qemu_dir}/build/tools/virtiofsd/virtiofsd'"
}

get_config_qemu_package() {
lsb_dist="$( get_distribution )"

case "$lsb_dist" in
ubuntu|fedora)
QEMU_BIN='/usr/bin/qemu-system-x86_64'
QEMU_IMG_BIN='/usr/bin/qemu-img'
;;
centos|rhel)
QEMU_BIN='/usr/libexec/qemu-kvm'
QEMU_IMG_BIN='/usr/bin/qemu-img'
;;
*)
log_fatal "Distributive '$lsb_dist' is unsupported. Please compile QEMU manually."
;;
esac

echo "QEMU_BIN='${QEMU_BIN}'"
echo "QEMU_IMG_BIN='${QEMU_IMG_BIN}'"
}

post_clone_QEMU() {
log_info "QEMU repository post clone"

qemu_dir="$(realpath "${1}")"

install_deps_qemu
compile_qemu "${qemu_dir}"
if check_qemu "${qemu_dir}"; then
log "QEMU binary compiled successfully"
else
log_fatal "Can't find QEMU binary"
fi

log "QEMU binary compiled"
}

process_QEMU() {
log_info "QEMU repository custom processing"
log_info "QEMU dependency custom processing"

qemu_dir="$(realpath "${1}")"
qemu_package="${2}"

if [ "x${qemu_package}" == "x" ]; then
qemu_dir="$(realpath "${1}")"
get_config_qemu_repo "${qemu_dir}" >>"${bootstrap}"
else
install_qemu_package
get_config_qemu_package >>"${bootstrap}"
fi

source "${bootstrap}"

if ! check_qemu "${qemu_dir}"; then
log_fatal "Can't find QEMU binary"
fi

get_config_qemu "${qemu_dir}" >>"${bootstrap}"
echo >>"${bootstrap}"
}
55 changes: 51 additions & 4 deletions virtiofsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,38 @@ install_deps_virtiofsd() {
esac
}

install_virtiofsd_package() {
log_info "Installing virtiofsd package"

lsb_dist="$( get_distribution )"

case "$lsb_dist" in
ubuntu)
sudo apt-get update
sudo apt-get install -y virtiofsd
;;
rhel|centos)
sudo dnf makecache
sudo dnf install -y virtiofsd
;;
fedora)
case "$( get_distribution_variant )" in
silverblue)
rpm-ostree install -A --allow-inactive --idempotent virtiofsd
;;
*)
sudo dnf makecache
sudo dnf install -y virtiofsd
;;
esac
;;

*)
log_fatal "Distributive '$lsb_dist' is unsupported. Please compile QEMU manually."
;;
esac
}

install_rust() {
log_info "Installing Rust"

Expand Down Expand Up @@ -69,12 +101,20 @@ check_virtiofsd() {
return 0
}

get_config_virtiofsd() {
get_config_virtiofsd_repo() {
virtiofsd_dir="$(realpath "${1}")"

echo "FS_DAEMON_BIN='${virtiofsd_dir}/target/release/virtiofsd'"
}

get_config_virtiofsd_package() {
FS_DAEMON_BIN='/usr/libexec/virtiofsd'

[ -f "${FS_DAEMON_BIN}" ] || log_fatal "FS_DAEMON_BIN file '$FS_DAEMON_BIN' does not exist. Please configure virtiofsd manually."

echo "FS_DAEMON_BIN='${FS_DAEMON_BIN}'"
}

post_clone_VIRTIOFSD() {
log_info "VIRTIOFSD repository post clone"

Expand All @@ -95,10 +135,17 @@ post_clone_VIRTIOFSD() {
}

process_VIRTIOFSD() {
log_info "VIRTIOFSD repository custom processing"
log_info "VIRTIOFSD dependency custom processing"

virtiofsd_dir="$(realpath "${1}")"
virtiofsd_package="${2}"

if [ "x${virtiofsd_package}" == "x" ]; then
virtiofsd_dir="$(realpath "${1}")"
get_config_virtiofsd_repo "${virtiofsd_dir}" >>"${bootstrap}"
else
install_virtiofsd_package
get_config_virtiofsd_package >>"${bootstrap}"
fi

get_config_virtiofsd "${virtiofsd_dir}" >>"${bootstrap}"
echo >>"${bootstrap}"
}