| @@ -2,6 +2,7 @@ · 1 unmodified line |
| 2 | set -euxC | 2 | set -euxC |
| 3 | | 3 | |
| 4 | target="$1" | 4 | target="$1" |
| | 5 | test -n "$target" |
| 5 | | 6 | |
| 6 | # Arrange for the indirect `tzdata` dependency to be installed and configured | 7 | # Arrange for the indirect `tzdata` dependency to be installed and configured |
| 7 | # without prompting for the time zone. (Passing `-y` is not enough.) | 8 | # without prompting for the time zone. (Passing `-y` is not enough.) |
| @@ -14,16 +15,30 @@ apt-get install --no-install-recommends -y apt-utils · 6 unmodified lines |
| 14 | apt-get install --no-install-recommends -y apt-transport-https dpkg-dev gnupg | 15 | apt-get install --no-install-recommends -y apt-transport-https dpkg-dev gnupg |
| 15 | type dpkg-architecture # Make sure we really have this. | 16 | type dpkg-architecture # Make sure we really have this. |
| 16 | | 17 | |
| 17 | # Decide what architecture to use for `git`, shared libraries for gitoxide when | 18 | # Decide what architecture to use for `git`, shared libraries `git` links to, |
| 18 | # attempting to build `max`, and shared libraries used by `git` itself. | 19 | # and shared libraries gitoxide links to when building `max`. Instead of this |
| | 20 | # custom logic, we could use `$CROSS_DEB_ARCH`, which `cross` tries to provide |
| | 21 | # (https://github.com/cross-rs/cross/blob/v0.2.5/src/lib.rs#L268), and which is |
| | 22 | # available for roughly the same architectures where this logic gets a nonempty |
| | 23 | # value. But using `$CROSS_DEB_ARCH` may make it harder to build and test the |
| | 24 | # image manually. In particular, if it is not passed, we would conclude that we |
| | 25 | # should install the versions of those packages with the host's architecture. |
| 19 | apt_suffix= | 26 | apt_suffix= |
| 20 | if target_arch="$(dpkg-architecture --host-type "$target" --query DEB_HOST_ARCH)"; then | 27 | if target_arch="$(dpkg-architecture --host-type "$target" --query DEB_HOST_ARCH)" |
| | 28 | then |
| 21 | dpkg --add-architecture "$target_arch" | 29 | dpkg --add-architecture "$target_arch" |
| 22 | apt_suffix=":$target_arch" | 30 | apt_suffix=":$target_arch" |
| | 31 | printf 'INFO: Using target architecture for `git` and libs in container.\n' |
| | 32 | printf 'INFO: This architecture is %s.\n' "$target_arch" |
| | 33 | else |
| | 34 | apt_suffix='' |
| | 35 | printf 'WARNING: Using HOST architecture for `git` and libs in container.\n' |
| 23 | fi | 36 | fi |
| 24 | | 37 | |
| 25 | # Add the git-core PPA manually. (Faster than installing `add-apt-repository`.) | 38 | # Get release codename. Like `lsb_release -sc`. (`lsb_release` may be absent.) |
| 26 | release="$(sed -n 's/^VERSION_CODENAME=//p' /etc/os-release)" | 39 | release="$(sed -n 's/^VERSION_CODENAME=//p' /etc/os-release)" |
| | 40 | |
| | 41 | # Add the git-core PPA manually. (Faster than installing `add-apt-repository`.) |
| 27 | echo "deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu $release main" \ | 42 | echo "deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu $release main" \ |
| 28 | >/etc/apt/sources.list.d/git-core-ubuntu-ppa.list | 43 | >/etc/apt/sources.list.d/git-core-ubuntu-ppa.list |
| 29 | apt-key adv --keyserver keyserver.ubuntu.com \ | 44 | apt-key adv --keyserver keyserver.ubuntu.com \ |
| @@ -94,19 +109,17 @@ file -- "$git" · 64 unmodified lines |
| 94 | apt-get clean | 109 | apt-get clean |
| 95 | rm -rf /tmp/dl /var/lib/apt/lists/* | 110 | rm -rf /tmp/dl /var/lib/apt/lists/* |
| 96 | | 111 | |
| 97 | # If this is an Android-related image or otherwise has a runner script `cross` | 112 | # If this image has a runner script `cross` uses for Android, patch the script |
| 98 | # uses for Android, then patch the script to add the ability to suppress its | 113 | # to add the ability to suppress its customization of `LD_PRELOAD`. The runner |
| 99 | # customization of `LD_PRELOAD`. This runner script sets `LD_PRELOAD` to the | 114 | # script sets `LD_PRELOAD` to the path of `libc++_shared.so` in the Android NDK |
| 100 | # path of `libc++_shared.so` in the vendored Android NDK. But this causes a | 115 | # (https://github.com/cross-rs/cross/blob/v0.2.5/docker/android-runner#L34). |
| 101 | # problem for us because, when a non-Android (i.e. a host-architecture) program | 116 | # But this causes a problem for us. When a host-architecture program is run, |
| 102 | # is run, `ld.so` shows a message about the "wrong ELF class". Such programs | 117 | # `ld.so` shows a message about the "wrong ELF class". Such programs can still |
| 103 | # can still run, but when we make an assertion about, parse, or otherwise rely | 118 | # run, but when we rely on their specific output to stderr, fixtures and tests |
| 104 | # on their output to standard error, we get test failures. (That especially | 119 | # fail. The change we make here lets us set `NO_PRELOAD_CXX=1` to avoid that. |
| 105 | # affects fixtures.) This change lets us pass `NO_PRELOAD_CXX=1` to avoid that. | 120 | runner=/android-runner |
| 106 | if test -f /android-runner; then | 121 | patch='s/^[[:blank:]]*export LD_PRELOAD=/test "${NO_PRELOAD_CXX:-0}" != 0 || &/' |
| 107 | sed -i.orig 's/^export LD_PRELOAD=/test "${NO_PRELOAD_CXX:-0}" != 0 || &/' | 122 | if test -f "$runner"; then sed -i.orig "$patch" -- "$runner"; fi |
| 108 | /android-runner | | |
| 109 | fi | | |
| 110 | | 123 | |
| 111 | # Ensure a nonempty Git `system` scope (for the `installation_config` tests). | 124 | # Ensure a nonempty Git `system` scope (for the `installation_config` tests). |
| 112 | git config --system gitoxide.imaginary.arbitraryVariable arbitraryValue | 125 | git config --system gitoxide.imaginary.arbitraryVariable arbitraryValue |