Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-07-06 10:31:08 +0200
committerErich Eckner <git@eckner.net>2018-07-06 10:31:08 +0200
commit48abda2dd07cb8379996d0046bd99fdbb9dbd29d (patch)
tree0e001b18ff733e0971dfd087822759299d04b1a6 /bin
parenta4b94e21dc895f796e8a89be14416c8f949474ab (diff)
bin/wtp new to query package database
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ii-answer25
-rwxr-xr-xbin/wtp46
2 files changed, 71 insertions, 0 deletions
diff --git a/bin/ii-answer b/bin/ii-answer
index 8bbdbb1..0fa032c 100755
--- a/bin/ii-answer
+++ b/bin/ii-answer
@@ -93,6 +93,31 @@ find "${irc_dir}" \
irc_say "${channel}" 'copy'
done
fi
+ # answer "wtp?"
+ regex='^\S\+ <\(\S\+\)> '"${prefix}"'!\?wtp '
+ if grep -q "${regex}" "${out_file}"; then
+ sed -i '
+ s/'"${regex}"'/\1 /
+ T
+ w /dev/stdout
+ d
+ ' "${out_file}" | \
+ while read -r asker line; do
+ reason=$("${base_dir}/bin/wtp" "${line}");
+ if [ -z "${reason}" ]; then
+ reason="No, we don't have that."
+ fi
+ reason="${asker}: ${reason}"
+ if [ "$(echo "${reason}" | wc -l)" -le 5 ]; then
+ echo "${reason}"
+ else
+ echo "${reason}" | \
+ head -n5
+ printf '... (%s lines total)\n' "$(echo "${reason}" | wc -l)"
+ fi | \
+ irc_say "${channel}" 'copy'
+ done
+ fi
# answer "What's up?"
regex='^\S\+ <\S\+> .*[Ww]hat'"'"'\?s *[Uu]p'
if grep "${regex}" "${out_file}" | \
diff --git a/bin/wtp b/bin/wtp
new file mode 100755
index 0000000..3545f61
--- /dev/null
+++ b/bin/wtp
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# search for a package in the database
+
+# shellcheck disable=SC2119,SC2120
+
+# shellcheck source=../lib/load-configuration
+. "${0%/*}/../lib/load-configuration"
+
+# shellcheck disable=SC2016
+{
+ printf 'SELECT'
+ printf ' CONCAT('
+ printf '`architectures`.`name`,"/",'
+ printf '`binary_packages`.`pkgname`,": ",'
+ printf 'GROUP_CONCAT('
+ printf 'CONCAT('
+ printf '`r_a`.`name`,"/",'
+ printf '`repositories`.`name`," (",'
+ printf 'IF('
+ printf '`binary_packages`.`epoch`=0,'
+ printf '"",'
+ printf 'CONCAT(`binary_packages`.`epoch`,":")'
+ printf '),'
+ printf '`binary_packages`.`pkgver`,"-",'
+ printf '`binary_packages`.`pkgrel`,'
+ printf 'IF('
+ printf 'NOT `binary_packages`.`sub_pkgrel_omitted`,'
+ printf 'CONCAT(".",`binary_packages`.`sub_pkgrel`),'
+ printf '""),'
+ printf '")"'
+ printf ') SEPARATOR ", "'
+ printf ')'
+ printf ')'
+ printf ' FROM `binary_packages`'
+ mysql_join_binary_packages_architectures
+ mysql_join_binary_packages_binary_packages_in_repositories
+ mysql_join_binary_packages_in_repositories_repositories
+ mysql_join_repositories_architectures '' 'r_a'
+ printf ' WHERE `binary_packages`.`pkgname` LIKE from_base64("'
+ printf '%s' "$*" | \
+ base64 -w0
+ printf '") AND `repositories`.`is_on_master_mirror`'
+ printf ' GROUP BY CONCAT(`binary_packages`.`pkgname`,"-",`architectures`.`name`);\n'
+} | \
+ mysql_run_query