summaryrefslogtreecommitdiff
path: root/scripts/install-build-deps.sh
diff options
context:
space:
mode:
authorRyo Nakamura <upa@haeena.net>2024-02-11 14:04:43 +0900
committerRyo Nakamura <upa@haeena.net>2024-02-11 14:04:43 +0900
commit45ba6b077ede13170855a9a985d06c067fd52a24 (patch)
tree9e43010eb8be502c7af6eb8055c3e704f36ece12 /scripts/install-build-deps.sh
parentd819f715c8ab5abd3c02459eb9967cfc00136e34 (diff)
install-build-deps.sh has --dont-install and --platform options.
All docker files do not call isntall-build-deps.sh. Instead, cmake passes REQUIREDPKGS to Dockerfiles, which is derived from the output of ./scripts/install-build-deps.sh --dont-install --platform PLATFORM. This change enables caching package installaion during docker build.
Diffstat (limited to 'scripts/install-build-deps.sh')
-rwxr-xr-xscripts/install-build-deps.sh53
1 files changed, 45 insertions, 8 deletions
diff --git a/scripts/install-build-deps.sh b/scripts/install-build-deps.sh
index 5c46a61..3ec3d49 100755
--- a/scripts/install-build-deps.sh
+++ b/scripts/install-build-deps.sh
@@ -3,34 +3,71 @@
# Install build dpenedencies.
set -e
-set -u
+#set -u
+
+function print_help() {
+ echo "$0 [options]"
+ echo " --dont-install Print required packages."
+ echo " --platform [PLATFORM] PLATFORM is Kernel-ID, e.g., Linux-ubuntu."
+ echo " Automatically detected if not specified."
+}
platform=$(uname -s)
+doinstall=1
if [ -e /etc/os-release ]; then
source /etc/os-release
platform=${platform}-${ID}
fi
-set -x
+while getopts h-: opt; do
+ optarg="${!OPTIND}"
+ [[ "$opt" = - ]] && opt="-$OPTARG"
+ case "-${opt}" in
+ --dont-install)
+ doinstall=0
+ ;;
+ --platform)
+ platform=$optarg
+ shift
+ ;;
+ -h)
+ print_help
+ exit 0
+ ;;
+ *)
+ print_help
+ exit 1
+ ;;
+ esac
+done
case $platform in
Darwin)
- brew install openssl@1.1
+ cmd="brew install"
+ pkgs="openssl@1.1"
;;
Linux-ubuntu*)
- apt-get install --no-install-recommends -y \
- gcc make cmake zlib1g-dev libssl-dev libkrb5-dev
+ cmd="apt-get install --no-install-recommends -y"
+ pkgs="gcc make cmake zlib1g-dev libssl-dev libkrb5-dev"
;;
Linux-centos* | Linux-rhel* | Linux-rocky* | Linux-almalinux)
- yum install -y \
- gcc make cmake zlib-devel openssl-devel rpm-build
+ cmd="yum install -y"
+ pkgs="gcc make cmake zlib-devel openssl-devel rpm-build"
;;
FreeBSD-freebsd)
- pkg install cmake
+ cmd="pkg install"
+ pkgs="cmake"
;;
*)
echo "unsupported platform: $platform"
exit 1
;;
esac
+
+if [ $doinstall -gt 0 ]; then
+ echo do "$cmd $pkgs"
+ $cmd $pkgs
+else
+ echo $pkgs
+fi