Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ubuntu 18.04 #22

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 45 additions & 31 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
FROM buildpack-deps:bookworm AS static-libcrypt
FROM ubuntu:18.04 AS static-libcrypt

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; \
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; \
cp /libc6-dev/usr/lib/aarch64-linux-gnu/libcrypt.a /libcrypt.a; \
fi; \
:
export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install -y \
ca-certificates \
curl \
gcc \
libc6-dev \
make \
patch \
perl \
tar \
wget \
xz-utils \
;

FROM centos:centos7 AS builder
ARG LIBXCRYPT_VERSION=4.4.36

# 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
RUN set -eux; \
cd /tmp; \
curl -fsSL -o libxcrypt-${LIBXCRYPT_VERSION}.tar.xz https://github.com/besser82/libxcrypt/releases/download/v${LIBXCRYPT_VERSION}/libxcrypt-${LIBXCRYPT_VERSION}.tar.xz; \
tar xf libxcrypt-${LIBXCRYPT_VERSION}.tar.xz; \
cd libxcrypt-${LIBXCRYPT_VERSION}; \
./configure --with-pic --disable-shared; \
make; \
mv .libs/libcrypt.a /; \
:

# 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-*
# XXX We use ubuntu:18.04 because its gcc is configured with --enable-default-pie
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 @@ -38,25 +52,25 @@ RUN mkdir -p \
/usr/lib/$(uname -m)-linux-gnu \
/usr/lib64 \
/usr/local/lib \
/usr/local/lib64
/usr/local/lib64 \
;
RUN wget -q -O - https://raw.githubusercontent.com/skaji/relocatable-perl/main/perl-install | bash -s /perl
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 /tmp/libcrypt.a
RUN cp -f /tmp/libcrypt.a /usr/lib/$(uname -m)-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
12 changes: 11 additions & 1 deletion build/relocatable-perl-build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ sub run {
my ($cmd, $log) = @_;
warn "---> @$cmd\n";
run3 $cmd, undef, $log, $log, { append_stdout => 1 };
$? == 0 or die "failed @$cmd";
if ($? != 0) {
open my $fh, "<", $log or die;
while (<$fh>) {
print;
}
die;
}
return 1;
}

=head1 NAME
Expand Down Expand Up @@ -139,6 +146,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
Loading