index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2019-06-26 15:17:21 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-06-26 15:17:21 +0200 |
commit | 92bff46a1574c5425e88696f19333973406e0743 (patch) | |
tree | dec45aa9639a3c1adb5b38dfb77970ac1f953f5b /bin/get-assignment | |
parent | 130ac893e7903a39a320eeb803d4b2d8c2178288 (diff) |
-rwxr-xr-x | bin/get-assignment | 179 |
diff --git a/bin/get-assignment b/bin/get-assignment index 462d2c7..9dcb600 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -303,77 +303,126 @@ next_building=$( # - does not exist blocked before exists blocked # - unbuilt before built # - exists unblocked before does not exist unblocked - printf 'DELETE `considered_build_assignments`' + + printf 'CREATE TEMPORARY TABLE `ordered_considered_build_assignments`(' + printf '`order` BIGINT NOT NULL AUTO_INCREMENT,' + printf '`id` BIGINT NOT NULL,' + printf '`exists_blocked` BIT NOT NULL,' + printf '`exists_built` BIT NOT NULL,' + printf '`exists_unblocked` BIT NOT NULL,' + printf 'PRIMARY KEY (`order`),' + printf 'KEY (`id`)' + printf ');\n' + printf 'CREATE TEMPORARY TABLE `orders`(' + printf '`order` BIGINT NOT NULL AUTO_INCREMENT,' + printf 'PRIMARY KEY (`order`)' + printf ');\n' + + printf 'INSERT IGNORE INTO `ordered_considered_build_assignments` (' + printf '`id`,' + printf '`exists_blocked`,' + printf '`exists_built`,' + printf '`exists_unblocked`' + printf ')' + printf 'SELECT' + printf ' `build_assignments`.`id`,' + printf 'EXISTS (' + printf 'SELECT 1' + printf ' FROM `toolchain_order` AS `late`' + printf ' JOIN `toolchain_order` AS `early`' + printf ' ON `late`.`pkgbase`!=`early`.`pkgbase`' + printf ' AND `late`.`number`>`early`.`number`' + printf ' JOIN `package_sources` AS `e_ps`' + printf ' ON `e_ps`.`pkgbase`=`early`.`pkgbase`' + mysql_join_package_sources_build_assignments 'e_ps' 'e_ba' + printf ' JOIN `considered_build_assignments_3` AS `e_cba`' + printf ' ON `e_cba`.`id`=`e_ba`.`id`' + printf ' WHERE `late`.`pkgbase`=`package_sources`.`pkgbase`' + printf ') AS `exists_blocked`,' + printf 'EXISTS (' + printf 'SELECT 1' + printf ' FROM `binary_packages_in_repositories`' + mysql_join_binary_packages_in_repositories_repositories + printf ' AND `repositories`.`is_on_master_mirror`' + printf ' JOIN `architecture_compatibilities`' + printf ' ON `repositories`.`architecture`=`architecture_compatibilities`.`runs_on`' + printf ' AND `architecture_compatibilities`.`build_slave_compatible`' + printf ' JOIN `architectures`' + printf ' ON `architectures`.`id`=`architecture_compatibilities`.`built_for`' + printf ' AND `architectures`.`name`=from_base64("%s")' \ + "${arch}" + mysql_join_binary_packages_in_repositories_binary_packages + printf ' WHERE `binary_packages`.`build_assignment`=`build_assignments`.`id`' + printf ') AS `exists_built`,' + printf 'EXISTS (' + printf 'SELECT 1' + printf ' FROM `toolchain_order` AS `late`' + printf ' WHERE NOT EXISTS (' + printf 'SELECT 1' + printf ' FROM `toolchain_order` AS `early`' + printf ' JOIN `package_sources` AS `e_ps`' + printf ' ON `e_ps`.`pkgbase`=`early`.`pkgbase`' + mysql_join_package_sources_build_assignments 'e_ps' 'e_ba' + printf ' JOIN `considered_build_assignments_4` AS `e_cba`' + printf ' ON `e_ba`.`id`=`e_cba`.`id`' + printf ' WHERE `late`.`pkgbase`!=`early`.`pkgbase`' + printf ' AND `late`.`number`>`early`.`number`' + printf ')' + printf ' AND `late`.`pkgbase`=`package_sources`.`pkgbase`' + printf ') AS `exists_unblocked`' printf ' FROM `considered_build_assignments`' printf ' JOIN `build_assignments`' printf ' ON `build_assignments`.`id`=`considered_build_assignments`.`id`' printf ' JOIN `toolchain_architectures`' - printf ' ON `build_assignments`.`architecture`=`toolchain_architectures`.`id`;\n' + printf ' ON `build_assignments`.`architecture`=`toolchain_architectures`.`id`' + mysql_join_build_assignments_package_sources + printf ' ORDER BY' + # does it exist toolchain-blocked? + printf ' `exists_blocked`,' + # does it exist built? + printf '`exists_built`,' + # does it exist not toolchain-blocked? + printf '`exists_unblocked` DESC' + printf ';\n' + + printf 'INSERT INTO `orders`(`order`)' + printf ' SELECT' + printf ' MIN(`ordered_considered_build_assignments`.`order`)' + printf ' FROM `ordered_considered_build_assignments`' + printf ' JOIN `build_assignments`' + printf ' ON `build_assignments`.`id`=`ordered_considered_build_assignments`.`id`' + printf ' JOIN `toolchain_architectures`' + printf ' JOIN `architecture_compatibilities`' + printf ' ON `architecture_compatibilities`.`fully_compatible`' + printf ' AND (' + printf '(' + printf '`architecture_compatibilities`.`runs_on`=`build_assignments`.`architecture`' + printf ' AND `architecture_compatibilities`.`built_for`=`toolchain_architectures`.`id`' + printf ') OR (' + printf '`architecture_compatibilities`.`built_for`=`build_assignments`.`architecture`' + printf ' AND `architecture_compatibilities`.`runs_on`=`toolchain_architectures`.`id`' + printf ')' + printf ')' + printf ' GROUP BY `toolchain_architectures`.`id`' + printf ';\n' + + printf 'DELETE `considered_build_assignments`' + printf ' FROM `toolchain_architectures`' + printf ' JOIN `build_assignments`' + printf ' ON `build_assignments`.`architecture`=`toolchain_architectures`.`id`' + printf ' JOIN `considered_build_assignments`' + printf ' ON `build_assignments`.`id`=`considered_build_assignments`.`id`;\n' -# TODO: this is somewhat inaccurate: We keep one build assignment per architecture -# but actually, any should interfere with each other architecture, too ... printf 'INSERT IGNORE INTO `considered_build_assignments` (`id`)' - printf 'SELECT `sub_query`.`ba_id`' - printf ' FROM (' - printf 'SELECT' - printf ' `considered_build_assignments_2`.`id` AS `ba_id`,' - printf '`build_assignments`.`architecture`' - printf ' FROM `considered_build_assignments_2`' - printf ' JOIN `build_assignments`' - printf ' ON `build_assignments`.`id`=`considered_build_assignments_2`.`id`' - printf ' JOIN `toolchain_architectures`' - printf ' ON `build_assignments`.`architecture`=`toolchain_architectures`.`id`' - mysql_join_build_assignments_package_sources - printf ' ORDER BY' - # does it exist toolchain-blocked? - printf ' EXISTS (' - printf 'SELECT 1' - printf ' FROM `toolchain_order` AS `late`' - printf ' JOIN `toolchain_order` AS `early`' - printf ' ON `late`.`pkgbase`!=`early`.`pkgbase`' - printf ' AND `late`.`number`>`early`.`number`' - printf ' JOIN `package_sources` AS `e_ps`' - printf ' ON `e_ps`.`pkgbase`=`early`.`pkgbase`' - mysql_join_package_sources_build_assignments 'e_ps' 'e_ba' - printf ' JOIN `considered_build_assignments_3` AS `e_cba`' - printf ' ON `e_cba`.`id`=`e_ba`.`id`' - printf ' WHERE `late`.`pkgbase`=`package_sources`.`pkgbase`' - printf '),' - # does it exist built? - printf ' EXISTS (' - printf 'SELECT 1' - printf ' FROM `binary_packages_in_repositories`' - mysql_join_binary_packages_in_repositories_repositories - printf ' AND `repositories`.`is_on_master_mirror`' - printf ' JOIN `architecture_compatibilities`' - printf ' ON `repositories`.`architecture`=`architecture_compatibilities`.`runs_on`' - printf ' AND `architecture_compatibilities`.`build_slave_compatible`' - printf ' JOIN `architectures`' - printf ' ON `architectures`.`id`=`architecture_compatibilities`.`built_for`' - printf ' AND `architectures`.`name`=from_base64("%s")' \ - "${arch}" - mysql_join_binary_packages_in_repositories_binary_packages - printf ' WHERE `binary_packages`.`build_assignment`=`build_assignments`.`id`' - printf '),' - # does it exist not toolchain-blocked? - printf ' EXISTS (' - printf 'SELECT 1' - printf ' FROM `toolchain_order` AS `late`' - printf ' WHERE NOT EXISTS (' - printf 'SELECT 1' - printf ' FROM `toolchain_order` AS `early`' - printf ' JOIN `package_sources` AS `e_ps`' - printf ' ON `e_ps`.`pkgbase`=`early`.`pkgbase`' - mysql_join_package_sources_build_assignments 'e_ps' 'e_ba' - printf ' JOIN `considered_build_assignments_4` AS `e_cba`' - printf ' ON `e_ba`.`id`=`e_cba`.`id`' - printf ' WHERE `late`.`pkgbase`!=`early`.`pkgbase`' - printf ' AND `late`.`number`>`early`.`number`' - printf ')' - printf ' AND `late`.`pkgbase`=`package_sources`.`pkgbase`' - printf ') DESC' - printf ') AS `sub_query`' - printf ' GROUP BY `sub_query`.`architecture`;\n' + printf ' SELECT' + printf ' `ordered_considered_build_assignments`.`id`' + printf ' FROM `ordered_considered_build_assignments`' + printf ' JOIN `orders`' + printf ' ON `orders`.`order`=`ordered_considered_build_assignments`.`order`' + printf ';\n' + + printf 'DROP TEMPORARY TABLE `ordered_considered_build_assignments`;\n' + printf 'DROP TEMPORARY TABLE `orders`;\n' # delete all currently building packages from considered list printf 'DELETE `considered_build_assignments`' |