1 |
ulm 15/03/31 16:50:33 |
2 |
|
3 |
Added: lua.eselect-1 |
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-lua/files/lua.eselect-1 |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-lua/files/lua.eselect-1?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-lua/files/lua.eselect-1?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: lua.eselect-1 |
16 |
=================================================================== |
17 |
# -*-eselect-*- vim: ft=eselect |
18 |
# Copyright 2014-2015 Gentoo Foundation |
19 |
# Distributed under the terms of the GNU General Public License v2 |
20 |
|
21 |
inherit config multilib |
22 |
|
23 |
DESCRIPTION="Manage lua symlinks" |
24 |
MAINTAINER="mabi@g.o" |
25 |
|
26 |
HEADER_FILES="lauxlib.h luaconf.h lua.h lua.hpp lualib.h" |
27 |
|
28 |
remove_symlinks() { |
29 |
rm -f "${EROOT}"/usr/bin/{lua,luac} &>/dev/null |
30 |
for dir in $(get_libdirs) ; do |
31 |
rm -f "${EROOT}"${dir}/liblua.so &>/dev/null && \ |
32 |
rm -f "${EROOT}"${dir}/pkgconfig/lua.pc &>/dev/null |
33 |
done |
34 |
for f in $HEADER_FILES ; do |
35 |
rm -f "${EROOT}"/usr/include/$f |
36 |
done |
37 |
rm -f "${EROOT}"/usr/share/man/man1/{lua,luac}.1{,.gz,.bz2,.lzma} &>/dev/null |
38 |
} |
39 |
|
40 |
set_symlinks() { |
41 |
local ver=$1 |
42 |
ln -s "${EROOT}"/usr/bin/lua{$ver,} |
43 |
ln -s "${EROOT}"/usr/bin/luac{$ver,} |
44 |
for dir in $(get_libdirs) ; do |
45 |
ln -s "${dir}"/liblua{$ver,}.so |
46 |
ln -s "${dir}"/pkgconfig/lua{$ver,}.pc |
47 |
done |
48 |
for orig in "${EROOT}"/usr/share/man/man1/lua*$ver.1* ; do |
49 |
ln -s "${orig}" "${orig//$ver}" |
50 |
done |
51 |
for f in $HEADER_FILES ; do |
52 |
ln -s "${EROOT}"/usr/include/lua$ver/$f "${EROOT}"/usr/include |
53 |
done |
54 |
} |
55 |
|
56 |
get_libdirs() { |
57 |
local dir libdirs |
58 |
for dir in $(list_libdirs); do |
59 |
[[ -L ${EROOT}/usr/${dir} ]] && continue |
60 |
ls "${EROOT}"/usr/${dir}/liblua*.* > /dev/null 2>&1 || continue |
61 |
|
62 |
libdirs+=' '/usr/${dir} |
63 |
done |
64 |
echo ${libdirs:-/usr/lib} |
65 |
} |
66 |
|
67 |
find_targets() { |
68 |
local dirs |
69 |
local prefix="${EROOT}/usr/bin/lua" |
70 |
for f in ${prefix}5* ; do |
71 |
dirs="${dirs} ${f##$prefix}" |
72 |
done |
73 |
echo $dirs |
74 |
} |
75 |
|
76 |
resolv_target() { |
77 |
local targets=( $(find_targets) ) |
78 |
if is_number $1; then |
79 |
[[ $1 -le ${#targets[@]} && $1 -gt 0 ]] && echo "${targets[ $(( $1 - 1 )) ]}" |
80 |
elif has $1 ${targets[@]}; then |
81 |
echo $1 |
82 |
fi |
83 |
} |
84 |
|
85 |
get_active_version() { |
86 |
readlink -e "${EROOT}"/usr/bin/lua | sed -ne "s:.*/usr/bin/lua\([\d.-]*\):\1:p" |
87 |
} |
88 |
|
89 |
## Actual actions |
90 |
|
91 |
## set action |
92 |
|
93 |
describe_set() { |
94 |
echo "Sets the current version of lua" |
95 |
} |
96 |
|
97 |
describe_set_parameters() { |
98 |
echo '<target>' |
99 |
} |
100 |
|
101 |
describe_set_options() { |
102 |
echo 'target: Target name or number (from "list" action)' |
103 |
} |
104 |
|
105 |
|
106 |
do_set() { |
107 |
local target=$(resolv_target $1) |
108 |
if [[ -z "${target}" ]]; then |
109 |
die -q "You need to specify a version" |
110 |
fi |
111 |
remove_symlinks |
112 |
set_symlinks $target |
113 |
} |
114 |
|
115 |
## List action |
116 |
|
117 |
describe_list() { |
118 |
echo 'Lists available lua versions' |
119 |
} |
120 |
|
121 |
do_list() { |
122 |
local targets |
123 |
local a |
124 |
targets=( $(find_targets) ) |
125 |
a=$(get_active_version) |
126 |
for (( i = 0; i < ${#targets[@]}; i++ )) ; do |
127 |
[[ $a == ${targets[i]} ]] && targets[i]=$(highlight_marker "${targets[i]}") |
128 |
done |
129 |
write_numbered_list -m '(none found)' "${targets[@]}" |
130 |
} |
131 |
|
132 |
## Show action |
133 |
|
134 |
describe_show() { |
135 |
echo 'Show the active lua version' |
136 |
} |
137 |
|
138 |
do_show() { |
139 |
get_active_version |
140 |
} |
141 |
|
142 |
## update action |
143 |
|
144 |
describe_update() { |
145 |
echo 'Automatically update the lua version' |
146 |
} |
147 |
|
148 |
describe_update_options() { |
149 |
echo 'ifunset : Do not override existing implementation' |
150 |
} |
151 |
|
152 |
do_update() { |
153 |
[[ -n ${1} && ! ( ${1} == ifunset || ${1} == '--if-unset' ) ]] && \ |
154 |
die -q 'Usage error' |
155 |
|
156 |
[[ ( ${1} == ifunset || ${1} == '--if-unset' ) && -n $(get_active_version) ]] && \ |
157 |
return |
158 |
|
159 |
remove_symlinks |
160 |
|
161 |
local targets=( $(find_targets) ) |
162 |
if [[ -n ${#targets[@]} ]] ; then |
163 |
local target=${targets[${#targets[@]} - 1]} |
164 |
set_symlinks $target || echo 'Nothing to update' |
165 |
fi |
166 |
} |