Skip to content

Commit 33b104f

Browse files
alivraghiAlvaro Livraghi
authored andcommitted
AVRO-4239: fix Perl porting's lack of version number (#3704)
Co-authored-by: Alvaro Livraghi <a.livraghi@sirti.it> (cherry picked from commit 846a201)
1 parent 3296361 commit 33b104f

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

lang/perl/MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ META.yml
4040
LICENSE
4141
NOTICE
4242
README
43+
VERSION.txt
4344
t/00_compile.t
4445
t/01_names.t
4546
t/01_schema.t

lang/perl/Makefile.PL

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ use Config;
1919
use inc::Module::Install;
2020

2121
my $version;
22-
$version = `cat ../../share/VERSION.txt`;
22+
# We need to have VERSION.txt file in place to allow Avro.pm to get the version from it,
23+
# but VERSION.txt has to be copied from ../../share/VERSION.txt.
24+
# If we are in a cpan* installation we expect VERSION.txt to be already in place,
25+
# but if we are in a git clone it won't be there, so we need to copy it.
26+
unless (-f 'VERSION.txt') {
27+
`cp -vf ../../share/VERSION.txt ./`;
28+
}
29+
$version = `cat VERSION.txt`;
2330
chomp $version;
2431

2532
license 'apache';
@@ -67,4 +74,9 @@ my %packages = (
6774
my %provides = map { $_ => { file => $packages{$_}, version => $version } } keys %packages;
6875
provides(%provides);
6976

70-
WriteMakefile(PM_FILTER => "sed -e 's/\+\+MODULE_VERSION\+\+/$version/'");
77+
WriteMakefile(
78+
PM_FILTER => "sed -e 's/\+\+MODULE_VERSION\+\+/$version/'",
79+
realclean => {
80+
FILES => "VERSION.txt" # can be removed on realclean
81+
}
82+
);

lang/perl/build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ case "$target" in
5858
;;
5959

6060
dist)
61-
perl ./Makefile.PL && make dist
61+
# The dist target is used to create a distribution tarball that can be uploaded to CPAN,
62+
# so we need to add VERSION.txt to the tarball to make it available to Makefile.PL
63+
cp -vf ../../share/VERSION.txt ./ && \
64+
perl ./Makefile.PL && make dist && \
65+
rm -vf ./VERSION.txt
6266
;;
6367

6468
clean)

0 commit comments

Comments
 (0)