Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/wtf
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-28 14:47:32 +0200
committerErich Eckner <git@eckner.net>2018-03-28 14:47:32 +0200
commitd1f85f94a3baa51c38be356f659138bef035d460 (patch)
tree164ac96abbda3a0ff765d49d81228a267b9b8a00 /bin/wtf
parent6d6b37c0ad62d448503efadf613790d133a88465 (diff)
bin/wtf: new table format, smaller bugfixes
Diffstat (limited to 'bin/wtf')
-rwxr-xr-xbin/wtf31
1 files changed, 23 insertions, 8 deletions
diff --git a/bin/wtf b/bin/wtf
index 0a48293..247b3e3 100755
--- a/bin/wtf
+++ b/bin/wtf
@@ -9,15 +9,22 @@
. "${0%/*}/../conf/default.conf"
hash=$(
- printf '%s' "$*" | \
- sha512sum | \
- awk '{print $1}'
+ printf '%d' "0x$(
+ printf '%s' "$*" | \
+ sed '
+ s,/$,,
+ s,.*/,,
+ ' | \
+ sha224sum | \
+ awk '{print $1}' | \
+ cut -c 1-4
+ )"
)
result=$(
# shellcheck disable=SC2016
{
- printf 'SELECT CONCAT(`repositories`.`name`,"/",'
+ printf 'SELECT DISTINCT CONCAT(`repositories`.`name`,"/",'
mysql_package_name_query
printf ')'
printf ' FROM `binary_packages`'
@@ -25,10 +32,18 @@ result=$(
mysql_join_binary_packages_repositories
mysql_join_binary_packages_file_providers
mysql_join_file_providers_files
- printf ' WHERE `files`.`absolute_name_hash`="%s"' \
- "${hash}"
- printf ' OR `files`.`name_hash`="%s"' \
+ printf ' WHERE `files`.`name_hash`=%s' \
"${hash}"
+ printf ' AND (`files`.`name`=from_base64("%s")' \
+ "$(
+ printf '%s' "$*" | \
+ base64 -w0
+ )"
+ printf ' OR CONCAT(`files`.`path`,`files`.`name`)=from_base64("%s"))' \
+ "$(
+ printf '%s' "$*" | \
+ base64 -w0
+ )"
} | \
mysql_run_query
)
@@ -36,5 +51,5 @@ result=$(
if [ -z "${result}" ]; then
printf 'Huh, I don'"'"'t know that one.\n'
else
- printf '%s' "${result}"
+ printf '%s\n' "${result}"
fi