1 |
Instead of adding a private function to get the unprefixed version of |
2 |
every path, use a new "_systemd_unprefix" helper function. |
3 |
|
4 |
Signed-off-by: Mike Gilbert <floppym@g.o> |
5 |
--- |
6 |
eclass/systemd.eclass | 69 ++++++++++++------------------------------- |
7 |
1 file changed, 19 insertions(+), 50 deletions(-) |
8 |
|
9 |
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass |
10 |
index 7731bede094..9e9a9b0cf20 100644 |
11 |
--- a/eclass/systemd.eclass |
12 |
+++ b/eclass/systemd.eclass |
13 |
@@ -1,4 +1,4 @@ |
14 |
-# Copyright 2011-2021 Gentoo Authors |
15 |
+# Copyright 2011-2022 Gentoo Authors |
16 |
# Distributed under the terms of the GNU General Public License v2 |
17 |
|
18 |
# @ECLASS: systemd.eclass |
19 |
@@ -53,20 +53,21 @@ _systemd_get_dir() { |
20 |
|
21 |
if $(tc-getPKG_CONFIG) --exists systemd; then |
22 |
d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die |
23 |
- d=${d#${EPREFIX}} |
24 |
else |
25 |
- d=${fallback} |
26 |
+ d="${EPREFIX}${fallback}" |
27 |
fi |
28 |
|
29 |
echo "${d}" |
30 |
} |
31 |
|
32 |
-# @FUNCTION: _systemd_get_systemunitdir |
33 |
+# @FUNCTION: _systemd_unprefix |
34 |
+# @USAGE: <function-name> |
35 |
# @INTERNAL |
36 |
# @DESCRIPTION: |
37 |
-# Get unprefixed unitdir. |
38 |
-_systemd_get_systemunitdir() { |
39 |
- _systemd_get_dir systemdsystemunitdir /lib/systemd/system |
40 |
+# Calls the specified function and removes ${EPREFIX} from the result. |
41 |
+_systemd_unprefix() { |
42 |
+ local d=$("${@}") |
43 |
+ echo "${d#"${EPREFIX}"}" |
44 |
} |
45 |
|
46 |
# @FUNCTION: systemd_get_systemunitdir |
47 |
@@ -77,7 +78,7 @@ _systemd_get_systemunitdir() { |
48 |
systemd_get_systemunitdir() { |
49 |
debug-print-function ${FUNCNAME} "${@}" |
50 |
|
51 |
- echo "${EPREFIX}$(_systemd_get_systemunitdir)" |
52 |
+ _systemd_get_dir systemdsystemunitdir /lib/systemd/system |
53 |
} |
54 |
|
55 |
# @FUNCTION: systemd_get_unitdir |
56 |
@@ -89,14 +90,6 @@ systemd_get_unitdir() { |
57 |
systemd_get_systemunitdir |
58 |
} |
59 |
|
60 |
-# @FUNCTION: _systemd_get_userunitdir |
61 |
-# @INTERNAL |
62 |
-# @DESCRIPTION: |
63 |
-# Get unprefixed userunitdir. |
64 |
-_systemd_get_userunitdir() { |
65 |
- _systemd_get_dir systemduserunitdir /usr/lib/systemd/user |
66 |
-} |
67 |
- |
68 |
# @FUNCTION: systemd_get_userunitdir |
69 |
# @DESCRIPTION: |
70 |
# Output the path for the systemd user unit directory (not including |
71 |
@@ -105,15 +98,7 @@ _systemd_get_userunitdir() { |
72 |
systemd_get_userunitdir() { |
73 |
debug-print-function ${FUNCNAME} "${@}" |
74 |
|
75 |
- echo "${EPREFIX}$(_systemd_get_userunitdir)" |
76 |
-} |
77 |
- |
78 |
-# @FUNCTION: _systemd_get_utildir |
79 |
-# @INTERNAL |
80 |
-# @DESCRIPTION: |
81 |
-# Get unprefixed utildir. |
82 |
-_systemd_get_utildir() { |
83 |
- _systemd_get_dir systemdutildir /lib/systemd |
84 |
+ _systemd_get_dir systemduserunitdir /usr/lib/systemd/user |
85 |
} |
86 |
|
87 |
# @FUNCTION: systemd_get_utildir |
88 |
@@ -124,15 +109,7 @@ _systemd_get_utildir() { |
89 |
systemd_get_utildir() { |
90 |
debug-print-function ${FUNCNAME} "${@}" |
91 |
|
92 |
- echo "${EPREFIX}$(_systemd_get_utildir)" |
93 |
-} |
94 |
- |
95 |
-# @FUNCTION: _systemd_get_systemgeneratordir |
96 |
-# @INTERNAL |
97 |
-# @DESCRIPTION: |
98 |
-# Get unprefixed systemgeneratordir. |
99 |
-_systemd_get_systemgeneratordir() { |
100 |
- _systemd_get_dir systemdsystemgeneratordir /lib/systemd/system-generators |
101 |
+ _systemd_get_dir systemdutildir /lib/systemd |
102 |
} |
103 |
|
104 |
# @FUNCTION: systemd_get_systemgeneratordir |
105 |
@@ -142,15 +119,7 @@ _systemd_get_systemgeneratordir() { |
106 |
systemd_get_systemgeneratordir() { |
107 |
debug-print-function ${FUNCNAME} "${@}" |
108 |
|
109 |
- echo "${EPREFIX}$(_systemd_get_systemgeneratordir)" |
110 |
-} |
111 |
- |
112 |
-# @FUNCTION: _systemd_get_systempresetdir |
113 |
-# @INTERNAL |
114 |
-# @DESCRIPTION: |
115 |
-# Get unprefixed systempresetdir. |
116 |
-_systemd_get_systempresetdir() { |
117 |
- _systemd_get_dir systemdsystempresetdir /lib/systemd/system-preset |
118 |
+ _systemd_get_dir systemdsystemgeneratordir /lib/systemd/system-generators |
119 |
} |
120 |
|
121 |
# @FUNCTION: systemd_get_systempresetdir |
122 |
@@ -160,7 +129,7 @@ _systemd_get_systempresetdir() { |
123 |
systemd_get_systempresetdir() { |
124 |
debug-print-function ${FUNCNAME} "${@}" |
125 |
|
126 |
- echo "${EPREFIX}$(_systemd_get_systempresetdir)" |
127 |
+ _systemd_get_dir systemdsystempresetdir /lib/systemd/system-preset |
128 |
} |
129 |
|
130 |
# @FUNCTION: systemd_dounit |
131 |
@@ -172,7 +141,7 @@ systemd_dounit() { |
132 |
|
133 |
( |
134 |
insopts -m 0644 |
135 |
- insinto "$(_systemd_get_systemunitdir)" |
136 |
+ insinto "$(_systemd_unprefix systemd_get_systemunitdir)" |
137 |
doins "${@}" |
138 |
) |
139 |
} |
140 |
@@ -186,7 +155,7 @@ systemd_newunit() { |
141 |
|
142 |
( |
143 |
insopts -m 0644 |
144 |
- insinto "$(_systemd_get_systemunitdir)" |
145 |
+ insinto "$(_systemd_unprefix systemd_get_systemunitdir)" |
146 |
newins "${@}" |
147 |
) |
148 |
} |
149 |
@@ -200,7 +169,7 @@ systemd_douserunit() { |
150 |
|
151 |
( |
152 |
insopts -m 0644 |
153 |
- insinto "$(_systemd_get_userunitdir)" |
154 |
+ insinto "$(_systemd_unprefix systemd_get_userunitdir)" |
155 |
doins "${@}" |
156 |
) |
157 |
} |
158 |
@@ -215,7 +184,7 @@ systemd_newuserunit() { |
159 |
|
160 |
( |
161 |
insopts -m 0644 |
162 |
- insinto "$(_systemd_get_userunitdir)" |
163 |
+ insinto "$(_systemd_unprefix systemd_get_userunitdir)" |
164 |
newins "${@}" |
165 |
) |
166 |
} |
167 |
@@ -262,7 +231,7 @@ systemd_enable_service() { |
168 |
|
169 |
local target=${1} |
170 |
local service=${2} |
171 |
- local ud=$(_systemd_get_systemunitdir) |
172 |
+ local ud=$(_systemd_unprefix systemd_get_systemunitdir) |
173 |
local destname=${service##*/} |
174 |
|
175 |
dodir "${ud}"/"${target}".wants && \ |
176 |
@@ -306,7 +275,7 @@ systemd_enable_ntpunit() { |
177 |
|
178 |
( |
179 |
insopts -m 0644 |
180 |
- insinto "$(_systemd_get_utildir)"/ntp-units.d |
181 |
+ insinto "$(_systemd_unprefix systemd_get_utildir)"/ntp-units.d |
182 |
doins "${T}"/${ntpunit_name}.list |
183 |
) |
184 |
local ret=${?} |
185 |
-- |
186 |
2.37.3 |