Skip to content

Commit

Permalink
dev-lua/lpeg: add 1.1.0
Browse files Browse the repository at this point in the history
The original source code location gives certificate validation errors
when downloading with `wget`. Therefore, I switched to the luarocks
repository.

Closes: https://bugs.gentoo.org/936599
Signed-off-by: Jonas Toth <[email protected]>
Closes: gentoo#38282
Signed-off-by: Arthur Zamarin <[email protected]>
  • Loading branch information
JonasToth authored and arthurzam committed Aug 30, 2024
1 parent 8815c67 commit 95424d0
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-lua/lpeg/Manifest
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DIST lpeg-1.0.2.tar.gz 71840 BLAKE2B e0d8fb4e9d17c9018f0b206cd3f7c9c0e21398c119600b5b0705c8df19e0956347bea795c7c3ded8e62e0c09802dd8eab931a5e3769fcacf44c35aa2b17fa8d6 SHA512 110527ddf9f8e5e8a80ef0ae8847c8ba8cd2597dba3bfe2865cba9af60daafbb885f21e74231952f5ab793d021e050b482066a821c6954d52090a5eae77e9814
DIST lpeg-1.1.0.zip 78933 BLAKE2B 90895d74088d59529229825dd0058f69d0cb035d0b5ef9be49d9643c02e7b37ffcf358daa6b7129ff8df2247946dd12627d2ed1be23f61c51112303b702842b1 SHA512 5be6d3d9608881d044185e4e9cb5a7577d94b82276f4273f5dda7e2da93e13b926eaced9fc577dd83a4af231224c85a0336ddb920d94fbb334f8f55f7f21f8b4
31 changes: 31 additions & 0 deletions dev-lua/lpeg/files/lpeg-1.1.0-makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Respect user CFLAGS and LDFLAGS.

--- lpeg-1.1.0/makefile
+++ lpeg-1.1.0/makefile
@@ -1,7 +1,7 @@
LIBNAME = lpeg
LUADIR = ../lua/

-COPT = -O2 -DNDEBUG
+COPT = -DNDEBUG
# COPT = -O0 -DLPEG_DEBUG -g

CWARNS = -Wall -Wextra -pedantic \
@@ -22,7 +22,7 @@
# -Wunreachable-code \


-CFLAGS = $(CWARNS) $(COPT) -std=c99 -I$(LUADIR) -fPIC
+CFLAGS += $(CWARNS) $(COPT) -std=c99 -I$(LUADIR) -fPIC
CC = gcc

FILES = lpvm.o lpcap.o lptree.o lpcode.o lpprint.o
@@ -36,7 +36,7 @@
$(MAKE) lpeg.so "DLLFLAGS = -bundle -undefined dynamic_lookup"

lpeg.so: $(FILES)
- env $(CC) $(DLLFLAGS) $(FILES) -o lpeg.so
+ env $(CC) $(DLLFLAGS) $(LDFLAGS) $(FILES) -o lpeg.so

$(FILES): makefile

100 changes: 100 additions & 0 deletions dev-lua/lpeg/lpeg-1.1.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

LUA_COMPAT=( lua5-{1..4} luajit )

inherit lua flag-o-matic toolchain-funcs

DESCRIPTION="Parsing Expression Grammars for Lua"
HOMEPAGE="https://www.inf.puc-rio.br/~roberto/lpeg/"
SRC_URI="https://luarocks.org/manifests/gvvaughan/${P}-1.src.rock -> ${P}.zip"

LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 arm arm64 ~hppa ~mips ppc ppc64 ~riscv sparc x86 ~x64-macos"
IUSE="test debug doc"
REQUIRED_USE="${LUA_REQUIRED_USE}"
RESTRICT="!test? ( test )"

RDEPEND="${LUA_DEPS}"
DEPEND="${RDEPEND}"
BDEPEND="
virtual/pkgconfig
app-arch/unzip
test? ( ${RDEPEND} )
"

DOCS=( HISTORY )
HTML_DOCS=( lpeg.html re.html )
PATCHES=(
"${FILESDIR}"/${PN}-1.1.0-makefile.patch
)

src_unpack() {
unpack "${P}.zip" || die
unpack "${WORKDIR}/${P}.tar.gz" || die
}

lua_src_prepare() {
if ! test -d "${S}.${ELUA}/" ; then
cp -ral "${S}/" "${S}.${ELUA}/" || die
fi
}

src_prepare() {
default
use debug && append-cflags -DLPEG_DEBUG

if [[ ${CHOST} == *-darwin* ]] ; then
append-ldflags "-undefined dynamic_lookup"
fi

lua_foreach_impl lua_src_prepare
}

lua_src_compile() {
cd "${S}.${ELUA}/" || die
emake CC="$(tc-getCC)" \
LUADIR="${EPREFIX}/$(lua_get_include_dir)"
}

src_compile() {
lua_foreach_impl lua_src_compile
}

lua_src_test() {
cd "${S}.${ELUA}/" || die
${ELUA} test.lua || die
}

src_test() {
lua_foreach_impl lua_src_test
}

lua_src_install() {
cd "${S}.${ELUA}/" || die
local instdir
instdir="$(lua_get_cmod_dir)"
exeinto "${instdir#${EPREFIX}}"
doexe lpeg.so
instdir="$(lua_get_lmod_dir)"
insinto "${instdir#${EPREFIX}}"
doins re.lua

if [[ ${CHOST} == *-darwin* ]] ; then
local luav=$(lua_get_version)
# we only want the major version (e.g. 5.1)
local luamv=${luav:0:3}
local file="lua/${luamv}/lpeg.so"
install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${file}" \
"${ED}/usr/$(get_libdir)/${file}" || die "Failed to adjust install_name"
fi
}

src_install() {
lua_foreach_impl lua_src_install
cd "${S}" || die
use doc && einstalldocs
}

0 comments on commit 95424d0

Please sign in to comment.