summaryrefslogtreecommitdiff
path: root/bin/mysql-functions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-01-17 13:43:18 +0100
committerErich Eckner <git@eckner.net>2018-01-17 13:43:18 +0100
commit5afe831dc54294f0de0633d5f91c1f07bf56eb42 (patch)
tree2b27c3b289c6ab5195ff4d56ba03ee6a8522c3e8 /bin/mysql-functions
parent70d60ec3f5f507f9cdf8766fcadc74bdc907cba3 (diff)
downloadbuilder-5afe831dc54294f0de0633d5f91c1f07bf56eb42.tar.xz
bin/mysql-functions: mysql_sanity_check() new
Diffstat (limited to 'bin/mysql-functions')
-rwxr-xr-xbin/mysql-functions47
1 files changed, 47 insertions, 0 deletions
diff --git a/bin/mysql-functions b/bin/mysql-functions
index 340f9d5..ca7d0ca 100755
--- a/bin/mysql-functions
+++ b/bin/mysql-functions
@@ -573,3 +573,50 @@ mysql_generate_package_metadata() {
)
}
+
+# mysql_sanity_check
+# do a sanity check on the mysql database
+
+mysql_sanity_check() {
+ ( # new shell is intentional
+ temp_dir=$(mktemp -d)
+ trap 'rm -rf --one-file-system "${temp_dir}"' EXIT
+
+ for dir in $(ls_master_mirror 'i686'); do
+ ls_master_mirror "i686/${dir}" | \
+ sed -n '
+ s/\.pkg\.tar\.xz$//
+ T
+ s/-\([0-9]\+\)-\([^-]\+\)$/-\1.0-\2/
+ s/-\([^-:]\+-[^-]\+-[^-]\+\)$/-0:\1/
+ s|^|'"${dir}"'/|
+ p
+ '
+ done | \
+ sort > \
+ "${temp_dir}/master-mirror-listing"
+
+ # shellcheck disable=SC2016
+ ${mysql_command} '
+ SELECT `repositories`.`name`,`pkgname`,`epoch`,`pkgver`,`pkgrel`,`sub_pkgrel`,`architectures`.`name`
+ FROM `binary_packages`
+ JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`
+ JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`
+ ' --batch | \
+ sed '
+ 1d
+ s,\t,/,
+ s,\t,-,
+ s,\t,:,
+ s,\t,-,
+ s,\t,.,
+ s,\t,-,
+ ' | \
+ sort > \
+ "${temp_dir}/mysql-packages"
+
+ diff -u \
+ "${temp_dir}/mysql-packages" \
+ "${temp_dir}/master-mirror-listing"
+ )
+}