diff options
author | Marek Szuba <marecki@gentoo.org> | 2020-12-22 13:48:19 +0000 |
---|---|---|
committer | Marek Szuba <marecki@gentoo.org> | 2020-12-22 14:17:35 +0000 |
commit | 4e4affd80c96506d909397937d44ee26ad735de0 (patch) | |
tree | 0ef656584db148350496251e369ad501fdc9a799 /app-eselect/eselect-lua | |
parent | media-libs/freetype: Enable png by default (diff) | |
download | gentoo-4e4affd80c96506d909397937d44ee26ad735de0.tar.gz gentoo-4e4affd80c96506d909397937d44ee26ad735de0.tar.bz2 gentoo-4e4affd80c96506d909397937d44ee26ad735de0.zip |
app-eselect/eselect-lua: eclass compatibility + minor fixes
1. Lua implementation names are now similar to allowed values of Lua-target
ebuild variables, e.g. "lua5.4" instead of just "5.4". LuaJIT is an
exception because the binary it installs is 'luajit-${PV}' rather than
just 'luajit', that however is something that will likely have to be
addressed in dev-lang/luajit;
2. While removing old man-page symlinks, do not try to account for every
possible documentation-compression scheme. Just use a wildcard;
3. Do not create a dangling luac symlink if the chosen implementation
is LuaJIT;
4. Sync the shell globs used to create and to remove man-page symlinks.
Note that as things stand no lua.1 symlink is created for LuaJIT due
to an inconsistency in existing versions of dev-lang/luajit - the binary
they install is called 'luajit-${PV}' but the man page is simply
'luajit.1';
5. Implement the '--if-unset' option in do_set() so that Lua ebuilds can
use eselect-lua when no default implementation has been selected yet
but leave previously chosen implementation alone;
6. Remove 'update' functionality because it was broken - it would always
"upgrade" to LuaJIT if dev-lang/luajit was present. We might re-add this
functionality in the future, then again given how incompatible different
versions of Lua are perhaps we will not;
7. Fix typo in the name "resolve_target".
Signed-off-by: Marek Szuba <marecki@gentoo.org>
Diffstat (limited to 'app-eselect/eselect-lua')
-rw-r--r-- | app-eselect/eselect-lua/eselect-lua-3.ebuild (renamed from app-eselect/eselect-lua/eselect-lua-2.ebuild) | 0 | ||||
-rw-r--r-- | app-eselect/eselect-lua/files/lua.eselect-3 (renamed from app-eselect/eselect-lua/files/lua.eselect-2) | 62 |
2 files changed, 23 insertions, 39 deletions
diff --git a/app-eselect/eselect-lua/eselect-lua-2.ebuild b/app-eselect/eselect-lua/eselect-lua-3.ebuild index 3529ad194141..3529ad194141 100644 --- a/app-eselect/eselect-lua/eselect-lua-2.ebuild +++ b/app-eselect/eselect-lua/eselect-lua-3.ebuild diff --git a/app-eselect/eselect-lua/files/lua.eselect-2 b/app-eselect/eselect-lua/files/lua.eselect-3 index 02a942788b9d..b46c226f8ee2 100644 --- a/app-eselect/eselect-lua/files/lua.eselect-2 +++ b/app-eselect/eselect-lua/files/lua.eselect-3 @@ -18,7 +18,7 @@ remove_symlinks() { for f in $HEADER_FILES ; do rm -f "${EROOT}"/usr/include/${f} done - rm -f "${EROOT}"/usr/share/man/man1/{lua,luac}.1{,.gz,.bz2,.lzma} &>/dev/null + rm -f "${EROOT}"/usr/share/man/man1/lua{,c}.1{,.*} &>/dev/null } _dup() { @@ -26,9 +26,12 @@ _dup() { } set_symlinks() { - local ver=$1 - ln -s lua${ver} $(_dup "${EROOT}"/usr/bin/lua) - ln -s luac${ver} $(_dup "${EROOT}"/usr/bin/luac) + local ver=${1#lua} + local bin_prefix="${EROOT}/usr/bin" + ln -s lua${ver} $(_dup "${bin_prefix}"/lua) + if [[ -f "${bin_prefix}"/luac${ver} ]]; then + ln -s luac${ver} $(_dup "${bin_prefix}"/luac) + fi for dir in $(get_libdirs) ; do if has 'jit*' ${ver}; then type -p lua${ver} &>/dev/null || die -q "It's something wrong with your lua${ver} installation: it's binary leads to broken symlink" @@ -41,7 +44,7 @@ set_symlinks() { fi ln -s lua${ver}.pc $(_dup "${EROOT}/${dir}"/pkgconfig/lua.pc) done - for manpage in "${EROOT}"/usr/share/man/man1/lua*${ver}.1* ; do + for manpage in "${EROOT}"/usr/share/man/man1/lua{,c}${ver}.1.* ; do test -f ${manpage} && ln -s $(basename "${manpage}") $(_dup "${manpage//${ver}}") done @@ -72,14 +75,14 @@ get_libdirs() { find_targets() { local dirs - local prefix="${EROOT}/usr/bin/lua" - for f in ${prefix}{5,jit-2}.* ; do + local prefix="${EROOT}/usr/bin/" + for f in ${prefix}lua{5,jit-2}.* ; do [[ -f "${f}" ]] && dirs="${dirs} ${f##$prefix}" done echo $dirs } -resolv_target() { +resolve_target() { local targets=( $(find_targets) ) if is_number $1; then [[ $1 -le ${#targets[@]} && $1 -gt 0 ]] && echo "${targets[ $(( $1 - 1 )) ]}" @@ -89,7 +92,7 @@ resolv_target() { } get_active_version() { - readlink -e "${EROOT}"/usr/bin/lua | sed -ne "s:.*/usr/bin/lua\([\w.-]*\):\1:p" + readlink -e "${EROOT}"/usr/bin/lua | sed -ne "s:.*/usr/bin/\([\w.-]*\):\1:p" } ## Actual actions @@ -101,16 +104,23 @@ describe_set() { } describe_set_parameters() { - echo '<target>' + echo '[--if-unset] <target>' } describe_set_options() { - echo 'target: Target name or number (from "list" action)' + echo '--if-unset: Do not replace currently selected implementation' + echo 'target: Target name or number (from "list" action)' } - do_set() { - local target=$(resolv_target $1) + if [ "${1}" == "--if-unset" ]; then + if [[ -n "$(get_active_version)" ]]; then + return + fi + shift + fi + + local target=$(resolve_target $1) if [[ -z "${target}" ]]; then die -q "You need to specify a version" fi @@ -144,29 +154,3 @@ describe_show() { do_show() { get_active_version } - -## update action - -describe_update() { - echo 'Automatically update the lua version' -} - -describe_update_options() { - echo 'ifunset : Do not override existing implementation' -} - -do_update() { - [[ -n ${1} && ! ( ${1} == ifunset || ${1} == '--if-unset' ) ]] && \ - die -q 'Usage error' - - [[ ( ${1} == ifunset || ${1} == '--if-unset' ) && -n $(get_active_version) ]] && \ - return - - remove_symlinks - - local targets=( $(find_targets) ) - if [[ -n ${#targets[@]} ]] ; then - local target=${targets[${#targets[@]} - 1]} - set_symlinks $target || echo 'Nothing to update' - fi -} |