[prev in list] [next in list] [prev in thread] [next in thread]
List: gentoo-dev
Subject: [gentoo-dev] [PATCH 6/6] perl-functions.eclass: add perl_domodule
From: kentnl () gentoo ! org
Date: 2017-01-24 15:22:01
Message-ID: 20170124152201.15415-7-kentnl () gentoo ! org
[Download RAW message or body]
From: Kent Fredric <kentnl@gentoo.org>
---
eclass/perl-functions.eclass | 75 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/eclass/perl-functions.eclass b/eclass/perl-functions.eclass
index 1652ceaa10..9eed888f75 100644
--- a/eclass/perl-functions.eclass
+++ b/eclass/perl-functions.eclass
@@ -467,4 +467,77 @@ perl_get_vendorlib() {
-e'exists $Config{$ARGV[0]} || die qq{No such Config key "$ARGV[0]"};
print $Config{$ARGV[0]} =~ s{\A\Q$ARGV[1]\E}{}r;
exit 0' -- "installvendorlib" "$EPREFIX" || die "Can't extract installvendorlib \
from Perl Configuration"
-}
\ No newline at end of file
+}
+
+# @FUNCTION: perl_domodule
+# @USAGE: perl_domodule [options] <files>
+# @DESCRIPTION:
+# Installs files in paths where they can be found in the default
+# Perl runtime.
+#
+# The contents of the <files> list are copied into Perls Vendor library path
+# as follows:
+# @CODE
+# # install perl/File.pm as Samba::File
+# pushd perl/
+# perl_domodule -C Samba File.pm
+#
+# # install perl/ recursively under VENDORLIB/Samba/
+# pushd perl/
+# perl_domodule -C Samba -r .
+# @CODE
+#
+# @CODE
+# options:
+# -C Target/Name
+# The subdirectory relative to the Perl VENDOR_LIB
+# to install into.
+#
+# defaults to ""
+# -r
+# Install directories recursively ( see doins )
+# files:
+# list of .pm files to install to VENDORLIB
+# @CODE
+
+perl_domodule() {
+ local target_prefix=""
+ local files=()
+ local doins_opts=()
+
+ local recursive=false
+ local target
+ local file
+
+ while [[ $# -gt 0 ]] ; do
+ case $1 in
+ -C|--target-prefix)
+ [[ -z "${2}" || "${2:0:1}" == "-" ]] && die "${FUNCNAME}: -C|--target-prefix \
expects an argument, got \"$2\"!" + target_prefix="${2}";
+ shift 2;;
+ -r)
+ recursive=true
+ shift;;
+ *)
+ [[ -z "${1}" || "${1:0:1}" == "-" ]] && die "${FUNCNAME}: Unknown argument \
\"${1}\"!" + files+=( "${1}" )
+ shift 1;;
+ esac
+ done
+
+ if $recursive; then
+ doins_opts+=( "-r" )
+ fi
+ for file in "${files[@]}"; do
+ [[ -e "${file}" ]] || die "$FUNCNAME: Argument \"${file}\" is not an existing \
file" + [[ $recursive && -d "${file}" ]] && die "$FUNCNAME: Argument \"${file}\" is \
a directory ( needs -r parameter )" + done
+
+ target="$(perl_get_vendorlib)"
+
+ # Extend target if target_prefix is set
+ [[ -z "${target_prefix}" ]] || target="${target%/}/${target_prefix#/}"
+
+ insinto "/${target#/}"
+ doins "${doins_opts[@]}" "${files[@]}"
+}
--
2.11.0
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic