commit:     dd75a9dac59efef496f2fafac20ebe42f2c4fcd0
Author:     Artemis Everfree <artemis <AT> artemis <DOT> sh>
AuthorDate: Thu Nov 14 02:35:51 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Nov 14 03:22:34 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dd75a9da

dev-lang/luajit: Use luajit_relver in bin symlink

Previously we were generating this symlink:

    /usr/bin/luajit -> /usr/bin/luajit-${PV}

This failed for 2.1.9999999999, as the binary was instead at
/usr/bin/luajit-2.1.${relver}, for the corresponding relver
of the commit.

We now read `src/luajit_relver.txt` generated by luajit's
build process, which always contains the correct relver
suffix for both snapshot and live builds.

The 9999999999 support is also now agnostic to which release
channel is being built, so a theoretical 2.2.9999999999
could be supported by copying the 2.1.9999999999 ebuild
without modification.

Closes: https://bugs.gentoo.org/943404
Signed-off-by: Artemis Everfree <artemis <AT> artemis.sh>
Closes: https://github.com/gentoo/gentoo/pull/39312
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/luajit/luajit-2.1.1727870382.ebuild | 30 +++++++++++++++++++++-------
 dev-lang/luajit/luajit-2.1.9999999999.ebuild | 30 +++++++++++++++++++++-------
 2 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/dev-lang/luajit/luajit-2.1.1727870382.ebuild 
b/dev-lang/luajit/luajit-2.1.1727870382.ebuild
index 1a9014c337c4..ba62499c0453 100644
--- a/dev-lang/luajit/luajit-2.1.1727870382.ebuild
+++ b/dev-lang/luajit/luajit-2.1.1727870382.ebuild
@@ -14,19 +14,20 @@ EAPI=8
 
 inherit toolchain-funcs
 
+# Split release channel (such as "2.1") from relver (such as "1727870382")
+VER_CHANNEL=${PV%.*}
+VER_RELVER=${PV##*.}
+
 DESCRIPTION="Just-In-Time Compiler for the Lua programming language"
 HOMEPAGE="https://luajit.org/";
 
-if [[ ${PV} == 2.1.9999999999 ]]; then
-       # This is the 2.1 rolling release live build. When a 2.2 or 3.x branch 
comes
-       # out, create a new ebuild for it.
-       #
-       # Upstream recommends pulling rolling releases from the v2.1 branch.
+if [[ ${VER_RELVER} == 9999999999 ]]; then
+       # Upstream recommends pulling rolling releases from versioned branches.
        # > The old git master branch is phased out and stays pinned to the v2.0
        # > branch. Please follow the versioned branches instead.
        #
        # See http://luajit.org/status.html for additional information.
-       EGIT_BRANCH="v2.1"
+       EGIT_BRANCH="v${VER_CHANNEL}"
        EGIT_REPO_URI="https://luajit.org/git/luajit.git";
        inherit git-r3
 else
@@ -73,7 +74,22 @@ src_compile() {
 
 src_install() {
        _emake install
-       dosym luajit-"${PV}" /usr/bin/luajit
+
+       # For tarballs downloaded from github, the relver is provided in
+       # ${S}/.relver, a file populated when generating the tarball as 
directed by
+       # .gitattributes. That file will contain the same relver as the relver
+       # in our version number.
+       #
+       # For the live build, this is not populated, but luajit's build process
+       # inspects the git repository directly with this command:
+       #
+       #     git show -s --format=%ct
+       #
+       # In both cases, luajit puts the relver in src/luajit_relver.txt during
+       # the build. We read this file to ensure we're using the same source of
+       # truth as luajit's own build does when generating the binary's 
filename.
+       local relver="$(cat "${S}/src/luajit_relver.txt" || die 'error 
retrieving relver')"
+       dosym luajit-"${VER_CHANNEL}.${relver}" /usr/bin/luajit
 
        HTML_DOCS="doc/." einstalldocs
 }

diff --git a/dev-lang/luajit/luajit-2.1.9999999999.ebuild 
b/dev-lang/luajit/luajit-2.1.9999999999.ebuild
index f4cd0a39d8e1..f8f7cfba19d2 100644
--- a/dev-lang/luajit/luajit-2.1.9999999999.ebuild
+++ b/dev-lang/luajit/luajit-2.1.9999999999.ebuild
@@ -14,19 +14,20 @@ EAPI=8
 
 inherit toolchain-funcs
 
+# Split release channel (such as "2.1") from relver (such as "1727870382")
+VER_CHANNEL=${PV%.*}
+VER_RELVER=${PV##*.}
+
 DESCRIPTION="Just-In-Time Compiler for the Lua programming language"
 HOMEPAGE="https://luajit.org/";
 
-if [[ ${PV} == 2.1.9999999999 ]]; then
-       # This is the 2.1 rolling release live build. When a 2.2 or 3.x branch 
comes
-       # out, create a new ebuild for it.
-       #
-       # Upstream recommends pulling rolling releases from the v2.1 branch.
+if [[ ${VER_RELVER} == 9999999999 ]]; then
+       # Upstream recommends pulling rolling releases from versioned branches.
        # > The old git master branch is phased out and stays pinned to the v2.0
        # > branch. Please follow the versioned branches instead.
        #
        # See http://luajit.org/status.html for additional information.
-       EGIT_BRANCH="v2.1"
+       EGIT_BRANCH="v${VER_CHANNEL}"
        EGIT_REPO_URI="https://luajit.org/git/luajit.git";
        inherit git-r3
 else
@@ -73,7 +74,22 @@ src_compile() {
 
 src_install() {
        _emake install
-       dosym luajit-"${PV}" /usr/bin/luajit
+
+       # For tarballs downloaded from github, the relver is provided in
+       # ${S}/.relver, a file populated when generating the tarball as 
directed by
+       # .gitattributes. That file will contain the same relver as the relver
+       # in our version number.
+       #
+       # For the live build, this is not populated, but luajit's build process
+       # inspects the git repository directly with this command:
+       #
+       #     git show -s --format=%ct
+       #
+       # In both cases, luajit puts the relver in src/luajit_relver.txt during
+       # the build. We read this file to ensure we're using the same source of
+       # truth as luajit's own build does when generating the binary's 
filename.
+       local relver="$(cat "${S}/src/luajit_relver.txt" || die 'error 
retrieving relver')"
+       dosym luajit-"${VER_CHANNEL}.${relver}" /usr/bin/luajit
 
        HTML_DOCS="doc/." einstalldocs
 }

Reply via email to