Compare commits

...
5 Commits
Author SHA1 Message Date
arcanis d3b569bfa2 Release 2.23.6 2026-10-30 16:33:14 +02:00
arcanis 64a7e9b288 docs: take note on parametrized tests 2026-10-30 16:17:07 +02:00
arcanis 5ad8a2a7d0 fix: improve parsing of escaped symbols inside string 2026-10-30 16:16:50 +02:00
arcanis c56a319267 fix: handle array expansion without regex 2026-10-30 13:25:39 +02:00
arcanis 96558886bd fix: handle array append correctly 2026-10-29 14:27:14 +02:00
10 changed files with 265 additions and 80 deletions

No files matched your search

+1
View File
@@ -222,6 +222,7 @@ Again, the most checks can be performed by `tox` command, though some additional
* On the other hand, it is allowed to change method signatures, however, it is recommended to add new parameters as optional if possible. Deprecated API can be dropped during major release.
* Enumerations (`Enum` classes) are allowed and recommended. However, it is recommended to use `StrEnum` class if there are from/to string conversions and `IntEnum` otherwise.
* `Generator` return type is not allowed. Generator functions must return generic `Iterator` object. Documentation should be described as `Yields`, however, because of pylint checks. Unfortunately, `Iterable` return type is not available for generators also, because of specific `contextlib.contextmanager` case.
* Tests must not be parametrized. It is better to write separate test, which covers specific line of code rather than testing all over again.
### Other checks
@@ -1,4 +1,4 @@
.TH AHRIMAN "1" "2026\-10\-25" "ahriman 2.23.5" "ArcH linux ReposItory MANager"
.TH AHRIMAN "1" "2026\-10\-30" "ahriman 2.23.6" "ArcH linux ReposItory MANager"
.SH NAME
ahriman \- ArcH linux ReposItory MANager
.SH SYNOPSIS
+1 -1
View File
@@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__version__ = "2.23.5"
__version__ = "2.23.6"
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import re
import shlex
import tree_sitter_bash
@@ -26,6 +25,7 @@ from enum import StrEnum
from tree_sitter import Language, Node, Parser
from typing import IO, cast
from ahriman.core.configuration.shell_interpolator import ShellInterpolator
from ahriman.core.exceptions import PkgbuildParserError
from ahriman.models.pkgbuild_patch import PkgbuildPatch
@@ -113,7 +113,12 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
... print(patch.key, patch.value)
"""
_BRACE_EXPANSION = re.compile(r"(.*)\{([^{}]+)\}(.*)")
_ESCAPED_CHARACTERS = {
"\\$": "$",
"\\`": "`",
"\\\"": "\"",
"\\\n": "",
}
def __init__(self, stream: IO[bytes]) -> None:
"""
@@ -123,27 +128,7 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
self._content = stream.read()
@staticmethod
def _expand_array(value: str, *, expand: bool = True) -> list[str]:
"""
expand comma-separated brace expressions in a value
Args:
value(str): value that may contain a brace expression
expand(bool, optional): whether brace expansion is allowed (Default value = True)
Returns:
list[str]: expanded values if applicable
"""
match = PkgbuildParser._BRACE_EXPANSION.fullmatch(value)
# if there is no comma inside it should be treated as normal value
if match is None or not expand or "," not in match.group(2):
return [value]
prefix, values, suffix = match.groups()
return [f"{prefix}{item}{suffix}" for item in values.split(",")]
@staticmethod
def _text(node: Node) -> str:
def text(node: Node) -> str:
"""
read the original source text represented by a syntax tree node
@@ -155,6 +140,50 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
"""
return cast(bytes, node.text).decode("utf8", errors="backslashreplace")
@staticmethod
def unquote(value: str) -> str:
"""
remove shell quotes and escapes from a single value
Args:
value(str): shell value to unquote
Returns:
str: unquoted value
"""
return "".join(shlex.split(value, comments=False, posix=True))
@staticmethod
def value(node: Node) -> str:
"""
extract a string value from a syntax tree node
Args:
node(Node): syntax tree node to extract
Returns:
str: extracted string value
"""
def unescape(source: str) -> str:
for original, replacement in PkgbuildParser._ESCAPED_CHARACTERS.items():
source = source.replace(original, replacement)
return source
if node.type == PkgbuildNodeType.Concatenation:
return "".join(PkgbuildParser.value(child) for child in node.named_children)
value = PkgbuildParser.text(node)
match node.type:
case PkgbuildNodeType.String | PkgbuildNodeType.StringContent:
if node.type == PkgbuildNodeType.String:
value = PkgbuildParser.unquote(value)
# protect escaped backslashes from being interpreted a second time.
return "\\".join(unescape(part) for part in value.split("\\\\"))
case PkgbuildNodeType.Number | PkgbuildNodeType.RawString | PkgbuildNodeType.Word:
return PkgbuildParser.unquote(value)
case _:
return value
def _assignment(self, node: Node) -> PkgbuildPatch:
"""
convert an assignment node
@@ -165,10 +194,8 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
Returns:
PkgbuildPatch: parsed assignment
"""
name = cast(Node, node.child_by_field_name(PkgbuildNodeField.Name))
value = cast(Node, node.child_by_field_name(PkgbuildNodeField.Value))
key = self._text(name)
key = self.text(cast(Node, node.child_by_field_name(PkgbuildNodeField.Name)))
value = node.child_by_field_name(PkgbuildNodeField.Value)
# bash permits assignments without a value (for example ``IFS=``).
# tree-sitter represents those assignments without a value node.
if value is None:
@@ -176,34 +203,82 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
match value.type:
case PkgbuildNodeType.Array:
array_values = []
values = []
for element in filter(lambda child: child.type != PkgbuildNodeType.Comment, value.named_children):
item = self._value(element)
values = self._expand_array(item, expand=element.type == PkgbuildNodeType.Concatenation)
array_values.extend(values)
return PkgbuildPatch(key, array_values)
values.extend(self._expand_array(element))
return PkgbuildPatch(key, values)
case _:
return PkgbuildPatch(key, self._value(value))
return PkgbuildPatch(key, self.value(value))
def _read(self, node: Node) -> Iterator[PkgbuildPatch]:
def _expand_array(self, node: Node) -> list[str]:
"""
expand simple comma-separated brace groups in an array element
Args:
node(Node): array element to expand
Returns:
list[str]: expanded element values
"""
if node.type != PkgbuildNodeType.Concatenation:
return [self.value(node)]
values = [""]
children = node.named_children
while children:
match children[:3]:
case [
Node(type=PkgbuildNodeType.Word, text=b"{"),
Node(type=PkgbuildNodeType.Word) as content,
Node(type=PkgbuildNodeType.Word, text=b"}"),
] if "," in (escaped := self.text(content).replace("\\,", ShellInterpolator.DATA_LINK_ESCAPE)):
parts = [
self.unquote(part).replace(ShellInterpolator.DATA_LINK_ESCAPE, ",")
for part in escaped.split(",")
]
children = children[3:]
case _:
parts = [self.value(children.pop(0))]
values = [prefix + part for prefix in values for part in parts]
return values
def _read(self, node: Node, values: dict[str | None, PkgbuildPatch]) -> Iterator[PkgbuildPatch]:
"""
find assignments and functions in a syntax tree node
Args:
node(Node): syntax tree node to inspect
values(dict[str | None, PkgbuildPatch]): cached assignments
Yields:
PkgbuildPatch: parsed entries
"""
match node.type:
case PkgbuildNodeType.VariableAssignment if not any(child.type == PkgbuildNodeType.Append for child in node.children):
yield self._assignment(node)
case PkgbuildNodeType.VariableAssignment if any(child.type == PkgbuildNodeType.Append for child in node.children):
patch = self._assignment(node)
match values.get(patch.key), patch.value:
case PkgbuildPatch(value=str() as previous), str() as appended:
patch = PkgbuildPatch(patch.key, previous + appended)
case PkgbuildPatch(value=str() as previous), list() as appended:
patch = PkgbuildPatch(patch.key, [previous, *appended])
case PkgbuildPatch(value=list() as previous), list() as appended:
patch = PkgbuildPatch(patch.key, previous + appended)
values[patch.key] = patch
yield patch
case PkgbuildNodeType.VariableAssignment:
patch = self._assignment(node)
values[patch.key] = patch
yield patch
case PkgbuildNodeType.FunctionDefinition:
name = cast(Node, node.child_by_field_name(PkgbuildNodeField.Name))
body = cast(Node, node.child_by_field_name(PkgbuildNodeField.Body))
yield PkgbuildPatch(f"{self._text(name)}()", self._text(body))
yield PkgbuildPatch(f"{self.text(name)}()", self.text(body))
case _:
# descend into statements, but skip command arguments and values
@@ -215,31 +290,7 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
PkgbuildNodeType.String,
PkgbuildNodeType.Word,
):
yield from self._read(child)
def _value(self, node: Node) -> str:
"""
extract a string value from a syntax tree node
Args:
node(Node): syntax tree node to extract
Returns:
str: extracted string value
"""
if node.type in (PkgbuildNodeType.Concatenation, PkgbuildNodeType.String):
return "".join(self._value(child) for child in node.named_children)
value = self._text(node)
match node.type:
case PkgbuildNodeType.StringContent:
value = f'"{value}"'
case PkgbuildNodeType.Number | PkgbuildNodeType.RawString | PkgbuildNodeType.Word:
pass
case _:
return value
return "".join(shlex.split(value, comments=False, posix=True))
yield from self._read(child, values)
def parse(self) -> Iterator[PkgbuildPatch]:
"""
@@ -265,7 +316,7 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
f"syntax error at line {error.start_point.row + 1}, column {error.start_point.column + 1}"
)
yield from self._read(tree.root_node)
yield from self._read(tree.root_node, {})
def __iter__(self) -> Iterator[PkgbuildPatch]:
"""
@@ -18,9 +18,48 @@ def test_expand_array() -> None:
parser = PkgbuildParser(BytesIO(b"array=(prefix{first,second}suffix)"))
assert list(parser.parse()) == [PkgbuildPatch("array", ["prefixfirstsuffix", "prefixsecondsuffix"])]
parser = PkgbuildParser(BytesIO(br"array=(prefix{first\,second,third}suffix)"))
assert list(parser.parse()) == [PkgbuildPatch("array", ["prefixfirst,secondsuffix", "prefixthirdsuffix"])]
parser = PkgbuildParser(BytesIO(b"""array=("prefix{first,second}suffix")"""))
assert list(parser.parse()) == [PkgbuildPatch("array", ["prefix{first,second}suffix"])]
parser = PkgbuildParser(BytesIO(b"""array=(x"{a,b}" x'{a,b}' "{x,y}"{a,b})"""))
assert list(parser) == [PkgbuildPatch("array", ["x{a,b}", "x{a,b}", "{x,y}a", "{x,y}b"])]
parser = PkgbuildParser(BytesIO(b"""array=(${v:-a,b}suffix ${v:-a,b}{,.sig} $(echo '{a,b}')suffix)"""))
assert list(parser) == [PkgbuildPatch("array", [
"${v:-a,b}suffix", "${v:-a,b}", "${v:-a,b}.sig", "$(echo '{a,b}')suffix",
])]
def test_parse_append_array() -> None:
"""
must retain original array elements when appending and iterating again
"""
parser = PkgbuildParser(BytesIO(
b"source=(base.patch)\nsource+=(extra.patch)\nsource+=(last.patch)\nsource=(reset.patch)\nsource+=(extra.patch)"
))
expected = [
PkgbuildPatch("source", ["base.patch"]),
PkgbuildPatch("source", ["base.patch", "extra.patch"]),
PkgbuildPatch("source", ["base.patch", "extra.patch", "last.patch"]),
PkgbuildPatch("source", ["reset.patch"]),
PkgbuildPatch("source", ["reset.patch", "extra.patch"]),
]
assert list(parser) == expected
def test_parse_append_array_to_string() -> None:
"""
must preserve a string as the first element when appending an array
"""
parser = PkgbuildParser(BytesIO(b"source=base.patch\nsource+=(extra.patch)"))
assert list(parser) == [
PkgbuildPatch("source", "base.patch"),
PkgbuildPatch("source", ["base.patch", "extra.patch"]),
]
def test_parse_array() -> None:
"""
@@ -243,4 +282,12 @@ def test_parse(resource_path_root: Path) -> None:
_ver="$(cat CMakeLists.txt | grep -e SO_MAJOR_VERSION -e SO_MINOR_VERSION -e SO_BUILD_VERSION | cut -d '"' -f2 | head -n3)"
echo "$(echo ${_ver} | tr ' ' .).r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}"""),
PkgbuildPatch("var", "say \"hello\""),
PkgbuildPatch("var", "a\\b"),
PkgbuildPatch("var", "$name"),
PkgbuildPatch("var", "`date`"),
PkgbuildPatch("var", "firstsecond"),
PkgbuildPatch("var", "a\\qb"),
PkgbuildPatch("var", "\\$name"),
PkgbuildPatch("var", "first\nsecond"),
]
@@ -222,7 +222,7 @@ def test_parse_ahriman(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (ahriman)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_ahriman_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "ahriman",
"pkgname": "ahriman",
@@ -279,6 +279,8 @@ def test_parse_ahriman(resource_path_root: Path) -> None:
"53d37efec812afebf86281716259f9ea78a307b83897166c72777251c3eebcb587ecee375d907514781fb2a5c808cbb24ef9f3f244f12740155d0603bf213131",
"62b2eccc352d33853ef243c9cddd63663014aa97b87242f1b5bc5099a7dbd69ff3821f24ffc58e1b7f2387bd4e9e9712cc4c67f661b1724ad99cdf09b3717794",
],
"build()": None,
"package()": None,
}
@@ -287,7 +289,7 @@ def test_parse_gcc10(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (gcc10)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_gcc10_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "gcc10",
"pkgname": [
@@ -354,6 +356,12 @@ def test_parse_gcc10(resource_path_root: Path) -> None:
"_CHOST": "${CHOST:=}",
"_MAKEFLAGS": "${MAKEFLAGS:=}",
"_libdir": "usr/lib/gcc/${CHOST}/${pkgver%%+*}",
"prepare()": None,
"build()": None,
"check()": None,
"package_gcc10-libs()": None,
"package_gcc10()": None,
"package_gcc10-fortran()": None,
}
@@ -362,7 +370,7 @@ def test_parse_jellyfin_ffmpeg6_bin(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (jellyfin-ffmpeg6-bin)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_jellyfin-ffmpeg6-bin_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "jellyfin-ffmpeg6-bin",
"pkgname": "jellyfin-ffmpeg6-bin",
@@ -396,6 +404,7 @@ def test_parse_jellyfin_ffmpeg6_bin(resource_path_root: Path) -> None:
"source_aarch64": ["https://repo.jellyfin.org/releases/ffmpeg/${pkgver}-${pkgrel}/jellyfin-ffmpeg_${pkgver}-${pkgrel}_portable_linuxarm64-gpl.tar.xz"],
"sha256sums_x86_64": ["32cbe40942d26072faa1182835ccc89029883766de11778c731b529aa632ff37"],
"sha256sums_aarch64": ["22b8f2a3c92c6b1c9e6830a6631f08f3f0a7ae80739ace71ad30704a28045184"],
"package()": None,
}
@@ -404,7 +413,7 @@ def test_parse_pacman_static(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (pacman-static)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_pacman-static_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "pacman-static",
"pkgname": "pacman-static",
@@ -451,10 +460,56 @@ def test_parse_pacman_static(resource_path_root: Path) -> None:
"source": [
"git+https://gitlab.archlinux.org/pacman/pacman.git#tag=v${_git_tag}?signed",
"pacman-revertme-makepkg-remove-libdepends-and-libprovides.patch::https://gitlab.archlinux.org/pacman/pacman/-/commit/354a300cd26bb1c7e6551473596be5ecced921de.patch",
"https://github.com/nghttp2/nghttp2/releases/download/v$_nghttp2_ver/nghttp2-$_nghttp2_ver.tar.xz",
"https://github.com/c-ares/c-ares/releases/download/v${_cares_ver}/c-ares-${_cares_ver}.tar.gz",
"https://github.com/c-ares/c-ares/releases/download/v${_cares_ver}/c-ares-${_cares_ver}.tar.gz.asc",
"https://curl.haxx.se/download/curl-${_curlver}.tar.gz",
"https://curl.haxx.se/download/curl-${_curlver}.tar.gz.asc",
"https://github.com/openssl/openssl/releases/download/openssl-${_sslver}/openssl-${_sslver}.tar.gz",
"https://github.com/openssl/openssl/releases/download/openssl-${_sslver}/openssl-${_sslver}.tar.gz.asc",
"ca-dir.patch",
"openssl-3.0.7-no-atomic.patch",
"https://zlib.net/zlib-${_zlibver}.tar.gz",
"https://zlib.net/zlib-${_zlibver}.tar.gz.asc",
"git+https://github.com/tukaani-project/xz#tag=v${_xzver}",
"https://sourceware.org/pub/bzip2/bzip2-${_bzipver}.tar.gz",
"https://sourceware.org/pub/bzip2/bzip2-${_bzipver}.tar.gz.sig",
"https://github.com/facebook/zstd/releases/download/v${_zstdver}/zstd-${_zstdver}.tar.zst",
"https://github.com/facebook/zstd/releases/download/v${_zstdver}/zstd-${_zstdver}.tar.zst.sig",
"https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${_gpgerrorver}.tar.bz2",
"https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${_gpgerrorver}.tar.bz2.sig",
"https://gnupg.org/ftp/gcrypt/libassuan/libassuan-${_libassuanver}.tar.bz2",
"https://gnupg.org/ftp/gcrypt/libassuan/libassuan-${_libassuanver}.tar.bz2.sig",
"https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-${_gpgmever}.tar.bz2",
"https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-${_gpgmever}.tar.bz2.sig",
"https://github.com/libarchive/libarchive/releases/download/v${_libarchive_ver}/libarchive-${_libarchive_ver}.tar.xz",
"https://github.com/libarchive/libarchive/releases/download/v${_libarchive_ver}/libarchive-${_libarchive_ver}.tar.xz.asc",
],
"validpgpkeys": [
"6645B0A8C7005E78DB1D7864F99FFE0FEAE999BD",
"B8151B117037781095514CA7BBDFFC92306B1121",
"27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2",
"DA7D64E4C82C6294CB73A20E22E3D13B5411B7CA",
"27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2",
"8657ABB260F056B1E5190839D9C4D26D0E604491",
"7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C",
"A21FAB74B0088AA361152586B8EF1A6BA9DA2D5C",
"EFC0A467D613CB83C7ED6D30D894E2CE8B3D79F5",
"BA5473A2B0587B07FB27CF2D216094DFD0CB81EF",
"8657ABB260F056B1E5190839D9C4D26D0E604491",
"7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C",
"A21FAB74B0088AA361152586B8EF1A6BA9DA2D5C",
"EFC0A467D613CB83C7ED6D30D894E2CE8B3D79F5",
"5ED46A6721D365587791E2AA783FCD8E58BCAFBA",
"3690C240CE51B4670D30AD1C38EE757D69184620",
"EC3CFE88F6CA0788774F5C1D1AA44BE649DE760A",
"4EF4AC63455FC9F4545D9B7DEF8FE99528B52FFD",
"D8692123C4065DEA5E0F3AB5249B39D24F25E3B6",
"031EC2536E580D8EA286A9F22071B08A33BD3F06",
"6DAA6E64A76D2840571B4902528897B826403ADA",
"AC8E115BF73E2D8D47FA9908E98E9B2D19C6C8BD",
"A5A45B12AD92D964B89EEE2DEC560C81CEC2276E",
"DB2C7CF1B4C265FAEF56E3FC5848A18B8F14184B",
],
"sha512sums": [
"44e00c2bc259fe6a85de71f7fd8a43fcfd1b8fb7d920d2267bd5b347e02f1dab736b3d96e31faf7b535480398e2348f7c0b9914e51ca7e12bab2d5b8003926b4",
@@ -487,9 +542,12 @@ def test_parse_pacman_static(resource_path_root: Path) -> None:
"LDFLAGS": "$LDFLAGS -static",
"CC": "musl-gcc -fno-stack-protector",
"CXX": "musl-gcc -fno-stack-protector",
"CFLAGS": "${CFLAGS/-fstack-protector-strong/}",
"CXXFLAGS": "${CXXFLAGS/-fstack-protector-strong/}",
"CFLAGS": "${CFLAGS/-fstack-protector-strong/} -D_LARGEFILE64_SOURCE",
"CXXFLAGS": "${CXXFLAGS/-fstack-protector-strong/} -D_LARGEFILE64_SOURCE",
"PKGEXT": ".pkg.tar.xz",
"prepare()": None,
"build()": None,
"package()": None,
}
@@ -498,7 +556,7 @@ def test_parse_python_pytest_loop(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (python-pytest-loop)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_python-pytest-loop_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "python-pytest-loop",
"_pname": "${pkgbase#python-}",
@@ -526,6 +584,9 @@ def test_parse_python_pytest_loop(resource_path_root: Path) -> None:
"md5sums": [
"98365f49606d5068f92350f1d2569a5f",
],
"build()": None,
"check()": None,
"package_python-pytest-loop()": None,
}
@@ -534,7 +595,7 @@ def test_parse_tpacpi_bat_git(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (tpacpi-bat-git)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_tpacpi-bat-git_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "tpacpi-bat-git",
"pkgname": "tpacpi-bat-git",
@@ -551,6 +612,8 @@ def test_parse_tpacpi_bat_git(resource_path_root: Path) -> None:
"backup": ["etc/conf.d/tpacpi"],
"source": ["git+https://github.com/teleshoes/tpacpi-bat.git"],
"b2sums": ["SKIP"],
"pkgver()": None,
"package()": None,
}
@@ -559,7 +622,7 @@ def test_parse_ttf_google_fonts_git(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (ttf-google-fonts-git)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_ttf-google-fonts-git_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert "ttf-google-fonts-git" in pkgbuild.packages()
assert values == {
"pkgname": "ttf-google-fonts-git",
@@ -635,6 +698,9 @@ def test_parse_ttf_google_fonts_git(resource_path_root: Path) -> None:
"source": ["git+${url}.git"],
"sha512sums": ["SKIP"],
"pkgbase": "ttf-google-fonts-git",
"pkgver()": None,
"prepare()": None,
"package()": None,
}
@@ -643,7 +709,7 @@ def test_parse_vim_youcompleteme_git(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (vim-youcompleteme-git)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_vim-youcompleteme-git_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "vim-youcompleteme-git",
"_gocode": "y",
@@ -698,6 +764,10 @@ def test_parse_vim_youcompleteme_git(resource_path_root: Path) -> None:
"10a64c468d1dd2a384e0e5fd4eb2582fd9f1dfa706b6d2d2bb88fb0fbfc2718d",
"9a5bee818a4995bc52e91588059bef42728d046808206bfb93977f4e3109e50c",
],
"pkgver()": None,
"prepare()": None,
"build()": None,
"package()": None,
}
@@ -706,7 +776,7 @@ def test_parse_yay(resource_path_root: Path) -> None:
must parse real PKGBUILDs correctly (yay)
"""
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_yay_pkgbuild")
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
values = {key: None if value.is_function else value.value for key, value in pkgbuild.fields.items()}
assert values == {
"pkgbase": "yay",
"pkgname": "yay",
@@ -737,4 +807,6 @@ def test_parse_yay(resource_path_root: Path) -> None:
"makedepends": ["go>=1.21"],
"source": ["${pkgname}-${pkgver}.tar.gz::https://github.com/Jguer/yay/archive/v${pkgver}.tar.gz"],
"sha256sums": ["2fb6121a6eb4c5e6afaf22212b2ed15022500a4bc34bb3dc0f9782c1d43c3962"],
"build()": None,
"package()": None,
}
+1 -1
View File
@@ -2,7 +2,7 @@
pkgbase='ahriman'
pkgname=('ahriman' 'ahriman-core' 'ahriman-triggers' 'ahriman-web')
pkgver=2.23.5
pkgver=2.23.6
pkgrel=1
pkgdesc="ArcH linux ReposItory MANager"
arch=('any')
+4 -2
View File
@@ -65,7 +65,7 @@ digraph G {
ahriman_core_alpm_pacman [fillcolor="#9f2b04",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npacman"];
ahriman_core_alpm_pacman_database [fillcolor="#a15035",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npacman_database"];
ahriman_core_alpm_pacman_handle [fillcolor="#cc5933",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npacman_handle"];
ahriman_core_alpm_pkgbuild_parser [fillcolor="#a15035",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npkgbuild_parser"];
ahriman_core_alpm_pkgbuild_parser [fillcolor="#914830",fontcolor="#ffffff",label="ahriman\.\ncore\.\nalpm\.\npkgbuild_parser"];
ahriman_core_alpm_remote [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nalpm\.\nremote",shape="box"];
ahriman_core_alpm_remote_aur [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nalpm\.\nremote\.\naur",shape="box"];
ahriman_core_alpm_remote_official [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nalpm\.\nremote\.\nofficial",shape="box"];
@@ -567,7 +567,7 @@ digraph G {
ahriman_core_alpm_pacman_database -> ahriman_core_alpm_pacman [fillcolor="#a15035",weight="3"];
ahriman_core_alpm_pacman_handle -> ahriman_core_alpm_pacman [fillcolor="#cc5933",weight="3"];
ahriman_core_alpm_pacman_handle -> ahriman_models_package [fillcolor="#cc5933",minlen="3"];
ahriman_core_alpm_pkgbuild_parser -> ahriman_models_pkgbuild [fillcolor="#a15035",minlen="3"];
ahriman_core_alpm_pkgbuild_parser -> ahriman_models_pkgbuild [fillcolor="#914830",minlen="3"];
ahriman_core_alpm_remote -> ahriman_application_handlers_search [fillcolor="blue",minlen="3"];
ahriman_core_alpm_remote -> ahriman_core_build_tools_package_archive [fillcolor="blue",minlen="2",weight="2"];
ahriman_core_alpm_remote -> ahriman_core_repository_repository [fillcolor="blue",minlen="2",weight="2"];
@@ -667,6 +667,7 @@ digraph G {
ahriman_core_configuration -> ahriman_application_lock [fillcolor="blue",minlen="2"];
ahriman_core_configuration -> ahriman_core_alpm_pacman [fillcolor="blue",minlen="2",weight="2"];
ahriman_core_configuration -> ahriman_core_alpm_pacman_database [fillcolor="blue",minlen="2",weight="2"];
ahriman_core_configuration -> ahriman_core_alpm_pkgbuild_parser [fillcolor="blue",minlen="2",weight="2"];
ahriman_core_configuration -> ahriman_core_archive_archive_trigger [fillcolor="blue",minlen="2",weight="2"];
ahriman_core_configuration -> ahriman_core_auth_auth [fillcolor="blue",minlen="2",weight="2"];
ahriman_core_configuration -> ahriman_core_auth_mapping [fillcolor="blue",minlen="2",weight="2"];
@@ -734,6 +735,7 @@ digraph G {
ahriman_core_configuration_configuration_multi_dict -> ahriman_core_configuration_configuration [fillcolor="#b85c3d",weight="3"];
ahriman_core_configuration_schema -> ahriman_application_handlers_validate [fillcolor="#ce603b",minlen="3"];
ahriman_core_configuration_schema -> ahriman_core_triggers_trigger [fillcolor="#ce603b",minlen="2",weight="2"];
ahriman_core_configuration_shell_interpolator -> ahriman_core_alpm_pkgbuild_parser [fillcolor="blue",minlen="2",weight="2"];
ahriman_core_configuration_shell_interpolator -> ahriman_core_configuration_configuration [fillcolor="blue",weight="3"];
ahriman_core_configuration_shell_template -> ahriman_core_configuration_shell_interpolator [fillcolor="#ce603b",weight="3"];
ahriman_core_configuration_shell_template -> ahriman_models_pkgbuild_patch [fillcolor="#ce603b",minlen="3"];
+1 -1
View File
@@ -42,5 +42,5 @@
"preview": "vite preview"
},
"type": "module",
"version": "2.23.5"
"version": "2.23.6"
}
+12
View File
@@ -113,3 +113,15 @@ pkgver() {
_ver="$(cat CMakeLists.txt | grep -e SO_MAJOR_VERSION -e SO_MINOR_VERSION -e SO_BUILD_VERSION | cut -d '"' -f2 | head -n3)"
echo "$(echo ${_ver} | tr ' ' .).r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}
# escapes and newlines inside double-quoted assignments
var="say \"hello\""
var="a\\b"
var="\$name"
var="\`date\`"
var="first\
second"
var="a\qb"
var="\\\\$name"
var="first
second"