From d4cf5a864408773c36fc0cb72d652096310146a1 Mon Sep 17 00:00:00 2001 From: Alvaro Livraghi Date: Wed, 25 Mar 2026 15:02:59 +0100 Subject: [PATCH] AVRO-4239: fix Perl porting's lack of version number --- lang/perl/MANIFEST | 1 + lang/perl/Makefile.PL | 16 ++++++++++++++-- lang/perl/build.sh | 6 +++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lang/perl/MANIFEST b/lang/perl/MANIFEST index 0674514797f..61bbe3c633f 100644 --- a/lang/perl/MANIFEST +++ b/lang/perl/MANIFEST @@ -40,6 +40,7 @@ META.yml LICENSE NOTICE README +VERSION.txt t/00_compile.t t/01_names.t t/01_schema.t diff --git a/lang/perl/Makefile.PL b/lang/perl/Makefile.PL index 5da5e215423..4c07baac00e 100644 --- a/lang/perl/Makefile.PL +++ b/lang/perl/Makefile.PL @@ -19,7 +19,14 @@ use Config; use inc::Module::Install; my $version; -$version = `cat ../../share/VERSION.txt`; +# We need to have VERSION.txt file in place to allow Avro.pm to get the version from it, +# but VERSION.txt has to be copied from ../../share/VERSION.txt. +# If we are in a cpan* installation we expect VERSION.txt to be already in place, +# but if we are in a git clone it won't be there, so we need to copy it. +unless (-f 'VERSION.txt') { + `cp -vf ../../share/VERSION.txt ./`; +} +$version = `cat VERSION.txt`; chomp $version; license 'apache'; @@ -67,4 +74,9 @@ my %packages = ( my %provides = map { $_ => { file => $packages{$_}, version => $version } } keys %packages; provides(%provides); -WriteMakefile(PM_FILTER => "sed -e 's/\+\+MODULE_VERSION\+\+/$version/'"); +WriteMakefile( + PM_FILTER => "sed -e 's/\+\+MODULE_VERSION\+\+/$version/'", + realclean => { + FILES => "VERSION.txt" # can be removed on realclean + } +); diff --git a/lang/perl/build.sh b/lang/perl/build.sh index e7634dbabab..fa984f389cd 100755 --- a/lang/perl/build.sh +++ b/lang/perl/build.sh @@ -58,7 +58,11 @@ case "$target" in ;; dist) - perl ./Makefile.PL && make dist + # The dist target is used to create a distribution tarball that can be uploaded to CPAN, + # so we need to add VERSION.txt to the tarball to make it available to Makefile.PL + cp -vf ../../share/VERSION.txt ./ && \ + perl ./Makefile.PL && make dist && \ + rm -vf ./VERSION.txt ;; clean)