From b0ae59724ed36242459a91c0f9c5ce036c46de41 Mon Sep 17 00:00:00 2001 From: Dominik Fischer Date: Thu, 23 Apr 2015 16:41:46 +0200 Subject: makepkg-template: support multiple --template-dirs Especially when maintaining local templates in addition to the ones stored in /usr/share/makepkg-template, it can be useful to include templates stored in multiple different locations into one PKGBUILD. This patch makes this possible by allowing --template-dir to be specified multiple times. This also introduces a dedicated error message when a template cannot be found, in contrast to the already existing "Couldn't detect version for template '%s'". If a template of the same name is present in more than one of the given directories, the last one always takes precedence. Neither the default behaviour without the option given, nor the handling of a single template dir is changed. Signed-off-by: Dominik Fischer Signed-off-by: Florian Pritz Signed-off-by: Allan McRae --- .../last-template-dir-has-precedece/PKGBUILD | 4 ++++ .../last-template-dir-has-precedece/PKGBUILD.expanded | 6 ++++++ .../templates/first/perl-module-1.0.template | 1 + .../templates/last/perl-module-1.0.template | 1 + .../last-template-dir-has-precedece/testcase-config | 15 +++++++++++++++ 5 files changed, 27 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD.expanded create mode 100644 test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/first/perl-module-1.0.template create mode 100644 test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/last/perl-module-1.0.template create mode 100644 test/scripts/makepkg-template-tests/last-template-dir-has-precedece/testcase-config (limited to 'test/scripts/makepkg-template-tests/last-template-dir-has-precedece') diff --git a/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD new file mode 100644 index 00000000..2813b757 --- /dev/null +++ b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD @@ -0,0 +1,4 @@ +pkgname=foo +pkgver=1 + +# template input; name=perl-module; version=1.0; diff --git a/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD.expanded b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD.expanded new file mode 100644 index 00000000..c1dbeb4a --- /dev/null +++ b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/PKGBUILD.expanded @@ -0,0 +1,6 @@ +pkgname=foo +pkgver=1 + +# template start; name=perl-module; version=1.0; +this should be included +# template end; diff --git a/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/first/perl-module-1.0.template b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/first/perl-module-1.0.template new file mode 100644 index 00000000..2649f782 --- /dev/null +++ b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/first/perl-module-1.0.template @@ -0,0 +1 @@ +this should be overwritten diff --git a/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/last/perl-module-1.0.template b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/last/perl-module-1.0.template new file mode 100644 index 00000000..409e8d43 --- /dev/null +++ b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/templates/last/perl-module-1.0.template @@ -0,0 +1 @@ +this should be included diff --git a/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/testcase-config b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/testcase-config new file mode 100644 index 00000000..fe38d659 --- /dev/null +++ b/test/scripts/makepkg-template-tests/last-template-dir-has-precedece/testcase-config @@ -0,0 +1,15 @@ +arguments+=(--template-dir $testdir/$testcase/templates/first) +arguments+=(--template-dir $testdir/$testcase/templates/last) +expected_exitcode=0 + +IFS="" read -d '' expected_output <<'EOF' +EOF + +IFS="" read -d '' expected_result <<'EOF' +pkgname=foo +pkgver=1 + +# template start; name=perl-module; version=1.0; +this should be included +# template end; +EOF -- cgit v1.2.3-70-g09d2