relocatable-perl/support-srcpath-option-for-build.patch
2025-05-12 15:10:06 +08:00

107 lines
3.4 KiB
Diff

From d847354f4a0a0e2450e559e162257b096bc53973 Mon Sep 17 00:00:00 2001
From: zhangyao <zhangyao108@huawei.com>
Date: Fri, 25 Apr 2025 16:05:43 +0800
Subject: [PATCH] support srcpath option for build
---
build/relocatable-perl-build | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/build/relocatable-perl-build b/build/relocatable-perl-build
index 0b2f6b2..22bfbba 100644
--- a/build/relocatable-perl-build
+++ b/build/relocatable-perl-build
@@ -51,6 +51,7 @@ relocatable-perl-build - building perl with relocatable settings
--perl_version install perl version
--tarball use local tar.gz
--jobs parallel build, default: 1
+ --srcpath use local perl source path
--help, -h show this help message
Examples:
@@ -68,6 +69,7 @@ GetOptions
"prefix=s" => \(my $prefix),
"perl_version=s" => \(my $perl_version),
"tarball=s" => \(my $tarball),
+ "srcpath=s" => \(my $srcpath),
"jobs=i" => \(my $jobs),
"help|h" => sub { pod2usage(0) },
or pod2usage(1);
@@ -75,6 +77,8 @@ or pod2usage(1);
$prefix or do { warn "prefix option is required.\n"; pod2usage(1) };
if ($tarball && $tarball =~ /5\.(\d+)\.(\d+)/) {
$perl_version = "5.$1.$2";
+} elsif ($perl_version && $perl_version =~ /5\.(\d+)\.(\d+)/) {
+ $perl_version = "5.$1.$2";
}
$perl_version or do { warn "perl_verion option is required.\n"; pod2usage(1) };
@@ -84,7 +88,7 @@ if (!-d $prefix) {
die "don't have write permission to $prefix\n";
}
-perl_build($prefix, $perl_version, $tarball);
+perl_build($prefix, $perl_version, $tarball, $srcpath);
force_symlink($prefix, $perl_version);
my $config_heavy = `$prefix/bin/perldoc -lm Config_heavy.pl`;
@@ -103,7 +107,7 @@ system "$prefix/bin/perl -V";
exit;
sub perl_build {
- my ($prefix, $perl_version, $tarball) = @_;
+ my ($prefix, $perl_version, $tarball, $srcpath) = @_;
my $current_dir = getcwd;
@@ -113,7 +117,10 @@ sub perl_build {
mkdir $tempdir or die "mkdir $tempdir: $!\n";
my %tar_option = ("tar.gz" => "xzf", "tar.bz2" => "xjf", "tar.xz" => "xJf");
- if ($tarball) {
+ if ($srcpath) {
+ say "---> use $srcpath";
+ $tempdir = $srcpath;
+ } elsif ($tarball) {
say "---> use $tarball";
my ($suffix) = $tarball =~ /\.(tar\.(?:gz|bz2|xz))$/;
run ["tar", $tar_option{$suffix}, $tarball, "-C", $tempdir], $log;
@@ -136,6 +143,8 @@ sub perl_build {
"-Dman1dir=none",
"-Dman3dir=none",
"-DDEBUGGING=-g",
+ "-Dusethreads",
+ "-Duseithreads",
);
if ($Config{archname} =~ /linux/i) {
# ubuntu 18.04 does not have xlocale.h
@@ -150,16 +159,22 @@ sub perl_build {
}
push @Configure, "-des";
- chdir "$tempdir/perl-$perl_version" or die;
+ if ($srcpath) {
+ chdir "$tempdir" or die;
+ } else {
+ chdir "$tempdir/perl-$perl_version" or die;
+ }
my $devel = "Devel::PatchPerl";
say "---> patching by $devel " . $devel->VERSION;
$devel->patch_source($perl_version, ".");
say "---> building perl $perl_version, see $log for progress";
run \@Configure, $log;
my @option = $jobs ? ("--jobs=$jobs") : ();
- run ["make", @option, "install"], $log;
+ run ["make", @option, "install"];
chdir $current_dir;
- rmtree $tempdir;
+ if (!$srcpath) {
+ rmtree $tempdir;
+ }
}
sub patch_config_heavy {
--
2.33.0