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

Added Power and s390x architecture support #18

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ jobs:
with:
name: linux-arm64
path: linux-arm64
linux-ppc64le:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- run: docker buildx build --platform linux/ppc64le -t skaji/relocatable-perl -f build/Dockerfile --load .
- run: bash build/github-actions.sh linux_ppc64le_create_artifacts
- uses: actions/upload-artifact@v4
with:
name: linux-ppc64le
path: linux-ppc64le
darwin-amd64:
runs-on: macos-13
steps:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ jobs:
with:
name: linux-arm64
path: linux-arm64
linux-ppc64le:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- run: docker buildx build --platform linux/ppc64le -t skaji/relocatable-perl-ppc64le -f build/Dockerfile .
- run: bash build/github-actions.sh linux_ppc64le_create_artifacts
- uses: actions/upload-artifact@v4
with:
name: linux-ppc64le
path: linux-ppc64le
darwin-amd64:
runs-on: macos-13
steps:
Expand Down Expand Up @@ -63,6 +75,7 @@ jobs:
needs:
- linux-amd64
- linux-arm64
- linux-ppc64le
- darwin-amd64
- darwin-arm64
steps:
Expand All @@ -74,6 +87,10 @@ jobs:
with:
name: linux-arm64
path: linux-arm64
- uses: actions/download-artifact@v4
with:
name: linux-ppc64le
path: linux-ppc64le
- uses: actions/download-artifact@v4
with:
name: darwin-amd64
Expand Down
6 changes: 3 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM centos:centos7
FROM redhat/ubi8:latest

# 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
Expand All @@ -19,7 +19,7 @@ RUN mkdir -p \
/usr/lib64 \
/usr/local/lib \
/usr/local/lib64
RUN curl -fsSL https://raw.githubusercontent.com/skaji/relocatable-perl/main/perl-install | bash -s /perl
RUN curl -fsSL https://raw.githubusercontent.com/npanpaliya/relocatable-perl/ppc-support/perl-install | bash -s /perl
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is just for github actions to work while this is in PR state. Once this is reviewed and verified, before merging, I'll revert this change.

RUN curl -fsSL --compressed -o /cpm https://raw.githubusercontent.com/skaji/cpm/main/cpm
COPY build/relocatable-perl-build build/cpm.yml BUILD_VERSION /
RUN /perl/bin/perl /cpm install -g
Expand All @@ -28,7 +28,7 @@ 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; elif [[ $(uname -m) = aarch64 ]]; then echo arm64; else echo $(uname -m); 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
11 changes: 11 additions & 0 deletions build/github-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ linux_arm64_create_artifacts() {
docker rm $ID
}

linux_ppc64le_create_artifacts() {
mkdir linux-ppc64le
ID=$(docker create --platform linux/ppc64le skaji/relocatable-perl)
docker cp $ID:/perl-linux-ppc64le.tar.gz linux-ppc64le/
docker cp $ID:/perl-linux-ppc64le.tar.xz linux-ppc64le/
docker rm $ID
}

case "$1" in
mac_prepare_tools)
mac_prepare_tools
Expand All @@ -67,6 +75,9 @@ linux_amd64_create_artifacts)
linux_arm64_create_artifacts)
linux_arm64_create_artifacts
;;
linux_ppc64le_create_artifacts)
linux_ppc64le_create_artifacts
;;
*)
echo "unknown command: $1" >&2
exit 1
Expand Down
81 changes: 57 additions & 24 deletions perl-install
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
#!/bin/bash

set -eu
set -exu

die() {
echo "$1" >&2
exit 1
}

install_from_cpan() {
INSTALL_DIR=$1
PERL_VER=$2
VERSION=${PERL_VER%.*}
$HTTP_GET=$3
$HTTP_GET_OPTION=$4

$HTTP_GET $HTTP_GET_OPTION https://www.cpan.org/src/5.0/perl-${VERSION}.tar.gz -o perl.tar.gz \
&& tar -xzf perl.tar.gz \
&& cd perl-${VERSION} \
&& ./Configure -des -Dprefix=$INSTALL_DIR \
&& make \
&& make install \
&& rm -rf /perl.tar.gz perl-${VERSION}

}

