Git fork
1#!/bin/sh
2#
3# Install dependencies required to build and test Git on Linux and macOS
4#
5
6. ${0%/*}/lib.sh
7
8begin_group "Install dependencies"
9
10P4WHENCE=https://cdist2.perforce.com/perforce/r23.2
11LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
12JGITWHENCE=https://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit.pgm/6.8.0.202311291450-r/org.eclipse.jgit.pgm-6.8.0.202311291450-r.sh
13CARGO_MSRV_VERSION=0.18.4
14CARGO_MSRV_WHENCE=https://github.com/foresterre/cargo-msrv/releases/download/v$CARGO_MSRV_VERSION/cargo-msrv-x86_64-unknown-linux-musl-v$CARGO_MSRV_VERSION.tgz
15
16# Make sudo a no-op and execute the command directly when running as root.
17# While using sudo would be fine on most platforms when we are root already,
18# some platforms like e.g. Alpine Linux do not have sudo available by default
19# and would thus break.
20if test "$(id -u)" -eq 0
21then
22 sudo () {
23 "$@"
24 }
25fi
26
27case "$distro" in
28alpine-*)
29 apk add --update shadow sudo meson ninja-build gcc libc-dev curl-dev openssl-dev expat-dev gettext \
30 zlib-ng-dev pcre2-dev python3 musl-libintl perl-utils ncurses \
31 apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \
32 bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty >/dev/null
33 ;;
34fedora-*|almalinux-*)
35 case "$jobname" in
36 *-meson)
37 MESON_DEPS="meson ninja";;
38 esac
39 dnf -yq update >/dev/null &&
40 dnf -yq install shadow-utils sudo make pkg-config gcc findutils diffutils perl python3 gawk gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel $MESON_DEPS cargo >/dev/null
41 ;;
42ubuntu-*|i386/ubuntu-*|debian-*)
43 # Required so that apt doesn't wait for user input on certain packages.
44 export DEBIAN_FRONTEND=noninteractive
45
46 case "$distro" in
47 ubuntu-*)
48 SVN='libsvn-perl subversion'
49 LANGUAGES='language-pack-is'
50 ;;
51 i386/ubuntu-*)
52 SVN=
53 LANGUAGES='language-pack-is'
54 ;;
55 *)
56 SVN='libsvn-perl subversion'
57 LANGUAGES='locales-all'
58 ;;
59 esac
60
61 sudo apt-get -q update
62 sudo apt-get -q -y install \
63 $LANGUAGES apache2 cvs cvsps git gnupg $SVN \
64 make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
65 tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \
66 libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \
67 libsecret-1-dev libpcre2-dev meson ninja-build pkg-config cargo \
68 ${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE
69
70 # Starting with Ubuntu 25.10, sudo can now be provided via either
71 # sudo(1) or sudo-rs(1), with the latter being the default. The problem
72 # is that it does not support `--preserve-env` though, which we rely on
73 # in our CI. We thus revert back to the C implementation.
74 if test -f /etc/alternatives/sudo
75 then
76 sudo update-alternatives --set sudo /usr/bin/sudo.ws
77 fi
78
79 case "$distro" in
80 ubuntu-*)
81 mkdir --parents "$CUSTOM_PATH"
82
83 wget --quiet --directory-prefix="$CUSTOM_PATH" \
84 "$P4WHENCE/bin.linux26x86_64/p4d" \
85 "$P4WHENCE/bin.linux26x86_64/p4" &&
86 chmod a+x "$CUSTOM_PATH/p4d" "$CUSTOM_PATH/p4" || {
87 rm -f "$CUSTOM_PATH/p4"
88 rm -f "$CUSTOM_PATH/p4d"
89 }
90
91 wget --quiet \
92 "$LFSWHENCE/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" &&
93 tar -xzf "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" \
94 -C "$CUSTOM_PATH" --strip-components=1 \
95 "git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs" &&
96 rm "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" ||
97 rm -f "$CUSTOM_PATH/git-lfs"
98
99 wget --quiet "$JGITWHENCE" --output-document="$CUSTOM_PATH/jgit" &&
100 chmod a+x "$CUSTOM_PATH/jgit" ||
101 rm -f "$CUSTOM_PATH/jgit"
102 ;;
103 esac
104 ;;
105macos-*)
106 export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
107 # Uncomment this if you want to run perf tests:
108 # brew install gnu-time
109 brew link --force gettext
110
111 mkdir -p "$CUSTOM_PATH"
112 wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
113 tar -xf helix-core-server.tgz -C "$CUSTOM_PATH" p4 p4d &&
114 sudo xattr -d com.apple.quarantine "$CUSTOM_PATH/p4" "$CUSTOM_PATH/p4d" 2>/dev/null || true
115 rm helix-core-server.tgz
116
117 case "$jobname" in
118 osx-meson)
119 brew install meson ninja pcre2
120 ;;
121 esac
122
123 if test -n "$CC_PACKAGE"
124 then
125 BREW_PACKAGE=${CC_PACKAGE/-/@}
126 brew install "$BREW_PACKAGE"
127 brew link "$BREW_PACKAGE"
128 fi
129 ;;
130esac
131
132case "$jobname" in
133ClangFormat)
134 sudo apt-get -q -y install clang-format
135 ;;
136StaticAnalysis)
137 sudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \
138 libexpat-dev gettext make
139 ;;
140RustAnalysis)
141 sudo apt-get -q -y install rustup
142 rustup default stable
143 rustup component add clippy rustfmt
144
145 wget -q "$CARGO_MSRV_WHENCE" -O "cargo-msvc.tgz"
146 sudo mkdir -p "$CUSTOM_PATH"
147 sudo tar -xf "cargo-msvc.tgz" --strip-components=1 \
148 --directory "$CUSTOM_PATH" --wildcards "*/cargo-msrv"
149 sudo chmod a+x "$CUSTOM_PATH/cargo-msrv"
150 ;;
151sparse)
152 sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \
153 libexpat-dev gettext zlib1g-dev sparse
154 ;;
155Documentation)
156 sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make
157
158 test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
159 sudo gem install --version 1.5.8 asciidoctor
160 sudo gem install concurrent-ruby
161 ;;
162esac
163
164if type p4d >/dev/null 2>&1 && type p4 >/dev/null 2>&1
165then
166 echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)"
167 p4d -V
168 echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)"
169 p4 -V
170else
171 echo >&2 "::warning:: perforce wasn't installed, see above for clues why"
172fi
173
174if type git-lfs >/dev/null 2>&1
175then
176 echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)"
177 git-lfs version
178else
179 echo >&2 "::warning:: git-lfs wasn't installed, see above for clues why"
180fi
181
182if type jgit >/dev/null 2>&1
183then
184 echo "$(tput setaf 6)JGit Version$(tput sgr0)"
185 jgit version
186else
187 echo >&2 "::warning:: JGit wasn't installed, see above for clues why"
188fi
189
190end_group "Install dependencies"