summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/return-assignment73
1 files changed, 65 insertions, 8 deletions
diff --git a/bin/return-assignment b/bin/return-assignment
index 96cec90..8db7737 100755
--- a/bin/return-assignment
+++ b/bin/return-assignment
@@ -538,6 +538,28 @@ if [ -n "${errors}" ]; then
exit 1
fi
+min_version=$(
+ # shellcheck disable=SC2016
+ {
+ printf 'SELECT CONCAT(`versions`.`epoch`,":",`versions`.`version`)'
+ printf ' FROM `versions`'
+ printf ' ORDER BY `versions`.`order`'
+ printf ' LIMIT 1'
+ } | \
+ mysql_run_query
+)
+
+max_version=$(
+ # shellcheck disable=SC2016
+ {
+ printf 'SELECT CONCAT(`versions`.`epoch`,":",`versions`.`version`)'
+ printf ' FROM `versions`'
+ printf ' ORDER BY `versions`.`order` DESC'
+ printf ' LIMIT 1'
+ } | \
+ mysql_run_query
+)
+
while read -r package_id package_name; do
# move namcap.logs
mv \
@@ -551,6 +573,19 @@ while read -r package_id package_name; do
for lib in 'provides' 'needs'; do
zcat "${tmp_dir}/${package_name}.so.${lib}.gz" | \
sed '
+ s/\(=\|<\|<=\|>=\|>\)\([^[:space:]-]\+\)$/\t\1\t\2/
+ t
+ h
+ s/$/\t>=\t'"${min_version}"'/
+ p
+ g
+ s/$/\t<=\t'"${max_version}"'/
+ ' | \
+ sed '
+ s/\(\s[0-9]\+\):\(\S\+\)$/\1\t\2/
+ t coda
+ s/\s\S\+$/\t0\0/
+ :coda
s/^/'"${package_id}"'\t/
' >> "${tmp_dir}/so.${lib}"
done
@@ -629,8 +664,14 @@ trigger_mirror_refreshs
# insert provided/needed libraries into database
for lib_link in 'pl:provides' 'nl:needs'; do
- printf 'CREATE TEMPORARY TABLE `%s` (`pkgid` BIGINT, `lib` VARCHAR(128));\n' \
+ printf 'CREATE TEMPORARY TABLE `%s` (' \
"${lib_link%:*}"
+ printf '`pkgid` BIGINT,'
+ printf '`lib` VARCHAR(128),'
+ printf '`relation` VARCHAR(2),'
+ printf '`epoch` MEDIUMINT,'
+ printf '`version` VARCHAR(32)'
+ printf ');\n'
printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `%s`;\n' \
"${tmp_dir}/so.${lib_link#*:}" "${lib_link%:*}"
@@ -639,22 +680,38 @@ trigger_mirror_refreshs
"${lib_link%:*}" "${lib_link%:*}"
printf 'COMMIT;\n'
+ printf 'INSERT IGNORE INTO `versions` (`epoch`,`version`)'
+ printf ' SELECT DISTINCT `%s`.`epoch`,`%s`.`version` FROM `%s`;\n' \
+ "${lib_link%:*}" "${lib_link%:*}" "${lib_link%:*}"
+ printf 'COMMIT;\n'
+
if [ "${lib_link%:*}" = 'pl' ]; then
- printf 'INSERT IGNORE INTO `install_target_providers` (`package`,`install_target`)'
+ printf 'INSERT IGNORE INTO `install_target_providers` (`package`,`install_target`,`version`)'
else
- printf 'INSERT IGNORE INTO `dependencies` (`dependent`,`depending_on`,`dependency_type`)'
+ printf 'INSERT IGNORE INTO `dependencies` (`dependent`,`depending_on`,`dependency_type`,`version_relation`,`version`)'
fi
- printf ' SELECT `%s`.`pkgid`,`install_targets`.`id`' \
+ printf ' SELECT `%s`.`pkgid`,`install_targets`.`id`,' \
"${lib_link%:*}"
if [ "${lib_link%:*}" = 'nl' ]; then
- printf ',`dependency_types`.`id`'
+ printf '`dependency_types`.`id`,'
+ printf '`%s`.`relation`,' \
+ "${lib_link%:*}"
fi
+ printf '`versions`.`id`'
printf ' FROM `install_targets`'
if [ "${lib_link%:*}" = 'nl' ]; then
- printf ' JOIN `dependency_types` ON `dependency_types`.`name`="link"'
+ printf ' JOIN `dependency_types`'
+ printf ' ON `dependency_types`.`name`="link"'
fi
- printf ' JOIN `%s` ON `%s`.`lib`=`install_targets`.`name`' \
- "${lib_link%:*}" "${lib_link%:*}"
+ printf ' JOIN `%s`' \
+ "${lib_link%:*}"
+ printf ' ON `%s`.`lib`=`install_targets`.`name`' \
+ "${lib_link%:*}"
+ printf ' JOIN `versions`'
+ printf ' ON `versions`.`epoch`=`%s`.`epoch`' \
+ "${lib_link%:*}"
+ printf ' AND `versions`.`version`=`%s`.`version`' \
+ "${lib_link%:*}"
printf ';\n'
printf 'COMMIT;\n'
done