ci: install python on ubuntu

Python is missing from the default ubuntu-22.04 runner image, which prevents git-p4 from working. To install python on ubuntu, we need to provide the correct package names: * On Ubuntu 18.04 (bionic), "/usr/bin/python2" is provided by the "python" package, and "/usr/bin/python3" is provided by the "python3" package. * On Ubuntu 20.04 (focal) and above, "/usr/bin/python2" is provided by the "python2" package which has a different name from bionic, and "/usr/bin/python3" is provided by "python3". Since the "ubuntu-latest" runner image has a higher version, its safe to use "python2" or "python3" package name. Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jiang Xin committed Nov 25, 2022 at 17:59 UTC 0d3507f3e7b74ccbaa6f1ddc282cf467cce0e102
2 files changed +5 -5
ci/install-dependencies.sh
+1 -1
@@ -15,7 +15,7 @@ case "$runs_on_pool" in
15 ubuntu-*)
16 sudo apt-get -q update
17 sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \
18 - $UBUNTU_COMMON_PKGS $CC_PACKAGE
18 + $UBUNTU_COMMON_PKGS $CC_PACKAGE $PYTHON_PACKAGE
19 mkdir --parents "$P4_PATH"
20 pushd "$P4_PATH"
21 wget --quiet "$P4WHENCE/bin.linux26x86_64/p4d"
ci/lib.sh
+4 -4
@@ -232,12 +232,12 @@ ubuntu-*)
232 break
233 fi
234
235 - if [ "$jobname" = linux-gcc ]
235 + PYTHON_PACKAGE=python2
236 + if test "$jobname" = linux-gcc
237 then
237 - MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3"
238 - else
239 - MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python2"
238 + PYTHON_PACKAGE=python3
239 fi
240 + MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/$PYTHON_PACKAGE"
241
242 export GIT_TEST_HTTPD=true
243