diff --git a/builder/scripts/build-libjpeg-turbo b/builder/scripts/build-libjpeg-turbo index c6c2a03..49134ba 100755 --- a/builder/scripts/build-libjpeg-turbo +++ b/builder/scripts/build-libjpeg-turbo @@ -11,41 +11,12 @@ build_and_install() { } install_build_dependencies() { + install_packages cmake gcc ensure_libjpeg_is_fast - - if [ "$DISTRO" = centos ]; then - yum install -y cmake gcc - return - fi - if [ "$DISTRO" = oracle ]; then - dnf install -y cmake gcc - return - fi - if [ "$DISTRO" = opensuse ]; then - zypper install -y cmake gcc - return - fi - - apt-get update - apt-get install -y cmake gcc } ensure_libjpeg_is_fast() { - if [ "$DISTRO" = centos ]; then - yum install -y nasm - return - fi - if [ "$DISTRO" = oracle ]; then - dnf install -y nasm - return - fi - if [ "$DISTRO" = opensuse ]; then - zypper install -y nasm - return - fi - - apt-get update - apt-get install -y nasm + install_packages nasm } prepare_libjpeg_source() { diff --git a/builder/scripts/common.sh b/builder/scripts/common.sh index 9a2d6be..c066d73 100644 --- a/builder/scripts/common.sh +++ b/builder/scripts/common.sh @@ -12,4 +12,17 @@ detect_distro() { fi } +install_packages() { + local install_cmd=no-command-defined + + case "$DISTRO" in + centos) install_cmd="yum install -y" ;; + oracle) install_cmd="dnf install -y" ;; + opensuse) install_cmd="zypper install -y" ;; + *) install_cmd="apt-get update && apt-get install -y" + esac + + eval "$install_cmd $*" +} + detect_distro