Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-eselect/eselect-xvmc/files: eselect-xvmc-0.3.eselect eselect-xvmc-0.4.eselect
Date: Tue, 31 Mar 2015 16:58:45
Message-Id: 20150331165842.56E7214EE1@oystercatcher.gentoo.org
1 ulm 15/03/31 16:58:41
2
3 Added: eselect-xvmc-0.3.eselect eselect-xvmc-0.4.eselect
4 Log:
5 Move package from app-admin to app-eselect category.
6
7 (Portage version: 2.2.18/cvs/Linux x86_64, RepoMan options: --force, signed Manifest commit with key 9433907D693FB5B8!)
8
9 Revision Changes Path
10 1.1 app-eselect/eselect-xvmc/files/eselect-xvmc-0.3.eselect
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-xvmc/files/eselect-xvmc-0.3.eselect?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-xvmc/files/eselect-xvmc-0.3.eselect?rev=1.1&content-type=text/plain
14
15 Index: eselect-xvmc-0.3.eselect
16 ===================================================================
17 # Copyright 1999-2015 Gentoo Foundation
18 # Distributed under the terms of the GNU General Public License v2
19 # $Id: eselect-xvmc-0.3.eselect,v 1.1 2015/03/31 16:58:41 ulm Exp $
20
21 DESCRIPTION="Manage the XvMC implementation used by your system"
22 MAINTAINER="cardoe@g.o"
23 SVN_DATE='$Date: 2015/03/31 16:58:41 $'
24 VERSION=$(svn_date_to_version "${SVN_DATE}" )
25
26 XVMCLIBS=(
27 "libXvMCNVIDIA_dynamic.so.1"
28 "libXvMC.so.1"
29 "libviaXvMC.so.1"
30 "libviaXvMCPro.so.1"
31 "libchromeXvMC.so.1"
32 "libchromeXvMCPro.so.1"
33 "libXvMCVIA.so"
34 "libXvMCVIAPro.so"
35 "libI810XvMC.so.1"
36 "/usr/lib/libIntelXvMC.so"
37 "libAMDXvBA.so.1" )
38 XVMCPRETTY=(
39 "nvidia"
40 "xorg-x11"
41 "via"
42 "via-pro"
43 "openchrome"
44 "openchrome-pro"
45 "unichrome"
46 "unichrome-pro"
47 "intel-i815"
48 "intel-i915"
49 "ati" )
50
51 get_implementation_indices() {
52 local ret n
53 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
54 [[ -e "${ROOT}/usr/lib/${XVMCLIBS[n]}" ]] && ret+=($n)
55 done
56
57 echo ${ret[@]}
58 }
59
60 get_current_implementation_index() {
61 local n
62 if [[ -f "${ROOT}/etc/X11/XvMCConfig" ]]; then
63 local current=$(< "${ROOT}/etc/X11/XvMCConfig")
64 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
65 if [[ "${XVMCLIBS[n]}" = "${current}" ]]; then
66 echo "${n}"
67 return
68 fi
69 done
70 fi
71
72 echo "-1"
73 }
74
75 set_new_implementation() {
76 echo -n "Switching to ${XVMCPRETTY[$1]} XvMC implementation..."
77 touch "${ROOT}/etc/X11/XvMCConfig" 2>&1 > /dev/null
78 if [[ $? -eq 0 ]]; then
79 echo "${XVMCLIBS[$1]}" > "${ROOT}/etc/X11/XvMCConfig"
80 chmod 644 "${ROOT}/etc/X11/XvMCConfig"
81 chown 0:0 "${ROOT}/etc/X11/XvMCConfig"
82 echo " done"
83 else
84 echo " failed!"
85 echo "Insufficient privileges"
86 fi
87 }
88
89 ### list action
90
91 ## {{{ list stuff
92 describe_list() {
93 echo "List Available XvMC implementations"
94 }
95
96 do_list() {
97 local output n
98 local avail=( $(get_implementation_indices) )
99 local current=$(get_current_implementation_index)
100 write_list_start "Available XvMC implementations ( $(highlight '*') is current ):"
101
102 if (( ${#avail[@]} )) ; then
103 for n in "${avail[@]}" ; do
104 output[n]="${XVMCPRETTY[n]}"
105 [[ ${current} -eq ${n} ]] && \
106 output[n]+=" $(highlight '*')"
107 done
108 write_numbered_list "${output[@]}"
109 else
110 write_kv_list_entry "(none found)" ""
111 fi
112
113 return 0
114 }
115 ## }}}
116
117 ### show action
118
119 ## {{{ show stuff
120 describe_show() {
121 echo "Print the current XvMC implementation."
122 }
123
124 do_show() {
125 local current=$(get_current_implementation_index)
126 write_list_start "Current XvMC implementation:"
127
128 if [[ ${current} -ne -1 ]]; then
129 echo "${XVMCPRETTY[current]}"
130 return 0
131 else
132 echo "(none)"
133 return 2
134 fi
135 }
136 ## }}}
137
138 ### set action
139
140 ## {{{ set stuff
141 describe_set() {
142 echo "Select the XvMC implementation"
143 }
144
145 describe_set_parameters() {
146 echo "<target>"
147 }
148
149 describe_set_options() {
150 echo "<target> : XvMC implementation to activate"
151 echo "--use-old : If an implementation is already set, use that one instead"
152 }
153
154 do_set() {
155 local current=$(get_current_implementation_index)
156 local avail=( $(get_implementation_indices) )
157 local n new action
158
159 while [[ ${#@} -gt 0 ]]; do
160 local opt=${1}
161 shift
162 case ${opt} in
163 --use-old)
164 if [[ ${current} -gt -1 ]]; then
165 (( ${current} < ${#XVMCPRETTY[@]} )) && action="old-implementation"
166 fi
167 ;;
168 *)
169 [[ -z ${action} ]] && action="set-implementation"
170
171 if is_number ${opt} ; then
172 new=${avail[opt - 1]}
173 if [[ -z ${new} ]]; then
174 die -q "Unrecognized option: ${opt}"
175 fi
176 elif has ${opt} ${XVMCPRETTY[@]}; then
177 for (( n = 0; n < ${#XVMCPRETTY[@]}; ++n )); do
178 [[ "${XVMCPRETTY[n]}" = "${opt}" ]] && new=${n}
179 done
180 else
181 die -q "Unrecognized option: ${opt}"
182 fi
183 ;;
184 esac
185 done
186
187 case ${action} in
188 old-implementation)
189 set_new_implementation ${current}
190 return $?
191 ;;
192 set-implementation)
193 if [[ -n ${new} ]]; then
194 set_new_implementation ${new}
195 return $?
196 else
197 die -q "Please specify an implementation to set"
198 fi
199 ;;
200 *)
201 die -q "Invalid usage of set action."
202 esac
203 }
204
205 # vim: ts=4 sw=4 noet fdm=marker
206
207
208
209 1.1 app-eselect/eselect-xvmc/files/eselect-xvmc-0.4.eselect
210
211 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-xvmc/files/eselect-xvmc-0.4.eselect?rev=1.1&view=markup
212 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-xvmc/files/eselect-xvmc-0.4.eselect?rev=1.1&content-type=text/plain
213
214 Index: eselect-xvmc-0.4.eselect
215 ===================================================================
216 # -*-eselect-*- vim: ft=eselect
217 # Copyright 1999-2015 Gentoo Foundation
218 # Distributed under the terms of the GNU General Public License v2
219
220 DESCRIPTION="Manage the XvMC implementation used by your system"
221 MAINTAINER="{cardoe,ottxor}@gentoo.org"
222 VERSION="0.4"
223
224 init_XVMC_vars() {
225 get_libname() {
226 case ${OSTYPE} in
227 darwin*) echo ${1:+.}${1}.dylib ;;
228 *) echo .so${1:+.}${1} ;;
229 esac
230 }
231
232 XVMCLIBS=(
233 "libXvMCNVIDIA_dynamic$(get_libname 1)"
234 "libXvMC$(get_libname 1)"
235 "libviaXvMC$(get_libname 1)"
236 "libviaXvMCPro$(get_libname 1)"
237 "libchromeXvMC$(get_libname 1)"
238 "libchromeXvMCPro$(get_libname 1)"
239 "libXvMCVIA$(get_libname)"
240 "libXvMCVIAPro$(get_libname)"
241 "libI810XvMC$(get_libname 1)"
242 "/usr/lib/libIntelXvMC$(get_libname)"
243 "libAMDXvBA$(get_libname 1)"
244 )
245
246 XVMCPRETTY=(
247 "nvidia"
248 "xorg-x11"
249 "via"
250 "via-pro"
251 "openchrome"
252 "openchrome-pro"
253 "unichrome"
254 "unichrome-pro"
255 "intel-i810"
256 "intel-i915/i965"
257 "ati"
258 )
259 }
260
261 get_implementation_indices() {
262 local ret n
263 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
264 [[ -e "${EROOT}/usr/lib/${XVMCLIBS[n]##*/}" ]] && ret+=($n)
265 done
266
267 echo ${ret[@]}
268 }
269
270 get_current_implementation_index() {
271 local n
272 if [[ -f "${EROOT}/etc/X11/XvMCConfig" ]]; then
273 local current=$(< "${EROOT}/etc/X11/XvMCConfig")
274 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
275 if [[ "${XVMCLIBS[n]}" = "${current}" ]]; then
276 echo "${n}"
277 return
278 fi
279 done
280 fi
281
282 echo "-1"
283 }
284
285 set_new_implementation() {
286 echo -n "Switching to ${XVMCPRETTY[$1]} XvMC implementation..."
287 touch "${EROOT}/etc/X11/XvMCConfig" 2>&1 > /dev/null
288 if [[ $? -eq 0 ]]; then
289 echo "${XVMCLIBS[$1]}" > "${EROOT}/etc/X11/XvMCConfig"
290 chmod 644 "${EROOT}/etc/X11/XvMCConfig"
291 [[ ${EROOT} == "/" ]] && chown 0:0 "${EROOT}/etc/X11/XvMCConfig"
292 echo " done"
293 else
294 echo " failed!"
295 echo "Insufficient privileges"
296 fi
297 }
298
299 ### list action
300
301 ## {{{ list stuff
302 describe_list() {
303 echo "List Available XvMC implementations"
304 }
305
306 do_list() {
307 local output n
308 init_XVMC_vars
309 local avail=( $(get_implementation_indices) )
310 local current=$(get_current_implementation_index)
311 write_list_start \
312 "Available XvMC implementations ($(highlight '*') is current):"
313
314 for n in "${avail[@]}"; do
315 output[n]=${XVMCPRETTY[n]}
316 [[ ${current} -eq ${n} ]] \
317 && output[n]=$(highlight_marker "${output[n]}")
318 done
319 write_numbered_list -m "(none found)" "${output[@]}"
320
321 return 0
322 }
323 ## }}}
324
325 ### show action
326
327 ## {{{ show stuff
328 describe_show() {
329 echo "Print the current XvMC implementation."
330 }
331
332 do_show() {
333 init_XVMC_vars
334 local current=$(get_current_implementation_index)
335 write_list_start "Current XvMC implementation:"
336
337 if [[ ${current} -ne -1 ]]; then
338 echo "${XVMCPRETTY[current]}"
339 return 0
340 else
341 echo "(none)"
342 return 2
343 fi
344 }
345 ## }}}
346
347 ### set action
348
349 ## {{{ set stuff
350 describe_set() {
351 echo "Select the XvMC implementation"
352 }
353
354 describe_set_parameters() {
355 echo "<target>"
356 }
357
358 describe_set_options() {
359 echo "<target> : XvMC implementation to activate"
360 echo "--use-old : If an implementation is already set, use that one instead"
361 }
362
363 do_set() {
364 init_XVMC_vars
365 local current=$(get_current_implementation_index)
366 local avail=( $(get_implementation_indices) )
367 local n new action
368
369 while [[ ${#@} -gt 0 ]]; do
370 local opt=${1}
371 shift
372 case ${opt} in
373 --use-old)
374 if [[ ${current} -gt -1 ]]; then
375 (( ${current} < ${#XVMCPRETTY[@]} )) && action="old-implementation"
376 fi
377 ;;
378 *)
379 [[ -z ${action} ]] && action="set-implementation"
380
381 if is_number ${opt} ; then
382 new=${avail[opt - 1]}
383 if [[ -z ${new} ]]; then
384 die -q "Unrecognized option: ${opt}"
385 fi
386 elif has ${opt} ${XVMCPRETTY[@]}; then
387 for (( n = 0; n < ${#XVMCPRETTY[@]}; ++n )); do
388 [[ "${XVMCPRETTY[n]}" = "${opt}" ]] && new=${n}
389 done
390 else
391 die -q "Unrecognized option: ${opt}"
392 fi
393 ;;
394 esac
395 done
396
397 case ${action} in
398 old-implementation)
399 set_new_implementation ${current}
400 return $?
401 ;;
402 set-implementation)
403 if [[ -n ${new} ]]; then
404 set_new_implementation ${new}
405 return $?
406 else
407 die -q "Please specify an implementation to set"
408 fi
409 ;;
410 *)
411 die -q "Invalid usage of set action."
412 esac
413 }