Skip to content

Commit

Permalink
fix broken carton update
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Jun 10, 2024
1 parent 8be0b08 commit f40ef8d
Show file tree
Hide file tree
Showing 6 changed files with 465 additions and 36 deletions.
9 changes: 2 additions & 7 deletions author/carton/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ RUN curl --compressed -sSL https://raw.githubusercontent.com/tokuhirom/Perl-Buil
RUN apk del perl patch

ENV PATH=/opt/perl-5.8/bin:$PATH
RUN curl --compressed -sSL https://cpanmin.us/ | perl - --notest Distribution::[email protected] App::FatPacker::[email protected] Carton ExtUtils::PL2Bat
RUN curl --compressed -sSL https://cpanmin.us/ | \
perl - --notest Carton ExtUtils::PL2Bat

RUN mkdir -p /tmp/carton
WORKDIR /tmp/carton

COPY cpanfile .
COPY build.pl .
COPY cpanfile.snapshot .

RUN carton install --deployment
33 changes: 22 additions & 11 deletions author/carton/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,36 @@ all: carton

.PHONY: image
image: .image.exists ## build docker image of packing environment
.DELETE_ON_ERROR: .image.exists
.image.exists: Dockerfile cpanfile cpanfile.snapshot build.pl
touch .image.exists
-docker rmi $(IMAGE_NAME)
docker build -t $(IMAGE_NAME) .
touch .image.exists

.container.exists: .image.exists
-docker rm $(IMAGE_NAME)-tmp
docker run --name $(IMAGE_NAME)-tmp $(IMAGE_NAME) perl build.pl
touch .container.exists

carton: .container.exists ## generate fat-packed carton
docker cp $(IMAGE_NAME)-tmp:/tmp/carton/carton carton
carton: .deps.exists build.pl ## generate fat-packed carton
cat build.pl | docker run --rm -i --volumes-from $(IMAGE_NAME)-deps $(IMAGE_NAME) perl -
docker cp $(IMAGE_NAME)-deps:/tmp/carton/carton carton

.PHONY: deps
deps: .deps.exists ## install dependencies
.DELETE_ON_ERROR: .deps.exists
.deps.exists: .image.exists cpanfile.snapshot
touch .deps.exists
-docker rm $(IMAGE_NAME)-deps
docker create -v /tmp/carton --name $(IMAGE_NAME)-deps $(IMAGE_NAME) /bin/true
docker cp cpanfile $(IMAGE_NAME)-deps:/tmp/carton/cpanfile
docker cp cpanfile.snapshot $(IMAGE_NAME)-deps:/tmp/carton/cpanfile.snapshot
docker run --rm --volumes-from $(IMAGE_NAME)-deps $(IMAGE_NAME) carton install --deployment
docker cp $(IMAGE_NAME)-deps:/tmp/carton/local .

.PHONY: update
update: .image.exists ## download dependencies and update cpanfile.snapshot
-docker rm $(IMAGE_NAME)-update
docker run --name $(IMAGE_NAME)-update $(IMAGE_NAME) \
sh -c "rm -f cpanfile.snapshot && rm -rf local && carton install"
docker create -v /tmp/carton --name $(IMAGE_NAME)-update $(IMAGE_NAME) /bin/true
docker cp cpanfile $(IMAGE_NAME)-update:/tmp/carton/cpanfile
docker run --rm --volumes-from $(IMAGE_NAME)-update $(IMAGE_NAME) carton install
docker cp $(IMAGE_NAME)-update:/tmp/carton/cpanfile.snapshot cpanfile.snapshot
-docker rm $(IMAGE_NAME)-update

.PHONY: install
install: all ## installs into the bin directory of this repository
Expand All @@ -36,7 +47,7 @@ install: all ## installs into the bin directory of this repository
.PHONY: clean
clean:
rm -f carton carton.bat
rm -f .image.exists .container.exists
rm -f .image.exists .deps.exists
-docker rm $(IMAGE_NAME)-tmp
-docker rm $(IMAGE_NAME)-update
-docker rmi $(IMAGE_NAME)
9 changes: 9 additions & 0 deletions author/carton/build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/local/lib/perl5";
use App::FatPacker::Simple;
use Carton::Snapshot;
use ExtUtils::PL2Bat qw/pl2bat/;
Expand All @@ -18,6 +19,14 @@ sub fatpack {
',',
# configure modules
'Module::Build',
# fat-packing
'App::FatPacker', 'App::FatPacker::Simple',
'Clone', 'Distribution::Metadata',
'ExtUtils::CBuilder', 'ExtUtils::ParseXS',
'IO::String', 'JSON', 'Module::Build::Tiny', 'PPI',
'Params::Util', 'Cwd', 'List::Util',
'Perl::Strip', 'Scalar::Util', 'Storable',
'Task::Weaken', 'Perl::OSType', 'XSLoader', 'common::sense',
# test modules
'Test2','App::Prove','TAP::Harness',
# core modules of perl 5
Expand Down
5 changes: 5 additions & 0 deletions author/carton/cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ requires 'perl', '5.006';
requires 'Carton';
requires 'Menlo::Legacy';
requires 'Menlo';
requires 'CPAN::Meta::Requirements', '==2.140'; # 2.141 doesn't support perl 5.8.
requires 'Distribution::Metadata', '==0.06';
requires 'App::FatPacker::Simple', '==0.09';
requires 'Module::Build::Tiny', '==0.047'; # 0.048 doesn't work on perl 5.8.

requires 'Menlo::Index::Mirror';
requires 'ExtUtils::Manifest', '1.70';
requires 'ExtUtils::MakeMaker', '7.52';
Expand Down
Loading

0 comments on commit f40ef8d

Please sign in to comment.