index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-01-30 14:56:11 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-01-30 14:56:11 +0100 |
commit | 70074e1bdf42534b3a1cf7c23b714104e59d9ae5 (patch) | |
tree | 47047f9110272ec0e6609113b234c1b642c58b99 | |
parent | d5cca713716f5ea3a8ee843ebd9f128878045465 (diff) |
-rwxr-xr-x | bin/get-assignment | 52 | ||||
-rwxr-xr-x | bin/mysql-functions | 45 |
diff --git a/bin/get-assignment b/bin/get-assignment index 0e37e14..ec8dad2 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -115,17 +115,10 @@ trap clean_up EXIT currently_building=$( # shellcheck disable=SC2016 { - printf 'SELECT' - printf ' `package_sources`.`%s`,' \ - 'pkgbase' \ - 'git_revision' \ - 'mod_git_revision' - printf '`upstream_repositories`.`name`' - printf ' FROM `build_slaves`' - printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ - 'build_assignments' 'build_assignments' 'build_slaves' 'currently_building' \ - 'package_sources' 'package_sources' 'build_assignments' 'package_source' \ - 'upstream_repositories' 'upstream_repositories' 'package_sources' 'upstream_package_repository' + printf 'SELECT ' + mysql_query_select_pkgbase_and_revision + printf ' JOIN `build_slaves`' + printf ' ON `build_slaves`.`currently_building`=`build_assignments`.`id`' printf ' WHERE `build_slaves`.`name`=from_base64("%s")' \ "$(printf '%s' "${slave}" | base64 -w0)" printf ' LIMIT 1;\n' @@ -145,8 +138,8 @@ fi next_building=$( # shellcheck disable=SC2016 { - printf 'SELECT' - printf ' `package_sources`.`pkgbase`=from_base64("%s") AS `requested`,' \ + printf 'SELECT ' + printf '`package_sources`.`pkgbase`=from_base64("%s") AS `requested`,' \ "$( printf '%s' "$1" | \ base64 -w0 @@ -156,16 +149,9 @@ next_building=$( printf ' FROM `failed_builds`' printf ' WHERE `failed_builds`.`build_assignment`=`build_assignments`.`id`' printf ') AS `trials`,' - printf '`package_sources`.`%s`,' \ - 'pkgbase' \ - 'git_revision' \ - 'mod_git_revision' - printf '`upstream_repositories`.`name`' - printf ' FROM `binary_packages`' + mysql_query_select_pkgbase_and_revision printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ - 'build_assignments' 'build_assignments' 'binary_packages' 'build_assignment' \ - 'package_sources' 'package_sources' 'build_assignments' 'package_source' \ - 'upstream_repositories' 'upstream_repositories' 'package_sources' 'upstream_package_repository' \ + 'binary_packages' 'build_assignments' 'binary_packages' 'build_assignment' \ 'repositories' 'repositories' 'binary_packages' 'repository' printf ' WHERE `repositories`.`name`="build-list"' printf ' AND NOT EXISTS (' @@ -181,25 +167,9 @@ next_building=$( base64 -w0 )" printf ') AND (' - printf 'EXISTS( ' - printf 'SELECT * FROM `build_dependency_loops`' - printf ' WHERE `build_dependency_loops`.`build_assignment`=`build_assignments`.`id`' -# TODO: ignore loops which contain a build_assignment currently being handed out (?) - printf ') OR' - printf ' NOT EXISTS (' - printf 'SELECT * FROM `binary_packages` as `to_dos`' - printf ' JOIN `%s` ON `%s`.`%s`=`%s`.`%s`' \ - 'repositories` AS `to_do_repos' 'to_do_repos' 'id' 'to_dos' 'repository' \ - 'dependencies' 'to_dos' 'id' 'dependencies' 'dependent' \ - 'install_target_providers' 'dependencies' 'depending_on' 'install_target_providers' 'install_target' \ - 'binary_packages` AS `bin_deps' 'bin_deps' 'id' 'install_target_providers' 'package' \ - 'repositories` AS `dep_repos' 'dep_repos' 'id' 'bin_deps' 'repository' - printf ' WHERE' - printf ' `%s`.`name`="build-list" AND' \ - 'dep_repos' 'to_do_repos' - printf ' `bin_deps`.`build_assignment`!=`to_dos`.`build_assignment` AND' - printf ' `to_dos`.`build_assignment`=`build_assignments`.`id`' - printf ')' + mysql_query_is_part_of_loop '`build_assignments`.`id`' + printf ' OR NOT ' + mysql_query_has_pending_dependencies '`build_assignments`.`id`' printf ')' printf ' ORDER BY `requested` DESC, `trials`, `build_assignments`.`id`' printf ' LIMIT 1;\n' diff --git a/bin/mysql-functions b/bin/mysql-functions index 82c6fc8..44ef851 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -706,3 +706,48 @@ mysql_cleanup() { } | \ ${mysql_command} } + +# mysql_query_has_pending_dependencies `build_assignment`.`id` +# print a mysql query giving wether dependencies are pending +mysql_query_has_pending_dependencies() { + printf 'EXISTS (' + printf 'SELECT * FROM `binary_packages` as `to_dos`' + printf ' JOIN `%s` ON `%s`.`%s`=`%s`.`%s`' \ + 'repositories` AS `to_do_repos' 'to_do_repos' 'id' 'to_dos' 'repository' \ + 'dependencies' 'to_dos' 'id' 'dependencies' 'dependent' \ + 'install_target_providers' 'dependencies' 'depending_on' 'install_target_providers' 'install_target' \ + 'binary_packages` AS `bin_deps' 'bin_deps' 'id' 'install_target_providers' 'package' \ + 'repositories` AS `dep_repos' 'dep_repos' 'id' 'bin_deps' 'repository' + printf ' WHERE' + printf ' `%s`.`name`="build-list" AND' \ + 'dep_repos' 'to_do_repos' + printf ' `bin_deps`.`build_assignment`!=`to_dos`.`build_assignment` AND' + printf ' `to_dos`.`build_assignment`=%s' \ + "$1" + printf ')' +} + +# mysql_query_is_part_of_loop `build_assignment`.`id` +# print a mysql query giving wether the package is part of a loop +mysql_query_is_part_of_loop() { + printf 'EXISTS (' + printf 'SELECT * FROM `build_dependency_loops`' + printf ' WHERE `build_dependency_loops`.`build_assignment`=%s' \ + "$1" + printf ')' +} + +# mysql_query_select_pkgbase_and_revision +# print the part of a mysql query giving: +# pkgbase git_revision mod_git_revision upstream_package_repository +mysql_query_select_pkgbase_and_revision() { + printf '`package_sources`.`%s`,' \ + 'pkgbase' \ + 'git_revision' \ + 'mod_git_revision' + printf '`upstream_repositories`.`name`' + printf ' FROM `build_assignments`' + printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ + 'package_sources' 'package_sources' 'build_assignments' 'package_source' \ + 'upstream_repositories' 'upstream_repositories' 'package_sources' 'upstream_package_repository' +} |