Raw
1 #!/bin/sh
2 #
3 # Install dependencies required to build and test Git on Linux and macOS
4 #
5
6 . ${0%/*}/lib.sh
7
8 begin_group "Install dependencies"
9
10 P4WHENCE=https://cdist2.perforce.com/perforce/r23.2
11 LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
12 JGITWHENCE=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
13 CARGO_MSRV_VERSION=0.18.4
14 CARGO_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.
20 if test "$(id -u)" -eq 0
21 then
22 sudo () {
23 "$@"
24 }
25 fi
26
27 case "$distro" in
28 alpine-*)
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 cargo >/dev/null
33 ;;
34 fedora-*|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 ;;
42 ubuntu-*|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 # on uutils v0.2.2 from rust-coreutils,
80 # dirname "foo/."
81 # outputs "." instead of "foo" like it should.
82 # Use GNU coreutils to provide dirname instead.
83 #
84 # See <https://github.com/uutils/coreutils/issues/10508>.
85 if test -x /usr/bin/gnudirname
86 then
87 ln -sfT /usr/bin/gnudirname /usr/bin/dirname
88 fi
89
90 case "$distro" in
91 ubuntu-*)
92 mkdir --parents "$CUSTOM_PATH"
93
94 wget --quiet --directory-prefix="$CUSTOM_PATH" \
95 "$P4WHENCE/bin.linux26x86_64/p4d" \
96 "$P4WHENCE/bin.linux26x86_64/p4" &&
97 chmod a+x "$CUSTOM_PATH/p4d" "$CUSTOM_PATH/p4" || {
98 rm -f "$CUSTOM_PATH/p4"
99 rm -f "$CUSTOM_PATH/p4d"
100 }
101
102 wget --quiet \
103 "$LFSWHENCE/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" &&
104 tar -xzf "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" \
105 -C "$CUSTOM_PATH" --strip-components=1 \
106 "git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs" &&
107 rm "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" ||
108 rm -f "$CUSTOM_PATH/git-lfs"
109
110 wget --quiet "$JGITWHENCE" --output-document="$CUSTOM_PATH/jgit" &&
111 chmod a+x "$CUSTOM_PATH/jgit" ||
112 rm -f "$CUSTOM_PATH/jgit"
113 ;;
114 esac
115 ;;
116 macos-*)
117 export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
118 # Uncomment this if you want to run perf tests:
119 # brew install gnu-time
120 brew link --force gettext
121
122 mkdir -p "$CUSTOM_PATH"
123 wget -q "$P4WHENCE/bin.macosx12arm64/helix-core-server.tgz" &&
124 tar -xf helix-core-server.tgz -C "$CUSTOM_PATH" p4 p4d &&
125 sudo xattr -d com.apple.quarantine "$CUSTOM_PATH/p4" "$CUSTOM_PATH/p4d" 2>/dev/null || true
126 rm helix-core-server.tgz
127
128 case "$jobname" in
129 osx-meson)
130 brew install meson ninja pcre2
131 ;;
132 esac
133
134 if test -n "$CC_PACKAGE"
135 then
136 BREW_PACKAGE=${CC_PACKAGE/-/@}
137 brew install "$BREW_PACKAGE"
138 brew link "$BREW_PACKAGE"
139 fi
140 ;;
141 esac
142
143 case "$jobname" in
144 ClangFormat)
145 sudo apt-get -q -y install clang-format
146 ;;
147 StaticAnalysis)
148 sudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \
149 libexpat-dev gettext make
150 ;;
151 RustAnalysis)
152 sudo apt-get -q -y install rustup
153 rustup default stable
154 rustup component add clippy rustfmt
155
156 wget -q "$CARGO_MSRV_WHENCE" -O "cargo-msvc.tgz"
157 sudo mkdir -p "$CUSTOM_PATH"
158 sudo tar -xf "cargo-msvc.tgz" --strip-components=1 \
159 --directory "$CUSTOM_PATH" --wildcards "*/cargo-msrv"
160 sudo chmod a+x "$CUSTOM_PATH/cargo-msrv"
161 ;;
162 sparse)
163 sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \
164 libexpat-dev gettext zlib1g-dev sparse
165 ;;
166 Documentation)
167 sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make
168
169 test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
170 sudo gem install --version 1.5.8 asciidoctor
171 sudo gem install concurrent-ruby
172 ;;
173 esac
174
175 if type p4d >/dev/null 2>&1 && type p4 >/dev/null 2>&1
176 then
177 echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)"
178 p4d -V
179 echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)"
180 p4 -V
181 else
182 echo >&2 "::warning:: perforce wasn't installed, see above for clues why"
183 fi
184
185 if type git-lfs >/dev/null 2>&1
186 then
187 echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)"
188 git-lfs version
189 else
190 echo >&2 "::warning:: git-lfs wasn't installed, see above for clues why"
191 fi
192
193 if type jgit >/dev/null 2>&1
194 then
195 echo "$(tput setaf 6)JGit Version$(tput sgr0)"
196 jgit version
197 else
198 echo >&2 "::warning:: JGit wasn't installed, see above for clues why"
199 fi
200
201 end_group "Install dependencies"