From c310a56816bf44439b1ecc79d8e3b2cd099102a0 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 31 Jan 2018 10:40:35 +0100 Subject: bin/mysql-functions: mysql_add_package_source should fill uses_upstream and uses_modification, too --- bin/mysql-functions | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'bin/mysql-functions') diff --git a/bin/mysql-functions b/bin/mysql-functions index 44ef851..ac39141 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -27,7 +27,25 @@ base64_encode_each() { # shellcheck disable=SC2086 mysql_add_package_source() { local names='pkgbase git_revision mod_git_revision upstream_package_repository' - local values; + local values + local uses_upstream + local uses_modification + + if git -C "${repo_paths__archlinux32}" archive "$3" -- "$4/$1" >/dev/null 2>&1; then + uses_modification=1 + else + uses_modification=0 + fi + uses_upstream=0 + for values in ${repo_names}; do + if eval 'git -C "${repo_paths__'"${values}"'}" archive "$2" -- "$1/repos/$4-*/PKGBUILD" 2>/dev/null' | \ + tar -t 2>/dev/null | \ + sed 's,-x86_64/,-any/,' | \ + grep -qFx "$1/repos/$4-any/PKGBUILD"; then + uses_upstream=1 + fi + done + for _ in ${names}; do values="${values}$( printf '%s' "$1" | \ @@ -41,14 +59,15 @@ mysql_add_package_source() { printf 'INSERT IGNORE INTO package_sources' printf ' (' printf '`%s`, ' ${names} + printf '`uses_upstream`,`uses_modification`' printf ') SELECT' printf ' from_base64("%s"), ' ${values% *} - printf ' `upstream_repositories`.`id`' + printf ' `upstream_repositories`.`id`,%s,%s' \ + ${uses_upstream} ${uses_modification} printf ' FROM `upstream_repositories`' printf ' WHERE `upstream_repositories`.`name` = from_base64("%s");' \ "${values##* }" } | \ - sed 's|, )|)|g' | \ ${mysql_command} } -- cgit v1.2.3-70-g09d2