1 |
From: Kent Fredric <kentnl@g.o> |
2 |
|
3 |
--- |
4 |
eclass/perl-functions.eclass | 75 +++++++++++++++++++++++++++++++++++++++++++- |
5 |
1 file changed, 74 insertions(+), 1 deletion(-) |
6 |
|
7 |
diff --git a/eclass/perl-functions.eclass b/eclass/perl-functions.eclass |
8 |
index 1652ceaa10..9eed888f75 100644 |
9 |
--- a/eclass/perl-functions.eclass |
10 |
+++ b/eclass/perl-functions.eclass |
11 |
@@ -467,4 +467,77 @@ perl_get_vendorlib() { |
12 |
-e'exists $Config{$ARGV[0]} || die qq{No such Config key "$ARGV[0]"}; |
13 |
print $Config{$ARGV[0]} =~ s{\A\Q$ARGV[1]\E}{}r; |
14 |
exit 0' -- "installvendorlib" "$EPREFIX" || die "Can't extract installvendorlib from Perl Configuration" |
15 |
-} |
16 |
\ No newline at end of file |
17 |
+} |
18 |
+ |
19 |
+# @FUNCTION: perl_domodule |
20 |
+# @USAGE: perl_domodule [options] <files> |
21 |
+# @DESCRIPTION: |
22 |
+# Installs files in paths where they can be found in the default |
23 |
+# Perl runtime. |
24 |
+# |
25 |
+# The contents of the <files> list are copied into Perls Vendor library path |
26 |
+# as follows: |
27 |
+# @CODE |
28 |
+# # install perl/File.pm as Samba::File |
29 |
+# pushd perl/ |
30 |
+# perl_domodule -C Samba File.pm |
31 |
+# |
32 |
+# # install perl/ recursively under VENDORLIB/Samba/ |
33 |
+# pushd perl/ |
34 |
+# perl_domodule -C Samba -r . |
35 |
+# @CODE |
36 |
+# |
37 |
+# @CODE |
38 |
+# options: |
39 |
+# -C Target/Name |
40 |
+# The subdirectory relative to the Perl VENDOR_LIB |
41 |
+# to install into. |
42 |
+# |
43 |
+# defaults to "" |
44 |
+# -r |
45 |
+# Install directories recursively ( see doins ) |
46 |
+# files: |
47 |
+# list of .pm files to install to VENDORLIB |
48 |
+# @CODE |
49 |
+ |
50 |
+perl_domodule() { |
51 |
+ local target_prefix="" |
52 |
+ local files=() |
53 |
+ local doins_opts=() |
54 |
+ |
55 |
+ local recursive=false |
56 |
+ local target |
57 |
+ local file |
58 |
+ |
59 |
+ while [[ $# -gt 0 ]] ; do |
60 |
+ case $1 in |
61 |
+ -C|--target-prefix) |
62 |
+ [[ -z "${2}" || "${2:0:1}" == "-" ]] && die "${FUNCNAME}: -C|--target-prefix expects an argument, got \"$2\"!" |
63 |
+ target_prefix="${2}"; |
64 |
+ shift 2;; |
65 |
+ -r) |
66 |
+ recursive=true |
67 |
+ shift;; |
68 |
+ *) |
69 |
+ [[ -z "${1}" || "${1:0:1}" == "-" ]] && die "${FUNCNAME}: Unknown argument \"${1}\"!" |
70 |
+ files+=( "${1}" ) |
71 |
+ shift 1;; |
72 |
+ esac |
73 |
+ done |
74 |
+ |
75 |
+ if $recursive; then |
76 |
+ doins_opts+=( "-r" ) |
77 |
+ fi |
78 |
+ for file in "${files[@]}"; do |
79 |
+ [[ -e "${file}" ]] || die "$FUNCNAME: Argument \"${file}\" is not an existing file" |
80 |
+ [[ $recursive && -d "${file}" ]] && die "$FUNCNAME: Argument \"${file}\" is a directory ( needs -r parameter )" |
81 |
+ done |
82 |
+ |
83 |
+ target="$(perl_get_vendorlib)" |
84 |
+ |
85 |
+ # Extend target if target_prefix is set |
86 |
+ [[ -z "${target_prefix}" ]] || target="${target%/}/${target_prefix#/}" |
87 |
+ |
88 |
+ insinto "/${target#/}" |
89 |
+ doins "${doins_opts[@]}" "${files[@]}" |
90 |
+} |
91 |
-- |
92 |
2.11.0 |