From 002d036064354d9e7b4412f703ddbb8a92b87804 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 20 Jul 2017 20:35:24 +0200 Subject: bin/common-functions: find_package_repository_to_package new --- bin/common-functions | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/bin/common-functions b/bin/common-functions index 31ce6f1..2037853 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -604,3 +604,39 @@ find_newest_of_git_revisions() { echo "${newest}" ) } + +# find_package_repository_to_package $package $git_repository +# find the package repository a package from a given git repository +# belongs to + +find_package_repository_to_package() { + + local package="$1" + local git_repository="$2" + local repo_path + local repo + + eval 'repo_path="${repo_paths__'"${git_repository}"'}"' + + repo="$( + ls "${repo_path}/${package}/repos" 2> /dev/null | \ + grep -v 'staging\|testing' | \ + grep -v -- '-i686$' | \ + sed 's|-[^-]\+$||' | \ + sort -u + )" + + if [ -z "${repo}" ]; then + return 1 + fi + + if [ "$( + echo "${repo}" | \ + wc -l + )" -ne 1 ]; then + return 1 + fi + + echo "${repo}" + +} -- cgit v1.2.3-70-g09d2