[build-path-prefix-map-spec] 02/02: Improve the Perl example
Ximin Luo
infinity0 at debian.org
Fri Apr 7 16:45:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository build-path-prefix-map-spec.
commit ced69b842c44b0ce2d8a160a5a0fdf0addf2db8d
Author: Ximin Luo <infinity0 at debian.org>
Date: Fri Mar 31 18:53:15 2017 -0400
Improve the Perl example
- Refactor env-var stuff out of the core logic
- Fix checking the current value
- Longer names for clarity and less conflict with existing code
---
produce/pecsplit.pl | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/produce/pecsplit.pl b/produce/pecsplit.pl
index 229b078..5bc342e 100755
--- a/produce/pecsplit.pl
+++ b/produce/pecsplit.pl
@@ -1,20 +1,28 @@
#!/usr/bin/perl
+# TODO: this needs review by a Perl expert, I am a Perl newbie.
use strict;
+use warnings;
# Setting the variable
-sub pfmap_enquote {
- my $part = shift;
- $part =~ s/%/%#/g;
- $part =~ s/=/%+/g;
- $part =~ s/:/%./g;
- return $part;
- }
+sub path_prefix_map_enquote {
+ my $part = shift;
+ $part =~ s/%/%#/g;
+ $part =~ s/=/%+/g;
+ $part =~ s/:/%./g;
+ return $part;
+}
-$ENV{"BUILD_PATH_PREFIX_MAP"} = sprintf("%s:%s=%s",
- $ENV{"BUILD_PATH_PREFIX_MAP"},
- pfmap_enquote($ENV{"NEWDST"}),
- pfmap_enquote($ENV{"NEWSRC"}));
+sub path_prefix_map_append($$$) {
+ my $curmap = shift;
+ my $dst = shift;
+ my $src = shift;
+ return (length($curmap) ? $curmap . ":" : "") .
+ path_prefix_map_enquote($dst) . "=" . path_prefix_map_enquote($src);
+}
+
+$ENV{"BUILD_PATH_PREFIX_MAP"} = path_prefix_map_append(
+ $ENV{"BUILD_PATH_PREFIX_MAP"}, $ENV{"NEWDST"}, $ENV{"NEWSRC"});
exec @ARGV;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/build-path-prefix-map-spec.git
More information about the Reproducible-commits
mailing list