Ana Guerrero 2024-03-28 12:52:32 +00:00 committed by Git OBS Bridge
commit ccd887b51f
5 changed files with 62 additions and 7 deletions

View File

@ -43,3 +43,18 @@ function string.split(str, sep)
string.gsub(str, '[^'..sep..']+', func)
return res
end
function arg_compat()
--[[
Compat macro as workaround for older rpm not having function
arguments available as table arg(uments)
--]]
local arg_count = rpm.expand("%#")
local arg = {}
for arg_num = 1,arg_count do
arg[arg_num] = rpm.expand(("%" .. arg_num))
end
return arg
end

View File

@ -32,6 +32,12 @@ function treesitter_grammars()
local treesitter_grammar_names = ""
local treesitter_grammar_libnames = ""
local arg = arg
local suse_version = tonumber(rpm.expand("%suse_version"))
if suse_version < 1600 then
arg = arg_compat()
end
for arg_num = 1,#arg do
treesitter_grammar_libnames=treesitter_grammar_libnames .. base_libname .. "-" .. arg[arg_num] .. ".so "
end
@ -42,7 +48,6 @@ function treesitter_grammars()
print("Provides: treesitter_grammar(" .. base_name .. "-" .. arg[arg_num] .. ")\n")
end
rpm.define("treesitter_grammar_names " .. treesitter_grammar_names)
end
@ -76,6 +81,11 @@ function treesitter_build()
rpm.expand("%_treesitter_macro_init")
local basename = rpm.expand("%{_treesitter_grammar_base_libname}")
local grammar_names = rpm.expand("%treesitter_grammar_names")
local arg = arg
local suse_version = tonumber(rpm.expand("%suse_version"))
if suse_version < 1600 then
arg = arg_compat()
end
local left_over_args = arg[1]
local grammar_arg_binding = ""
@ -170,6 +180,12 @@ function treesitter_devel_install()
return
end
local arg = arg
local suse_version = tonumber(rpm.expand("%suse_version"))
if suse_version < 1600 then
arg = arg_compat()
end
if #arg > 0 then
--[[ FIXME: This maybe not be the best solution if packages can have a single grammar
but also addon files

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Mar 25 21:58:38 UTC 2024 - Björn Bidar <bjorn.bidar@thaodan.de>
- Add workaround to packaging macros for RPM being to old on current Leap
- Add workaround for Python below 3.9 on Leap
-------------------------------------------------------------------
Fri Mar 22 19:35:31 UTC 2024 - Björn Bidar <bjorn.bidar@thaodan.de>

View File

@ -7,12 +7,23 @@
# pylint: disable=invalid-name
import platform
import fileinput
import re
from typing import Optional
from pathlib import Path
if platform.sys.version_info.minor < 9:
def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text
def remove_suffix(text, suffix):
if text.endswith(suffix):
return text[:-len(suffix):]
return text
treeSitterGrammarSrcPath = "/usr/include/tree_sitter"
treeSitterGrammarSymbolToken = "treesitter_grammar_src"
grammarPaths = []
@ -57,6 +68,13 @@ def dummyRequire(requiredFile_fd: str, maxDepth: Optional[int] = 5 ) -> str:
requiredLvl2 = re.match(require_re, r_line)
#print(r_line)
if requiredLvl2 is not None:
if platform.sys.version_info.minor < 9:
requiredLvl2_grp_cleaned = \
remove_suffix(remove_prefix(requiredLvl2.group(1), "'"), "'")
requiredLvl2_grp_cleaned = \
remove_suffix(remove_prefix(requiredLvl2_grp_cleaned, "\""),
"\"")
else:
requiredLvl2_grp_cleaned = \
requiredLvl2.group(1).removeprefix("'").removesuffix("'")
requiredLvl2_grp_cleaned = \

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8158ba3e18b25a81d41e6937d120597630a57181996355154197e6988d632030
size 30391447
oid sha256:636609804ef5535c53a60e42ff1fac0a35d29aac4df98bd308fe2e7b25492b60
size 30401756