Gentoo Archives: gentoo-commits

From: Marek Szuba <marecki@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-lua/, app-eselect/eselect-lua/files/
Date: Tue, 22 Dec 2020 14:17:50
Message-Id: 1608646655.4e4affd80c96506d909397937d44ee26ad735de0.marecki@gentoo
1 commit: 4e4affd80c96506d909397937d44ee26ad735de0
2 Author: Marek Szuba <marecki <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 22 13:48:19 2020 +0000
4 Commit: Marek Szuba <marecki <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 22 14:17:35 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4e4affd8
7
8 app-eselect/eselect-lua: eclass compatibility + minor fixes
9
10 1. Lua implementation names are now similar to allowed values of Lua-target
11 ebuild variables, e.g. "lua5.4" instead of just "5.4". LuaJIT is an
12 exception because the binary it installs is 'luajit-${PV}' rather than
13 just 'luajit', that however is something that will likely have to be
14 addressed in dev-lang/luajit;
15 2. While removing old man-page symlinks, do not try to account for every
16 possible documentation-compression scheme. Just use a wildcard;
17 3. Do not create a dangling luac symlink if the chosen implementation
18 is LuaJIT;
19 4. Sync the shell globs used to create and to remove man-page symlinks.
20 Note that as things stand no lua.1 symlink is created for LuaJIT due
21 to an inconsistency in existing versions of dev-lang/luajit - the binary
22 they install is called 'luajit-${PV}' but the man page is simply
23 'luajit.1';
24 5. Implement the '--if-unset' option in do_set() so that Lua ebuilds can
25 use eselect-lua when no default implementation has been selected yet
26 but leave previously chosen implementation alone;
27 6. Remove 'update' functionality because it was broken - it would always
28 "upgrade" to LuaJIT if dev-lang/luajit was present. We might re-add this
29 functionality in the future, then again given how incompatible different
30 versions of Lua are perhaps we will not;
31 7. Fix typo in the name "resolve_target".
32
33 Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>
34
35 .../{eselect-lua-2.ebuild => eselect-lua-3.ebuild} | 0
36 .../files/{lua.eselect-2 => lua.eselect-3} | 62 ++++++++--------------
37 2 files changed, 23 insertions(+), 39 deletions(-)
38
39 diff --git a/app-eselect/eselect-lua/eselect-lua-2.ebuild b/app-eselect/eselect-lua/eselect-lua-3.ebuild
40 similarity index 100%
41 rename from app-eselect/eselect-lua/eselect-lua-2.ebuild
42 rename to app-eselect/eselect-lua/eselect-lua-3.ebuild
43
44 diff --git a/app-eselect/eselect-lua/files/lua.eselect-2 b/app-eselect/eselect-lua/files/lua.eselect-3
45 similarity index 73%
46 rename from app-eselect/eselect-lua/files/lua.eselect-2
47 rename to app-eselect/eselect-lua/files/lua.eselect-3
48 index 02a942788b9..b46c226f8ee 100644
49 --- a/app-eselect/eselect-lua/files/lua.eselect-2
50 +++ b/app-eselect/eselect-lua/files/lua.eselect-3
51 @@ -18,7 +18,7 @@ remove_symlinks() {
52 for f in $HEADER_FILES ; do
53 rm -f "${EROOT}"/usr/include/${f}
54 done
55 - rm -f "${EROOT}"/usr/share/man/man1/{lua,luac}.1{,.gz,.bz2,.lzma} &>/dev/null
56 + rm -f "${EROOT}"/usr/share/man/man1/lua{,c}.1{,.*} &>/dev/null
57 }
58
59 _dup() {
60 @@ -26,9 +26,12 @@ _dup() {
61 }
62
63 set_symlinks() {
64 - local ver=$1
65 - ln -s lua${ver} $(_dup "${EROOT}"/usr/bin/lua)
66 - ln -s luac${ver} $(_dup "${EROOT}"/usr/bin/luac)
67 + local ver=${1#lua}
68 + local bin_prefix="${EROOT}/usr/bin"
69 + ln -s lua${ver} $(_dup "${bin_prefix}"/lua)
70 + if [[ -f "${bin_prefix}"/luac${ver} ]]; then
71 + ln -s luac${ver} $(_dup "${bin_prefix}"/luac)
72 + fi
73 for dir in $(get_libdirs) ; do
74 if has 'jit*' ${ver}; then
75 type -p lua${ver} &>/dev/null || die -q "It's something wrong with your lua${ver} installation: it's binary leads to broken symlink"
76 @@ -41,7 +44,7 @@ set_symlinks() {
77 fi
78 ln -s lua${ver}.pc $(_dup "${EROOT}/${dir}"/pkgconfig/lua.pc)
79 done
80 - for manpage in "${EROOT}"/usr/share/man/man1/lua*${ver}.1* ; do
81 + for manpage in "${EROOT}"/usr/share/man/man1/lua{,c}${ver}.1.* ; do
82 test -f ${manpage} &&
83 ln -s $(basename "${manpage}") $(_dup "${manpage//${ver}}")
84 done
85 @@ -72,14 +75,14 @@ get_libdirs() {
86
87 find_targets() {
88 local dirs
89 - local prefix="${EROOT}/usr/bin/lua"
90 - for f in ${prefix}{5,jit-2}.* ; do
91 + local prefix="${EROOT}/usr/bin/"
92 + for f in ${prefix}lua{5,jit-2}.* ; do
93 [[ -f "${f}" ]] && dirs="${dirs} ${f##$prefix}"
94 done
95 echo $dirs
96 }
97
98 -resolv_target() {
99 +resolve_target() {
100 local targets=( $(find_targets) )
101 if is_number $1; then
102 [[ $1 -le ${#targets[@]} && $1 -gt 0 ]] && echo "${targets[ $(( $1 - 1 )) ]}"
103 @@ -89,7 +92,7 @@ resolv_target() {
104 }
105
106 get_active_version() {
107 - readlink -e "${EROOT}"/usr/bin/lua | sed -ne "s:.*/usr/bin/lua\([\w.-]*\):\1:p"
108 + readlink -e "${EROOT}"/usr/bin/lua | sed -ne "s:.*/usr/bin/\([\w.-]*\):\1:p"
109 }
110
111 ## Actual actions
112 @@ -101,16 +104,23 @@ describe_set() {
113 }
114
115 describe_set_parameters() {
116 - echo '<target>'
117 + echo '[--if-unset] <target>'
118 }
119
120 describe_set_options() {
121 - echo 'target: Target name or number (from "list" action)'
122 + echo '--if-unset: Do not replace currently selected implementation'
123 + echo 'target: Target name or number (from "list" action)'
124 }
125
126 -
127 do_set() {
128 - local target=$(resolv_target $1)
129 + if [ "${1}" == "--if-unset" ]; then
130 + if [[ -n "$(get_active_version)" ]]; then
131 + return
132 + fi
133 + shift
134 + fi
135 +
136 + local target=$(resolve_target $1)
137 if [[ -z "${target}" ]]; then
138 die -q "You need to specify a version"
139 fi
140 @@ -144,29 +154,3 @@ describe_show() {
141 do_show() {
142 get_active_version
143 }
144 -
145 -## update action
146 -
147 -describe_update() {
148 - echo 'Automatically update the lua version'
149 -}
150 -
151 -describe_update_options() {
152 - echo 'ifunset : Do not override existing implementation'
153 -}
154 -
155 -do_update() {
156 - [[ -n ${1} && ! ( ${1} == ifunset || ${1} == '--if-unset' ) ]] && \
157 - die -q 'Usage error'
158 -
159 - [[ ( ${1} == ifunset || ${1} == '--if-unset' ) && -n $(get_active_version) ]] && \
160 - return
161 -
162 - remove_symlinks
163 -
164 - local targets=( $(find_targets) )
165 - if [[ -n ${#targets[@]} ]] ; then
166 - local target=${targets[${#targets[@]} - 1]}
167 - set_symlinks $target || echo 'Nothing to update'
168 - fi
169 -}