| @@ -2,6 +2,7 @@ · 1 unmodified line |
| 2 | 2 | set -euxC |
| 3 | 3 | |
| 4 | 4 | target="$1" |
| 5 | +test -n "$target" |
| 5 | 6 | |
| 6 | 7 | # Arrange for the indirect `tzdata` dependency to be installed and configured |
| 7 | 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 | 15 | apt-get install --no-install-recommends -y apt-transport-https dpkg-dev gnupg |
| 15 | 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 | | −# attempting to build `max`, and shared libraries used by `git` itself. |
| 18 | +# Decide what architecture to use for `git`, shared libraries `git` links to, |
| 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 | 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 | 29 | dpkg --add-architecture "$target_arch" |
| 22 | 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 | 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 | 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 | 42 | echo "deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu $release main" \ |
| 28 | 43 | >/etc/apt/sources.list.d/git-core-ubuntu-ppa.list |
| 29 | 44 | apt-key adv --keyserver keyserver.ubuntu.com \ |
| @@ -94,19 +109,17 @@ file -- "$git" · 64 unmodified lines |
| 94 | 109 | apt-get clean |
| 95 | 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` |
| 98 | | −# uses for Android, then patch the script to add the ability to suppress its |
| 99 | | −# customization of `LD_PRELOAD`. This runner script sets `LD_PRELOAD` to the |
| 100 | | −# path of `libc++_shared.so` in the vendored Android NDK. But this causes a |
| 101 | | −# problem for us because, when a non-Android (i.e. a host-architecture) program |
| 102 | | −# is run, `ld.so` shows a message about the "wrong ELF class". Such programs |
| 103 | | −# can still run, but when we make an assertion about, parse, or otherwise rely |
| 104 | | −# on their output to standard error, we get test failures. (That especially |
| 105 | | −# affects fixtures.) This change lets us pass `NO_PRELOAD_CXX=1` to avoid that. |
| 106 | | −if test -f /android-runner; then |
| 107 | | − sed -i.orig 's/^export LD_PRELOAD=/test "${NO_PRELOAD_CXX:-0}" != 0 || &/' |
| 108 | | − /android-runner |
| 109 | | −fi |
| 112 | +# If this image has a runner script `cross` uses for Android, patch the script |
| 113 | +# to add the ability to suppress its customization of `LD_PRELOAD`. The runner |
| 114 | +# script sets `LD_PRELOAD` to the path of `libc++_shared.so` in the Android NDK |
| 115 | +# (https://github.com/cross-rs/cross/blob/v0.2.5/docker/android-runner#L34). |
| 116 | +# But this causes a problem for us. When a host-architecture program is run, |
| 117 | +# `ld.so` shows a message about the "wrong ELF class". Such programs can still |
| 118 | +# run, but when we rely on their specific output to stderr, fixtures and tests |
| 119 | +# fail. The change we make here lets us set `NO_PRELOAD_CXX=1` to avoid that. |
| 120 | +runner=/android-runner |
| 121 | +patch='s/^[[:blank:]]*export LD_PRELOAD=/test "${NO_PRELOAD_CXX:-0}" != 0 || &/' |
| 122 | +if test -f "$runner"; then sed -i.orig "$patch" -- "$runner"; fi |
| 110 | 123 | |
| 111 | 124 | # Ensure a nonempty Git `system` scope (for the `installation_config` tests). |
| 112 | 125 | git config --system gitoxide.imaginary.arbitraryVariable arbitraryValue |