Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/return-assignment
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-09-03 09:54:25 +0200
committerErich Eckner <git@eckner.net>2018-09-03 09:54:25 +0200
commitbeda398f5affe2db5491093908bbdedde4535fe7 (patch)
tree1a3b7878b2b70b019da74f653c412b71c140586d /bin/return-assignment
parent00ec890ca7e2aaf5fc1c8c48eefe2ac3b1327493 (diff)
bin/return-assignment: save version of required and provided libraries
Diffstat (limited to 'bin/return-assignment')
-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