blob: 6ec0f85972f1f9d55d2a12c86b0a19cc8993527b [file] [log] [blame]
Patrick Steinhardt40c60f42024-04-12 06:44:17 +02001#!/bin/sh
Lars Schneider657343a2017-09-10 16:44:28 +02002#
3# Install dependencies required to build and test Git on Linux and macOS
4#
5
Johannes Schindelinc2160f22019-01-27 15:26:50 -08006. ${0%/*}/lib.sh
Lars Schneider657343a2017-09-10 16:44:28 +02007
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +02008begin_group "Install dependencies"
9
Jiang Xin31a19522022-11-25 17:59:53 +080010P4WHENCE=https://cdist2.perforce.com/perforce/r21.2
Junio C Hamanof67242c2017-09-11 10:18:29 +090011LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
Patrick Steinhardt04ba2c72024-04-12 06:44:43 +020012JGITWHENCE=https://repo.eclipse.org/content/groups/releases//org/eclipse/jgit/org.eclipse.jgit.pgm/6.8.0.202311291450-r/org.eclipse.jgit.pgm-6.8.0.202311291450-r.sh
Lars Schneider657343a2017-09-10 16:44:28 +020013
Patrick Steinhardt11d3f1a2024-04-12 06:44:07 +020014# Make sudo a no-op and execute the command directly when running as root.
15# While using sudo would be fine on most platforms when we are root already,
16# some platforms like e.g. Alpine Linux do not have sudo available by default
17# and would thus break.
18if test "$(id -u)" -eq 0
19then
20 sudo () {
21 "$@"
22 }
23fi
24
Patrick Steinhardt2d65e5b2024-04-12 06:43:57 +020025case "$distro" in
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +020026alpine-*)
27 apk add --update shadow sudo build-base curl-dev openssl-dev expat-dev gettext \
28 pcre2-dev python3 musl-libintl perl-utils ncurses \
29 apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \
Patrick Steinhardt9fd36932024-05-27 13:45:47 +020030 bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty >/dev/null
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +020031 ;;
32fedora-*)
33 dnf -yq update >/dev/null &&
34 dnf -yq install make gcc findutils diffutils perl python3 gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel >/dev/null
35 ;;
Jiang Xin01784202022-11-25 17:59:51 +080036ubuntu-*)
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +020037 # Required so that apt doesn't wait for user input on certain packages.
38 export DEBIAN_FRONTEND=noninteractive
39
SZEDER Gábor0f0c5112018-11-01 12:47:14 +010040 sudo apt-get -q update
Patrick Steinhardt21bcb4a2024-04-12 06:44:12 +020041 sudo apt-get -q -y install \
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +020042 language-pack-is libsvn-perl apache2 cvs cvsps git gnupg subversion \
Patrick Steinhardt04ba2c72024-04-12 06:44:43 +020043 make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
Patrick Steinhardt21bcb4a2024-04-12 06:44:12 +020044 tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \
Patrick Steinhardt9fd36932024-05-27 13:45:47 +020045 libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +020046 ${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE
Patrick Steinhardt21bcb4a2024-04-12 06:44:12 +020047
Patrick Steinhardtd1ef3d32024-04-12 06:44:22 +020048 mkdir --parents "$CUSTOM_PATH"
49 wget --quiet --directory-prefix="$CUSTOM_PATH" \
Patrick Steinhardt40c60f42024-04-12 06:44:17 +020050 "$P4WHENCE/bin.linux26x86_64/p4d" "$P4WHENCE/bin.linux26x86_64/p4"
Patrick Steinhardtca44ef32024-04-12 06:44:37 +020051 chmod a+x "$CUSTOM_PATH/p4d" "$CUSTOM_PATH/p4"
Patrick Steinhardt21bcb4a2024-04-12 06:44:12 +020052
Patrick Steinhardt40c60f42024-04-12 06:44:17 +020053 wget --quiet "$LFSWHENCE/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
54 tar -xzf "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" \
Patrick Steinhardtd1ef3d32024-04-12 06:44:22 +020055 -C "$CUSTOM_PATH" --strip-components=1 "git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs"
Patrick Steinhardt40c60f42024-04-12 06:44:17 +020056 rm "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
Patrick Steinhardt04ba2c72024-04-12 06:44:43 +020057
58 wget --quiet "$JGITWHENCE" --output-document="$CUSTOM_PATH/jgit"
59 chmod a+x "$CUSTOM_PATH/jgit"
Lars Schneider657343a2017-09-10 16:44:28 +020060 ;;
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +020061ubuntu32-*)
62 sudo linux32 --32bit i386 sh -c '
63 apt update >/dev/null &&
64 apt install -y build-essential libcurl4-openssl-dev \
65 libssl-dev libexpat-dev gettext python >/dev/null
66 '
67 ;;
Ævar Arnfjörð Bjarmasond1119222022-12-06 20:57:56 +010068macos-*)
SZEDER Gáboraf8ed042019-07-03 12:47:48 +020069 export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
Junio C Hamanof67242c2017-09-11 10:18:29 +090070 # Uncomment this if you want to run perf tests:
71 # brew install gnu-time
Junio C Hamanof67242c2017-09-11 10:18:29 +090072 brew link --force gettext
Patrick Steinhardtc4b84b12024-01-18 11:22:58 +010073
Patrick Steinhardtd1ef3d32024-04-12 06:44:22 +020074 mkdir -p "$CUSTOM_PATH"
Patrick Steinhardt40c60f42024-04-12 06:44:17 +020075 wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
Patrick Steinhardtd1ef3d32024-04-12 06:44:22 +020076 tar -xf helix-core-server.tgz -C "$CUSTOM_PATH" p4 p4d &&
77 sudo xattr -d com.apple.quarantine "$CUSTOM_PATH/p4" "$CUSTOM_PATH/p4d" 2>/dev/null || true
Patrick Steinhardt40c60f42024-04-12 06:44:17 +020078 rm helix-core-server.tgz
Ævar Arnfjörð Bjarmason707d2f22021-11-23 17:29:11 +010079
80 if test -n "$CC_PACKAGE"
81 then
82 BREW_PACKAGE=${CC_PACKAGE/-/@}
83 brew install "$BREW_PACKAGE"
84 brew link "$BREW_PACKAGE"
85 fi
Lars Schneider657343a2017-09-10 16:44:28 +020086 ;;
Ævar Arnfjörð Bjarmason707d2f22021-11-23 17:29:11 +010087esac
88
89case "$jobname" in
SZEDER Gábor0f0c5112018-11-01 12:47:14 +010090StaticAnalysis)
91 sudo apt-get -q update
Johannes Schindelin411e4f42019-10-01 04:16:26 -070092 sudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \
Đoàn Trần Công Danh61432dd2020-04-11 00:18:07 +070093 libexpat-dev gettext make
SZEDER Gábor0f0c5112018-11-01 12:47:14 +010094 ;;
Jeff King27f45cc2021-07-26 14:22:27 -040095sparse)
96 sudo apt-get -q update -q
97 sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \
98 libexpat-dev gettext zlib1g-dev
99 ;;
SZEDER Gábor0f0c5112018-11-01 12:47:14 +0100100Documentation)
101 sudo apt-get -q update
Đoàn Trần Công Danh61432dd2020-04-11 00:18:07 +0700102 sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make
SZEDER Gáborf34a1bd2019-03-29 13:35:18 +0100103
104 test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
Johannes Schindelin4fef6322020-04-11 00:18:08 +0700105 sudo gem install --version 1.5.8 asciidoctor
SZEDER Gábor0f0c5112018-11-01 12:47:14 +0100106 ;;
Lars Schneider657343a2017-09-10 16:44:28 +0200107esac
108
Carlo Marcelo Arenas Belóncde6b9b2022-05-12 15:39:37 -0700109if type p4d >/dev/null 2>&1 && type p4 >/dev/null 2>&1
SZEDER Gábor0f0c5112018-11-01 12:47:14 +0100110then
111 echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)"
Jiang Xin4137c842022-11-25 17:59:52 +0800112 p4d -V
SZEDER Gábor0f0c5112018-11-01 12:47:14 +0100113 echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)"
Jiang Xin4137c842022-11-25 17:59:52 +0800114 p4 -V
Carlo Marcelo Arenas Belóncde6b9b2022-05-12 15:39:37 -0700115else
116 echo >&2 "WARNING: perforce wasn't installed, see above for clues why"
SZEDER Gábor0f0c5112018-11-01 12:47:14 +0100117fi
Patrick Steinhardt04ba2c72024-04-12 06:44:43 +0200118
Carlo Marcelo Arenas Belóncde6b9b2022-05-12 15:39:37 -0700119if type git-lfs >/dev/null 2>&1
SZEDER Gábor0f0c5112018-11-01 12:47:14 +0100120then
121 echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)"
122 git-lfs version
Carlo Marcelo Arenas Belóncde6b9b2022-05-12 15:39:37 -0700123else
124 echo >&2 "WARNING: git-lfs wasn't installed, see above for clues why"
SZEDER Gábor0f0c5112018-11-01 12:47:14 +0100125fi
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +0200126
Patrick Steinhardt04ba2c72024-04-12 06:44:43 +0200127if type jgit >/dev/null 2>&1
128then
129 echo "$(tput setaf 6)JGit Version$(tput sgr0)"
130 jgit version
131else
132 echo >&2 "WARNING: JGit wasn't installed, see above for clues why"
133fi
134
Patrick Steinhardt9cdeb342024-04-12 06:44:32 +0200135end_group "Install dependencies"