From a7a2f25fb092f30bb8c31ed45a60ffcf44b34932 Mon Sep 17 00:00:00 2001 From: Carl Smedstad Date: Mon, 5 Feb 2024 11:43:33 +0100 Subject: fix(version): Handle pkgbase with '.' correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For pkgbases with '.' in the name, the TOML-section must be wrapped in double quotes in order for it not to be parsed as a supersection and a subsection. This case was not properly handled by checks for if the TOML-file contains a pkgbase section, and for if the TOML-file contains superfluous sections. Address this by handling optional double quotes in the greps related to said checks. This was discovered in the AUR package ruby-cool.io and the issue can be reproduced with the following minimal PKGBUILD and .nvchecker.toml file: $ cat PKGBUILD pkgname=ruby-cool.io pkgver=1.8.0 $ cat .nvchecker.toml ["ruby-cool.io"] source = "gems" gems = "cool.io" Before the fix: $ pkgctl version check Failure x ruby-cool.io: missing pkgbase section in .nvchecker.toml: ruby-cool.io After the fix: $ pkgctl version check GEN lib/version/check.sh Out-of-date ✓ ruby-cool.io: current version 1.8.0 is latest Component: pkgctl version check --- src/lib/version/check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/version') diff --git a/src/lib/version/check.sh b/src/lib/version/check.sh index 4731545..6aa465c 100644 --- a/src/lib/version/check.sh +++ b/src/lib/version/check.sh @@ -260,13 +260,13 @@ nvchecker_check_config() { done # check if the config contains a pkgbase section - if [[ -n ${pkgbase} ]] && ! grep --max-count=1 --quiet "^\\[${pkgbase}\\]" < "${config}"; then + if [[ -n ${pkgbase} ]] && ! grep --max-count=1 --extended-regexp --quiet "^\\[\"?${pkgbase}\"?\\]" < "${config}"; then printf "missing pkgbase section in %s: %s" "${config}" "${pkgbase}" return 1 fi # check if the config contains any section other than pkgbase - if [[ -n ${pkgbase} ]] && property=$(grep --max-count=1 --perl-regexp "^\\[(?!${pkgbase}\\]).+\\]" < "${config}"); then + if [[ -n ${pkgbase} ]] && property=$(grep --max-count=1 --perl-regexp "^\\[(?!\"?${pkgbase}\"?\\]).+\\]" < "${config}"); then printf "none pkgbase section not supported in %s: %s" "${config}" "${property}" return 1 fi -- cgit v1.2.3-70-g09d2