Adjust sys_install usage

This commit is contained in:
Taiki Endo
2026-11-03 18:58:55 +09:00
parent 51eaf0f90c
commit 0e788e25d5
+116 -99
View File
@@ -109,53 +109,57 @@ download_and_extract() {
*.tar.gz | *.tgz) *.tar.gz | *.tgz)
tar_args+=('xzf') tar_args+=('xzf')
if ! type -P gzip >/dev/null; then if ! type -P gzip >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian | fedora | suse | arch | alpine) printf '::group::Install packages required for installation (gzip)\n'
printf '::group::Install packages required for installation (gzip)\n' sys_install gzip
sys_install gzip printf '::endgroup::\n'
printf '::endgroup::\n' else
;; warn "this action requires gzip to install ${tool}"
esac fi
fi fi
;; ;;
*.gz) *.gz)
if ! type -P gzip >/dev/null; then if ! type -P gzip >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian | fedora | suse | arch | alpine) printf '::group::Install packages required for installation (gzip)\n'
printf '::group::Install packages required for installation (gzip)\n' sys_install gzip
sys_install gzip printf '::endgroup::\n'
printf '::endgroup::\n' else
;; warn "this action requires gzip to install ${tool}"
esac fi
fi fi
;; ;;
*.tar.bz2 | *.tbz2) *.tar.bz2 | *.tbz2)
tar_args+=('xjf') tar_args+=('xjf')
if ! type -P bzip2 >/dev/null; then if ! type -P bzip2 >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian | fedora | suse | arch | alpine) printf '::group::Install packages required for installation (bzip2)\n'
printf '::group::Install packages required for installation (bzip2)\n' sys_install bzip2
sys_install bzip2 printf '::endgroup::\n'
printf '::endgroup::\n' else
;; warn "this action requires bzip2 to install ${tool}"
esac fi
fi fi
;; ;;
*.tar.xz | *.txz) *.tar.xz | *.txz)
tar_args+=('xJf') tar_args+=('xJf')
if ! type -P xz >/dev/null; then if ! type -P xz >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian) case "${base_distro}" in
printf '::group::Install packages required for installation (xz-utils)\n' debian)
sys_install xz-utils printf '::group::Install packages required for installation (xz-utils)\n'
printf '::endgroup::\n' sys_install xz-utils
;; printf '::endgroup::\n'
fedora | suse | arch | alpine) ;;
printf '::group::Install packages required for installation (xz)\n' *)
sys_install xz printf '::group::Install packages required for installation (xz)\n'
printf '::endgroup::\n' sys_install xz
;; printf '::endgroup::\n'
esac ;;
esac
else
warn "this action requires xz to install ${tool}"
fi
fi fi
;; ;;
*.tar.zst | *.tzst) *.tar.zst | *.tzst)
@@ -172,24 +176,24 @@ download_and_extract() {
;; ;;
*.zip) *.zip)
if ! type -P unzip >/dev/null; then if ! type -P unzip >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian | fedora | suse | arch | alpine) printf '::group::Install packages required for installation (unzip)\n'
printf '::group::Install packages required for installation (unzip)\n' sys_install unzip
sys_install unzip printf '::endgroup::\n'
printf '::endgroup::\n' else
;; warn "this action requires unzip to install ${tool}"
esac fi
fi fi
;; ;;
*.deb) *.deb)
if ! type -P dpkg-deb >/dev/null; then if ! type -P dpkg-deb >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian | fedora | suse | arch | alpine) printf '::group::Install packages required for installation (dpkg)\n'
printf '::group::Install packages required for installation (dpkg)\n' sys_install dpkg
sys_install dpkg printf '::endgroup::\n'
printf '::endgroup::\n' else
;; warn "this action requires dpkg-deb to install ${tool}"
esac fi
fi fi
;; ;;
esac esac
@@ -548,19 +552,25 @@ case "${RUNNER_OS}" in
# /etc/os-release is available on Debian 7+ # /etc/os-release is available on Debian 7+
base_distro=debian base_distro=debian
elif [[ -e /etc/os-release ]]; then elif [[ -e /etc/os-release ]]; then
if grep -Eq '^ID_LIKE=' /etc/os-release; then base_distro=$(grep -E '^ID_LIKE=' /etc/os-release || true)
base_distro=$(grep -E '^ID_LIKE=' /etc/os-release | cut -d= -f2) case "${base_distro}" in
case "${base_distro}" in *debian*) base_distro=debian ;;
*debian*) base_distro=debian ;; *fedora*) base_distro=fedora ;;
*fedora*) base_distro=fedora ;; *suse*) base_distro=suse ;;
*suse*) base_distro=suse ;; *arch*) base_distro=arch ;;
*arch*) base_distro=arch ;; *alpine*) base_distro=alpine ;;
*alpine*) base_distro=alpine ;; *)
esac base_distro=$(grep -E '^ID=' /etc/os-release)
else base_distro="${base_distro#*=}"
base_distro=$(grep -E '^ID=' /etc/os-release | cut -d= -f2) base_distro="${base_distro//\"/}"
fi case "${base_distro}" in
base_distro="${base_distro//\"/}" debian | fedora | suse | arch | alpine) ;;
*) base_distro='' ;;
esac
;;
esac
else
base_distro=''
fi fi
case "${base_distro}" in case "${base_distro}" in
fedora) fedora)
@@ -681,39 +691,42 @@ manifest_dir="${GITHUB_ACTION_PATH}/manifests"
case "${host_os}" in case "${host_os}" in
linux) linux)
if ! type -P jq >/dev/null || ! type -P curl >/dev/null || ! type -P tar >/dev/null; then if ! type -P jq >/dev/null || ! type -P curl >/dev/null || ! type -P tar >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian | fedora | suse | arch | alpine) printf '::group::Install packages required for installation (jq, curl, and/or tar)\n'
printf '::group::Install packages required for installation (jq, curl, and/or tar)\n' sys_packages=()
sys_packages=() if ! type -P curl >/dev/null; then
if ! type -P curl >/dev/null; then # Note that we do not fallback to wget.
sys_packages+=(ca-certificates curl) # Common containers do not install GNU Wget by default and BusyBox wget installed in some
fi # common containers by default lacks necessary security options (--https-only --secure-protocol=TLSv1_2).
if ! type -P tar >/dev/null; then sys_packages+=(ca-certificates curl)
sys_packages+=(tar) fi
fi if ! type -P tar >/dev/null; then
if [[ "${dnf:-}" == "yum" ]]; then # TODO: this is not necessary for some tools using unzip.
# On RHEL7-based distribution jq requires EPEL sys_packages+=(tar)
if ! type -P jq >/dev/null; then fi
sys_packages+=(epel-release) if [[ "${dnf:-}" == "yum" ]]; then
sys_install "${sys_packages[@]}" # On RHEL7-based distribution jq requires EPEL
sys_install jq --enablerepo=epel if ! type -P jq >/dev/null; then
else sys_packages+=(epel-release)
sys_install "${sys_packages[@]}" sys_install "${sys_packages[@]}"
fi sys_install jq --enablerepo=epel
else else
if ! type -P jq >/dev/null; then
# https://github.com/taiki-e/install-action/issues/521
if [[ "${base_distro}" == "arch" ]]; then
sys_packages+=(glibc)
fi
sys_packages+=(jq)
fi
sys_install "${sys_packages[@]}" sys_install "${sys_packages[@]}"
fi fi
printf '::endgroup::\n' else
;; if ! type -P jq >/dev/null; then
*) warn "this action requires at least jq and curl on non-Debian/Fedora/SUSE/Arch/Alpine-based Linux" ;; # https://github.com/taiki-e/install-action/issues/521
esac if [[ "${base_distro}" == "arch" ]]; then
sys_packages+=(glibc)
fi
sys_packages+=(jq)
fi
sys_install "${sys_packages[@]}"
fi
printf '::endgroup::\n'
else
warn "this action requires at least jq and curl on non-Debian/Fedora/SUSE/Arch/Alpine-based Linux"
fi
fi fi
;; ;;
macos) macos)
@@ -913,13 +926,13 @@ for tool in "${tools[@]}"; do
mkdir -p -- "${include_dir}" mkdir -p -- "${include_dir}"
fi fi
if ! type -P unzip >/dev/null; then if ! type -P unzip >/dev/null; then
case "${base_distro}" in if [[ -n "${base_distro}" ]]; then
debian | fedora | suse | arch | alpine) printf '::group::Install packages required for installation (unzip)\n'
printf '::group::Install packages required for installation (unzip)\n' sys_install unzip
sys_install unzip printf '::endgroup::\n'
printf '::endgroup::\n' else
;; warn "this action requires unzip to install ${tool}"
esac fi
fi fi
mkdir -p -- "${tmp_dir}" mkdir -p -- "${tmp_dir}"
( (
@@ -950,7 +963,9 @@ for tool in "${tools[@]}"; do
*) bail "unsupported host OS '${host_os}' for ${tool}" ;; *) bail "unsupported host OS '${host_os}' for ${tool}" ;;
esac esac
# libc6-dbg is needed to run Valgrind # libc6-dbg is needed to run Valgrind
apt_install libc6-dbg case "${base_distro}" in
debian) sys_install libc6-dbg ;;
esac
# Use snap to install the latest Valgrind # Use snap to install the latest Valgrind
# https://snapcraft.io/install/valgrind/ubuntu # https://snapcraft.io/install/valgrind/ubuntu
snap_install valgrind --classic snap_install valgrind --classic
@@ -1015,7 +1030,9 @@ for tool in "${tools[@]}"; do
cyclonedx) cyclonedx)
case "${host_os}" in case "${host_os}" in
linux) linux)
apt_install libicu-dev case "${base_distro}" in
debian) sys_install libicu-dev ;;
esac
;; ;;
esac esac
;; ;;