This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch branch-1.12
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.12 by this push:
     new 846a2017d7 AVRO-4239: fix Perl porting's lack of version number (#3704)
846a2017d7 is described below

commit 846a2017d7f782a1243e727a48de6bd44286475e
Author: Alvaro <[email protected]>
AuthorDate: Wed Apr 15 07:09:41 2026 +0200

    AVRO-4239: fix Perl porting's lack of version number (#3704)
    
    Co-authored-by: Alvaro Livraghi <[email protected]>
---
 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 0674514797..61bbe3c633 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 5da5e21542..4c07baac00 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 e7634dbaba..fa984f389c 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)

Reply via email to