[build-path-prefix-map-spec] 39/50: Update producer examples and add tests and a perl example

Ximin Luo infinity0 at debian.org
Fri Mar 10 15:17:22 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 a00c41e31d388f85c76907bc9fbcabf3109341e9
Author: Ximin Luo <infinity0 at debian.org>
Date:   Fri Feb 24 15:42:56 2017 +0100

    Update producer examples and add tests and a perl example
---
 produce/hexsplit.mk | 14 --------------
 produce/pecsplit.mk | 13 +++++++++++++
 produce/pecsplit.pl | 20 ++++++++++++++++++++
 produce/print.sh    |  2 ++
 produce/test-all.sh | 28 ++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 14 deletions(-)

diff --git a/produce/hexsplit.mk b/produce/hexsplit.mk
deleted file mode 100755
index 7a67e0d..0000000
--- a/produce/hexsplit.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/make -f
-
-# Setting the variable
-
-spm_encode = $(subst :,%3a,$(subst =,%3d,$(subst %,%25,$(1))))
-
-export override SOURCE_PREFIX_MAP := $(if $(SOURCE_PREFIX_MAP),$(SOURCE_PREFIX_MAP)&,)$(call\
-spm_encode,aa with 100% sauce)=$(call\
-spm_encode,bbb)
-
-print-%:; @echo "$($*)"
-default: print-SOURCE_PREFIX_MAP
-
-# We don't expect Makefiles to have to read or apply the variable.
diff --git a/produce/pecsplit.mk b/produce/pecsplit.mk
new file mode 100755
index 0000000..700aba2
--- /dev/null
+++ b/produce/pecsplit.mk
@@ -0,0 +1,13 @@
+#!/usr/bin/make -sf
+
+# Setting the variable
+
+pfmap_enquote = $(subst :,%.,$(subst =,%+,$(subst %,%\#,$(1))))
+
+export override BUILD_PATH_PREFIX_MAP := $(BUILD_PATH_PREFIX_MAP):$(call\
+pfmap_enquote,$(NEWSRC))=$(call\
+pfmap_enquote,$(NEWDST))
+
+.PHONY: print.sh
+print.sh:
+	./$@
diff --git a/produce/pecsplit.pl b/produce/pecsplit.pl
new file mode 100755
index 0000000..f277383
--- /dev/null
+++ b/produce/pecsplit.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+
+# Setting the variable
+
+sub pfmap_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{"NEWSRC"}),
+	pfmap_enquote($ENV{"NEWDST"}));
+
+exec @ARGV;
diff --git a/produce/print.sh b/produce/print.sh
new file mode 100755
index 0000000..e35650c
--- /dev/null
+++ b/produce/print.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "$BUILD_PATH_PREFIX_MAP"
diff --git a/produce/test-all.sh b/produce/test-all.sh
new file mode 100755
index 0000000..3b3c606
--- /dev/null
+++ b/produce/test-all.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set -ex
+
+ALLCHECK="pecsplit.mk pecsplit.pl"
+
+test_mapping() {
+	#echo "$PS4$0" "$@" >&2
+	local src="$1"
+	local dst="$2"
+	local res_expect="$3"
+	local res_actual
+
+	for i in $ALLCHECK; do
+		res_actual="$(NEWSRC="$src" NEWDST="$dst" "./$i" ./print.sh)"
+		test "$res_actual" = "$res_expect" -o "$res_actual" = ":$res_expect"
+		res_actual="$(BUILD_PATH_PREFIX_MAP=a=b NEWSRC="$src" NEWDST="$dst" "./$i" ./print.sh)"
+		test "$res_actual" = "a=b:$res_expect"
+		res_actual="$(BUILD_PATH_PREFIX_MAP=/ab%+cd=/b NEWSRC="$src" NEWDST="$dst" "./$i" ./print.sh)"
+		test "$res_actual" = "/ab%+cd=/b:$res_expect"
+	done
+}
+
+test_mapping 'foo' 'bar' \
+	'foo=bar'
+
+test_mapping '/a/b=yyy' 'libbar-3-bison++_41:10.5-3~rc1pre3+dfsg1.1-3nmu1+b4' \
+	'/a/b%+yyy=libbar-3-bison++_41%.10.5-3~rc1pre3+dfsg1.1-3nmu1+b4'

-- 
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