if [[ $# -ne 1 ]] || [[ $1 = "-h" ]] || [[ $1 = "--help" ]]; then
die "Usage:
perl-install INSTALL_DIR # install latest perl to INSTALL_DIR
Expand Down Expand Up @@ -38,31 +55,19 @@ else
fi

LATEST_LINE=$($HTTP_GET $HTTP_GET_OPTION https://raw.githubusercontent.com/skaji/relocatable-perl/main/releases.csv | (\grep -m 1 ,$_OS,$_ARCH,; cat >/dev/null))
if [[ -z $LATEST_LINE ]]; then
die "Failed to determine latest perl version"
fi

LATEST_VERSION=$(echo $LATEST_LINE | \cut -d, -f1)
LATEST_URL=$(echo $LATEST_LINE | \cut -d, -f5)
if [[ $PRINT_VERSION = "YES" ]]; then
echo $LATEST_VERSION
exit
fi

TAR_CMD=gtar
if ! type $TAR_CMD &>/dev/null; then
TAR_CMD=tar
if ! type $TAR_CMD &>/dev/null; then
die 'Cannot find `tar` command'
BUILD_FROM_CPAN=0
if [[ -z $LATEST_LINE ]]; then
if [[ $_ARCH = ppc64le || $_ARCH = s390x ]]; then
LATEST_LINE=$($HTTP_GET $HTTP_GET_OPTION https://raw.githubusercontent.com/skaji/relocatable-perl/main/releases.csv | (\grep -m 1 ,$_OS,amd64,; cat >/dev/null))
BUILD_FROM_CPAN=1
fi
if [[ -z $LATEST_LINE ]]; then
die "Failed to determine latest perl version"
fi
fi

TAR_OPTION=xzf
TAR_SUFFIX=tar.gz
if type xz &>/dev/null; then
TAR_OPTION=xJf
TAR_SUFFIX=tar.xz
fi
LATEST_VERSION=$(echo $LATEST_LINE | \cut -d, -f1)

INSTALL_DIR=$1
if [[ -d $INSTALL_DIR ]]; then
Expand All @@ -73,9 +78,37 @@ else
fi
ABS_INSTALL_DIR=$(cd $INSTALL_DIR &>/dev/null; pwd)

echo "Installing perl $LATEST_VERSION to $INSTALL_DIR, this may take a while..."
if [[ $BUILD_FROM_CPAN = 1 ]]; then
install_from_cpan $INSTALL_DIR $LATEST_VERSION $HTTP_GET $HTTP_GET_OPTION

else
LATEST_URL=$(echo $LATEST_LINE | \cut -d, -f5)
if [[ $PRINT_VERSION = "YES" ]]; then
echo $LATEST_VERSION
exit
fi

TAR_CMD=gtar
if ! type $TAR_CMD &>/dev/null; then
TAR_CMD=tar
if ! type $TAR_CMD &>/dev/null; then
die 'Cannot find `tar` command'
fi
fi

TAR_OPTION=xzf
TAR_SUFFIX=tar.gz
if type xz &>/dev/null; then
TAR_OPTION=xJf
TAR_SUFFIX=tar.xz
fi

echo "Installing perl $LATEST_VERSION to $INSTALL_DIR, this may take a while..."

$HTTP_GET $HTTP_GET_OPTION $LATEST_URL | $TAR_CMD $TAR_OPTION - --strip-components 1 -C $INSTALL_DIR

fi

$HTTP_GET $HTTP_GET_OPTION $LATEST_URL | $TAR_CMD $TAR_OPTION - --strip-components 1 -C $INSTALL_DIR
if [[ ! -f $INSTALL_DIR/bin/perl ]]; then
die "Failed to install perl"
fi
Expand Down