Skip to content

Commit

Permalink
[linux/arm64] Use debian multiarch, dunno how to do manylinux....
Browse files Browse the repository at this point in the history
  • Loading branch information
ianks committed Dec 17, 2022
1 parent 2558eb8 commit cecdd8a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Dockerfile.mri.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ RUN rm -f /usr/local/bin/sudo && \
echo "%sudo ALL=(ALL) ALL" >> /etc/sudoers
<% else %>
ENV DEBIAN_FRONTEND noninteractive
RUN dpkg --add-architecture <%= foreign_dpkg_arch %> && \
apt-get -y update && \
apt-get install -y sudo wget autoconf cmake curl git-core pkg-config build-essential xz-utils unzip gnupg2 dirmngr && \
apt-get install -y zlib1g-dev:<%= foreign_dpkg_arch %> libreadline-dev:<%= foreign_dpkg_arch %> libsqlite0-dev:<%= foreign_dpkg_arch %> libssl-dev:<%= foreign_dpkg_arch %> libyaml-dev:<%= foreign_dpkg_arch %> libffi-dev:<%= foreign_dpkg_arch %> && \
rm -rf /var/lib/apt/lists/*
COPY ./build/setup_dpkg_multiarch_for_target.sh /
RUN /setup_dpkg_multiarch_for_target.sh <%= foreign_dpkg_arch %>;

RUN apt-get -y -qq update && \
apt-get -y -qq install sudo wget autoconf cmake curl git-core pkg-config build-essential xz-utils unzip gnupg2 dirmngr && \
apt-get -y -qq install zlib1g-dev:<%= foreign_dpkg_arch %> libreadline-dev:<%= foreign_dpkg_arch %> libsqlite0-dev:<%= foreign_dpkg_arch %> libssl-dev:<%= foreign_dpkg_arch %> libyaml-dev:<%= foreign_dpkg_arch %> libffi-dev:<%= foreign_dpkg_arch %> && \
rm -rf /var/lib/apt/lists/*;
<% end %>

# Add "rvm" as system group, to avoid conflicts with host GIDs typically starting with 1000
Expand Down Expand Up @@ -92,7 +94,6 @@ RUN apt-get -y update && \
apt-get install -y <%
if platform=~/darwin/ %> clang python lzma-dev libxml2-dev libssl-dev libc++-10-dev <% end %><%
if platform=~/aarch64-linux/ %> gcc-aarch64-linux-gnu g++-aarch64-linux-gnu <% end %><%
if platform=~/x86_64-linux/ %> gcc-x86-64-linux-gnu g++-x86-64-linux-gnu <% end %><%
if platform=~/arm-linux/ %> gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf <% end %><%
if platform=~/x86-mingw32/ %> gcc-mingw-w64-i686 g++-mingw-w64-i686 <% end %><%
if platform=~/x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end %> && \
Expand Down
43 changes: 43 additions & 0 deletions build/setup_dpkg_multiarch_for_target.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -exuo pipefail
IFS=$'\n\t'

main() {
local to_uninstall=()

if ! command -v dpkg-architecture; then
echo "dpkg-architecture not found, installing" >&2
apt-get -qq -y update
apt-get -qq -y install --no-install-recommends debhelper lsb-release
rm -rf /var/lib/apt/lists/*
to_uninstall+=("debhelper" "lsb-release")
fi

deb_host_arch="$(dpkg-architecture --query DEB_HOST_ARCH)"
deb_target_arch="$1"

if [ "$deb_target_arch" != "$deb_host_arch" ]; then
echo "Setting up multiarch support for $deb_target_arch" >&2

# Add arch support for target so we can install libs
dpkg --add-architecture "$deb_target_arch"
# Qualify our current source lists to make sure debian doesn't infer stuff
sed -i "s/^deb http/deb [arch=$deb_host_arch] http/" /etc/apt/sources.list
# Add sources for ported target libs
sh -c "echo \"deb [arch=$deb_target_arch] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs) main universe restricted multiverse\" >> /etc/apt/sources.list"
sh -c "echo \"deb [arch=$deb_target_arch] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs)-updates main universe restricted multiverse\" >> /etc/apt/sources.list"
sh -c "echo \"deb [arch=$deb_target_arch] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs)-security main universe restricted multiverse\" >> /etc/apt/sources.list"
apt-get update
else
echo "No need to set up multiarch support for $deb_target_arch"
fi

if [ "${#to_uninstall[@]}" -gt 0 ]; then
apt-get remove -y "${to_uninstall[@]}"
fi

rm "$0"
}

main "$@"

0 comments on commit cecdd8a

Please sign in to comment.