Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
skaji committed Jun 23, 2019
1 parent 9caf52e commit dcc03dc
Show file tree
Hide file tree
Showing 5 changed files with 1,295 additions and 45 deletions.
58 changes: 36 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
FROM centos:centos6
FROM centos:centos6 as builder

RUN yum install -y gcc make tar curl patch bzip2 xz && \
rm -rf /var/cache/yum/* && \
yum clean all
RUN mkdir /tmp/build /artifact
RUN curl -fsSL https://github.com/skaji/relocatable-perl/releases/download/5.26.2.0/perl-x86_64-linux.tar.gz | tar xzf - --strip-components 1 -C /usr/local
RUN yum install -y \
gcc \
make \
tar \
curl \
patch \
xz
RUN mkdir -p \
/lib \
/lib/x86_64-linux-gnu \
/lib64 \
/usr/lib \
/usr/lib/x86_64-linux-gnu \
/usr/lib64 \
/usr/local/lib \
/usr/local/lib64
RUN curl -fsSL https://git.io/perl-install | bash -s /perl
COPY relocatable-perl-build BUILD_VERSION /
RUN /perl/bin/perl /relocatable-perl-build --perl_version $(cat /BUILD_VERSION) --prefix /opt/perl
RUN curl -fsSL https://git.io/cpm | /opt/perl/bin/perl - install -g App::cpanminus App::ChangeShebang
RUN /opt/perl/bin/change-shebang -f /opt/perl/bin/*
RUN cp -r /opt/perl /tmp/perl-x86_64-linux
RUN set -eux; \
cd /tmp; \
tar cf perl-x86_64-linux.tar perl-x86_64-linux; \
gzip -9 --stdout perl-x86_64-linux.tar > /perl-x86_64-linux.tar.gz; \
xz -9 --stdout perl-x86_64-linux.tar > /perl-x86_64-linux.tar.xz; \
true

RUN /usr/local/bin/perl -e 'mkdir $_ for grep !-d, @ARGV' /usr/local/lib64 /usr/local/lib /lib/x86_64-linux-gnu /lib64 /lib /usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib

ADD relocatable-perl-build /tmp/build/relocatable-perl-build
ADD BUILD_VERSION /tmp/build/BUILD_VERSION
RUN /usr/local/bin/perl /tmp/build/relocatable-perl-build --perl_version `cat /tmp/build/BUILD_VERSION` --prefix /opt/perl && \
curl --compressed -fsSL https://git.io/cpm | /opt/perl/bin/perl - install -g App::cpanminus App::ChangeShebang && \
rm -rf ~/.perl-cpm && \
/opt/perl/bin/change-shebang -f /opt/perl/bin/* && \
cp -r /opt/perl /tmp/perl-x86_64-linux && \
cd /tmp && \
tar cf perl-x86_64-linux.tar perl-x86_64-linux && \
gzip -9 --stdout perl-x86_64-linux.tar > /artifact/perl-x86_64-linux.tar.gz && \
xz -9 --stdout perl-x86_64-linux.tar > /artifact/perl-x86_64-linux.tar.xz && \
rm -rf /tmp/perl-x86_64-linux*

CMD ["sleep", "infinity"]
FROM alpine
COPY --from=builder /perl-x86_64-linux.tar.gz /perl-x86_64-linux.tar.gz
COPY --from=builder /perl-x86_64-linux.tar.xz /perl-x86_64-linux.tar.xz
# ID=$(docker create skaji/relocatable-perl)
# docker cp $ID:/perl-x86_64-linux.tar.gz .
# docker cp $ID:/perl-x86_64-linux.tar.xz .
# docker rm $ID
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ then we have self-contained and portable perl.

### One liner

curl -sSL https://git.io/perl-install | bash -s ~/perl
curl -fsSL https://git.io/perl-install | bash -s ~/perl

This installs the latest relocatable perl to `~/perl`.

Expand Down
23 changes: 14 additions & 9 deletions perl-install
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ if [[ $1 = "--print-version" ]]; then
PRINT_VERSION=YES
fi

if [[ `uname -m` != "x86_64" ]]; then
if [[ $(uname -m) != "x86_64" ]]; then
die "Only support x86_64"
fi

if [[ `uname -s` = "Darwin" ]]; then
if [[ $(uname -s) = "Darwin" ]]; then
ARCHNAME=darwin-2level
elif [[ `uname -s` = "Linux" ]]; then
elif [[ $(uname -s) = "Linux" ]]; then
ARCHNAME=x86_64-linux
else
die "Only support Darwin or Linux"
fi

if type curl &>/dev/null; then
HTTP_GET=curl
HTTP_GET_OPTION='-sSL'
HTTP_GET_OPTION='-fsSL'
elif type wget &>/dev/null; then
HTTP_GET=wget
HTTP_GET_OPTION='-q -O -'
else
die 'Cannot find `curl` nor `wget`'
fi

TAG=`$HTTP_GET $HTTP_GET_OPTION https://raw.githubusercontent.com/skaji/relocatable-perl/master/LATEST`
TAG=$($HTTP_GET $HTTP_GET_OPTION https://raw.githubusercontent.com/skaji/relocatable-perl/master/LATEST)
if [[ -z $TAG ]]; then
die "Failed to determine latest perl version"
fi
Expand All @@ -49,8 +49,12 @@ if [[ $PRINT_VERSION = "YES" ]]; then
exit
fi

if ! type tar &>/dev/null; then
die 'Cannot find `tar` command'
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
Expand All @@ -64,14 +68,15 @@ INSTALL_DIR=$1
if [[ -d $INSTALL_DIR ]]; then
[[ -w $INSTALL_DIR ]] || die "You don't have write permission to $INSTALL_DIR"
else
mkdir $INSTALL_DIR
mkdir -p $INSTALL_DIR
[[ -d $INSTALL_DIR ]] || die "Cannot create $INSTALL_DIR"
fi
ABS_INSTALL_DIR=$(cd $INSTALL_DIR &>/dev/null; pwd)

URL=https://github.com/skaji/relocatable-perl/releases/download/$TAG/perl-$ARCHNAME.$TAR_SUFFIX
echo "Installing perl $TAG to $INSTALL_DIR, this may take a while..."

$HTTP_GET $HTTP_GET_OPTION $URL | tar $TAR_OPTION - --strip-components 1 -C $INSTALL_DIR
$HTTP_GET $HTTP_GET_OPTION $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
Loading

0 comments on commit dcc03dc

Please sign in to comment.