From aca3ba055ae3a9d012e3dc8c7d159b19996c8814 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 28 Sep 2022 18:25:17 +0200 Subject: lib/common-functions: find_package_repository_to_package(): if multiple repositories are found, apply some sanity filter based on the database --- lib/common-functions | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'lib/common-functions') diff --git a/lib/common-functions b/lib/common-functions index eb61e9e..cecd27f 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -521,7 +521,40 @@ find_package_repository_to_package() { "${git_repository}" \ "${git_commit}" >&2 printf '%s\n' "${repo}" - return 1 + >&2 printf 'trying to filter based on git\n' + + if ! repo=$( + { + printf 'SELECT `upstream_repositories`.`name`' + printf ' FROM `upstream_repositories`' + mysql_join_upstream_repositories_git_repositories + printf ' WHERE `git_repositories`.`name`=from_base64("%s")' \ + "$( + printf '%s' "${git_repository}" \ + | base64 -w0 + )" + } | \ + mysql_run_query 'unimportant' | \ + grep -xF "${repo}" + ); then + >&2 printf 'find_package_repository_to_package %s %s %s: no repo found after filtering\n' \ + "${package}" \ + "${git_repository}" \ + "${git_commit}" + return 1 + fi + + if [ "$( + echo "${repo}" | \ + wc -l + )" -ne 1 ]; then + >&2 printf 'find_package_repository_to_package %s %s %s: still multiple repos found after filter:\n' \ + "${package}" \ + "${git_repository}" \ + "${git_commit}" + >&2 printf '%s\n' "${repo}" + return 1 + fi fi echo "${repo}" -- cgit v1.2.3-70-g09d2