Skip to content

Commit

Permalink
use ubuntu 18.04
Browse files Browse the repository at this point in the history
  • Loading branch information
skaji committed Dec 29, 2024
1 parent b798f95 commit ae33890
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
52 changes: 28 additions & 24 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
FROM buildpack-deps:bookworm AS static-libcrypt
FROM buildpack-deps:stable AS static-libcrypt

# XXX: We use ubuntu:20.04(focal)'s libcrypt.a
# because ubuntu:18.04(bionic)'s libcrypt.a depends on __snprintf
# see: objdump -x libcrypt.a | grep snprintf

# https://launchpad.net/ubuntu/focal/amd64/libcrypt-dev/
# https://launchpad.net/ubuntu/focal/arm64/libcrypt-dev/
ARG LIBCRYPT_DEV=libcrypt-dev_4.4.10-10ubuntu4
RUN set -eux; \
mkdir /libc6-dev; \
cd /tmp; \
if [ $(uname -m) = x86_64 ]; then \
curl -fsSL -O http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.23-0ubuntu3_amd64.deb; \
dpkg-deb -x libc6-dev_2.23-0ubuntu3_amd64.deb /libc6-dev; \
curl -fsSL -O https://archive.ubuntu.com/ubuntu/pool/main/libx/libxcrypt/${LIBCRYPT_DEV}_amd64.deb; \
dpkg-deb -x ${LIBCRYPT_DEV}_amd64.deb /libc6-dev; \
cp /libc6-dev/usr/lib/x86_64-linux-gnu/libcrypt.a /libcrypt.a; \
else \
curl -fsSL -O http://ports.ubuntu.com/pool/main/g/glibc/libc6-dev_2.23-0ubuntu3_arm64.deb; \
dpkg-deb -x libc6-dev_2.23-0ubuntu3_arm64.deb /libc6-dev; \
curl -fsSL -O https://ports.ubuntu.com/pool/main/libx/libxcrypt/${LIBCRYPT_DEV}_arm64.deb; \
dpkg-deb -x ${LIBCRYPT_DEV}_arm64.deb /libc6-dev; \
cp /libc6-dev/usr/lib/aarch64-linux-gnu/libcrypt.a /libcrypt.a; \
fi; \
:

FROM centos:centos7 AS builder

# see https://gist.github.com/skaji/76203327b517cb44da88a4301de118d3
RUN sed -i 's/override_install_langs=en_US.UTF-8/override_install_langs=en_US.utf8/' /etc/yum.conf

# https://stackoverflow.com/questions/78692851/could-not-retrieve-mirrorlist-http-mirrorlist-centos-org-release-7arch-x86-6
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
FROM ubuntu:18.04 AS builder

RUN yum install -y \
RUN set -eux; \
export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
libc6-dev \
make \
patch \
tar \
wget \
patch \
xz
xz-utils \
;
RUN mkdir -p \
/lib \
/lib/$(uname -m)-linux-gnu \
Expand All @@ -43,20 +49,18 @@ RUN wget -q -O - https://raw.githubusercontent.com/skaji/relocatable-perl/main/p
RUN wget -q -O /cpm https://raw.githubusercontent.com/skaji/cpm/main/cpm
RUN --mount=type=bind,target=src /perl/bin/perl /cpm install -g --cpmfile src/build/cpm.yml

RUN rm -f /usr/lib64/libcrypt.so /usr/lib64/libcrypt.so.1
COPY --from=static-libcrypt /libcrypt.a /usr/lib64/libcrypt.a
RUN rm -f /usr/lib/$(uname -m)-linux-gnu/libcrypt.so
COPY --from=static-libcrypt /libcrypt.a /usr/lib/x86_64-linux-gnu/libcrypt.a

RUN --mount=type=bind,target=src /perl/bin/perl src/build/relocatable-perl-build --perl_version $(cat src/BUILD_VERSION) --prefix /opt/perl
RUN cd /usr/lib64; \
rm -f libcrypt.a; \
ln -sf libcrypt-2.17.so libcrypt.so; \
ln -sf libcrypt-2.17.so libcrypt.so.1; \
:

RUN ln -sf /lib/$(uname -m)-linux-gnu/libcrypt.so.1 /usr/lib/$(uname -m)-linux-gnu/libcrypt.so

RUN /opt/perl/bin/perl /cpm install -g App::cpanminus App::ChangeShebang
RUN /opt/perl/bin/change-shebang -f /opt/perl/bin/*
RUN set -eux; \
cd /tmp; \
_ARCHNAME=$(if [[ $(uname -m) = x86_64 ]]; then echo amd64; else echo arm64; fi); \
_ARCHNAME=$(if [ $(uname -m) = x86_64 ]; then echo amd64; else echo arm64; fi); \
cp -r /opt/perl perl-linux-$_ARCHNAME; \
tar cf perl-linux-$_ARCHNAME.tar perl-linux-$_ARCHNAME; \
gzip -9 --stdout perl-linux-$_ARCHNAME.tar > /perl-linux-$_ARCHNAME.tar.gz; \
Expand Down
6 changes: 4 additions & 2 deletions build/relocatable-perl-build
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use POSIX 'uname';
sub run {
my ($cmd, $log) = @_;
warn "---> @$cmd\n";
run3 $cmd, undef, $log, $log, { append_stdout => 1 };
$? == 0 or die "failed @$cmd";
0 == system @$cmd or die;
}

=head1 NAME
Expand Down Expand Up @@ -139,6 +138,9 @@ sub perl_build {
# manually define d_crypt here
push @Configure, "-Dd_crypt";

# math.h in debian does not define _LIB_VERSION
push @Configure, "-Ud_libm_lib_version";

my $arch = (uname)[4];
my @libpth = (
"/lib",
Expand Down

0 comments on commit ae33890

Please sign in to comment.