Debian Codegraph @

debian/tests/testbed-setup.sh

raw
1 #!/usr/bin/sh
2
3 # helper script called from within ansible-test-integration.py to
4
5 set -eu
6
7 # workaround for various integration tests trying to do this and failing
8 # due to missing root permission
9 echo 'apt-mark changes'
10 /usr/bin/apt-mark manual debconf-utils || true
11 /usr/bin/apt-mark manual equivs || true
12 /usr/bin/apt-mark manual git || true
13 /usr/bin/apt-mark manual iptables || true
14 /usr/bin/apt-mark manual libfile-fcntllock-perl || true
15 /usr/bin/apt-mark manual openssl || true
16 /usr/bin/apt-mark manual python3-distlib || true
17
18 # Set default locale to en_US.UTF-8 to remove lots of warnings when
19 # running the tests
20 echo 'debconf selection changes'
21 # These values get overwritten by what is in the config files when
22 # running dpkg-reconfigure, see https://bugs.debian.org/684134
23 cat << EOF | debconf-set-selections
24 locales locales/default_environment_locale select en_US.UTF-8
25 locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
26 EOF
27
28 # So set these values manually in the config files.
29 cat > /etc/locale.gen << EOF
30 en_US.UTF-8 UTF-8
31 fr_FR.UTF-8 UTF-8 # used in unarchive integration test
32 EOF
33 echo 'LANG=en_US.UTF-8' > /etc/locale.conf
34 echo 'LANG=en_US.UTF-8' > /etc/default/locale
35
36 echo 'dpkg-reconfigure changes'
37 dpkg-reconfigure --frontend=noninteractive locales
38
39 # create empty authorized_keys for integration test 'copy'
40 [ -d /root/.ssh ] || mkdir /root/.ssh/
41
42 touch /root/.ssh/authorized_keys
43
44 # allow pip to install system packages for the tests
45 rm -f /usr/lib/python3*/EXTERNALLY-MANAGED
46
47 echo 'status of /usr/lib/python3*/EXTERNALLY-MANAGED:'
48
49 echo 'python3 snippet to detect env:'
50 python3 -c 'import sys, sysconfig; print(f"""{sysconfig.get_path("stdlib", sysconfig.get_default_scheme()
51 if sys.version_info >= (3, 10) else sysconfig._get_default_scheme())}/EXTERNALLY-MANAGED""")'
52
53 set -- /usr/lib/python3*/EXTERNALLY-MANAGED
54 if [ -e "$1" ]; then
55 echo "At least one EXTERNALLY-MANAGED file exists, failing"
56 ls -l /usr/lib/python3*/EXTERNALLY-MANAGED
57 exit 1
58 else
59 echo "No EXTERNALLY-MANAGED file found"
60 fi
61
62 # Remove autopkgtest's global pinning, as that breaks the apt and
63 # deb822_repository integration tests; see
64 # https://github.com/ansible/ansible/issues/85147. Don't touch more
65 # specific pins such as those created by "autopkgtest --pin-packages".
66 grep -lr 'Pin: origin ""' /etc/apt/preferences.d | xargs -r rm -f
67
68 # Workaround for integration test "apt", because of policy in base-files
69 # See
70 # MODULE FAILURE: No start of json char found
71 # Traceback (most recent call last):
72 # File \"<stdin>\", line 121, in <module>
73 # File \"<stdin>\", line 113, in _ansiballz_main
74 # File \"<stdin>\", line 61, in invoke_module
75 # File \"<frozen runpy>\", line 226, in run_module
76 # File \"<frozen runpy>\", line 98, in _run_module_code
77 # File \"<frozen runpy>\", line 88, in _run_code
78 # File \"/tmp/ansible_apt_repository_payload_88mfa8n7/ansible_apt_repository_payload.zip/ansible/modules/apt_repository.py\", line 195, in <module>
79 # File \"/usr/lib/python3/dist-packages/aptsources/distro.py\", line 547, in get_distro
80 # release = os_release[\"VERSION_ID\"]
81 # ~~~~~~~~~~^^^^^^^^^^^^^^
82 # KeyError: 'VERSION_ID'
83 #
84 # Fixed in sid: https://bugs.debian.org/1088402
85 # Still leaving this here because ansible assumes that it's set pretty
86 # much everywhere.
87 grep VERSION_ID /etc/os-release || echo 'VERSION_ID="99"' >> /etc/os-release