Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/travis2docker/templates/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ install_dev_tools(){
# emacs \
# byobu \
# multitail # Set the terminal with red letters build the docker
sudo -E pip install -q \
pip install -q \
ipython \
py-spy \
virtualenv \
Expand All @@ -115,7 +115,7 @@ install_dev_tools(){
# pre install pre-commit-vauxoo?
# sudo su odoo -c "git init /tmp/test && cd /tmp/test && pre-commit-vauxoo -f"
touch /home/odoo/full_test-requirements.txt
sudo -E pip install -r /home/odoo/full_test-requirements.txt
pip install -r /home/odoo/full_test-requirements.txt

# Install git-delta from .deb since not all Ubuntu versions ship the package
GIT_DELTA_VERSION=0.18.2
Expand Down
15 changes: 15 additions & 0 deletions tests/test_travis2docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import pathlib
import re
import subprocess
import sys
from shutil import which
Expand Down Expand Up @@ -215,3 +216,17 @@ def test_main_without_variables_sh(tmp_path, monkeypatch):
]
with pytest.raises(InvalidRepoBranchError):
cli_main(return_result=True)


def test_build_sh_pip_without_sudo():
"""build.sh runs as root in the Dockerfile, so pip must not go through sudo:
sudo resets PATH to its secure_path and images whose python lives outside of
it (e.g. uv managed /opt/python/current/bin) fail with "sudo: pip: command not found"
"""
build_sh = pathlib.Path(__file__).resolve().parent.parent / "src" / "travis2docker" / "templates" / "build.sh"
sudo_pip_lines = [
line.strip()
for line in build_sh.read_text().splitlines()
if not line.strip().startswith("#") and re.search(r"\bsudo\b.*\bpip3?\b", line)
]
assert not sudo_pip_lines, "pip called through sudo in build.sh: %s" % sudo_pip_lines
Loading