From e79bddb19f770523d66e51a152923e1f2344c04d Mon Sep 17 00:00:00 2001 From: Yujia Qiao Date: Mon, 1 Nov 2021 09:35:05 +0800 Subject: [PATCH] feat: Support installation on arch (#5350) --- docs/en/latest/install-dependencies.md | 4 +++- docs/zh/latest/install-dependencies.md | 4 +++- utils/install-dependencies.sh | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/en/latest/install-dependencies.md b/docs/en/latest/install-dependencies.md index eb806879..048e580b 100644 --- a/docs/en/latest/install-dependencies.md +++ b/docs/en/latest/install-dependencies.md @@ -44,7 +44,9 @@ title: Install Dependencies Run the following command to install Apache APISIX's dependencies on a supported operating system. -Supported OS versions: CentOS7, Fedora31 & 32, Ubuntu 16.04 & 18.04, Debian 9 & 10, Mac OSX +Supported OS versions: CentOS7, Fedora31 & 32, Ubuntu 16.04 & 18.04, Debian 9 & 10, Arch Linux, Mac OSX + +Note that in the case of Arch Linux, we use `openresty` from the AUR, thus requiring a AUR helper. For now `yay` and `pacaur` are supported. ``` curl https://raw.githubusercontent.com/apache/apisix/master/utils/install-dependencies.sh -sL | bash - diff --git a/docs/zh/latest/install-dependencies.md b/docs/zh/latest/install-dependencies.md index 07d27cef..1d97dc97 100644 --- a/docs/zh/latest/install-dependencies.md +++ b/docs/zh/latest/install-dependencies.md @@ -44,7 +44,9 @@ title: 安装依赖 在支持的操作系统上运行以下指令即可安装 Apache APISIX dependencies。 -支持的操作系统版本: CentOS 7, Fedora 31 & 32, Ubuntu 16.04 & 18.04, Debian 9 & 10, Mac OSX。 +支持的操作系统版本: CentOS 7, Fedora 31 & 32, Ubuntu 16.04 & 18.04, Debian 9 & 10, Arch Linux, Mac OSX。 + +注意,对于 Arch Linux 来说,我们使用 AUR 源中的 `openresty`,所以需要 AUR Helper 才能正常安装。目前支持 `yay` 和 `pacaur`。 ``` curl https://raw.githubusercontent.com/apache/apisix/master/utils/install-dependencies.sh -sL | bash - diff --git a/utils/install-dependencies.sh b/utils/install-dependencies.sh index 19a7e338..e7cc5da0 100755 --- a/utils/install-dependencies.sh +++ b/utils/install-dependencies.sh @@ -19,6 +19,29 @@ set -ex +function detect_aur_helper() { + if [[ $(which yay) ]]; then + AUR_HELPER=yay + elif [[ $(which pacaur) ]]; then + AUR_HELPER=pacaur + else + echo No available AUR helpers found. Please specify your AUR helper by AUR_HELPER. + exit -1 + fi +} + +function install_dependencies_with_aur() { + detect_aur_helper + $AUR_HELPER -S openresty --noconfirm + sudo pacman -S openssl --noconfirm + + export OPENRESTY_PREFIX=/opt/openresty + + sudo mkdir $OPENRESTY_PREFIX/openssl + sudo ln -s /usr/include $OPENRESTY_PREFIX/openssl/include + sudo ln -s /usr/lib $OPENRESTY_PREFIX/openssl/lib +} + # Install dependencies on centos and fedora function install_dependencies_with_yum() { # add OpenResty source @@ -66,6 +89,8 @@ function multi_distro_installation() { install_dependencies_with_apt "debian" elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then install_dependencies_with_apt "ubuntu" + elif grep -Eqi "Arch" /etc/issue || grep -Eq "Arch" /etc/*-release; then + install_dependencies_with_aur else echo "Non-supported operating system version" fi