Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/intentions-queue
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-01-30 10:44:25 +0100
committerErich Eckner <git@eckner.net>2020-01-30 10:44:25 +0100
commitf67e43ca9ba64ffdfa4c41614ce62b81936f6e4b (patch)
tree0202b62f9a0fd6da970ccfde44d4a069ea7cc485 /lib/intentions-queue
parent132f43c70bd30ae73b03c68b562b7be8d6e2954d (diff)
lib/intentions-queue: a start
Diffstat (limited to 'lib/intentions-queue')
-rwxr-xr-xlib/intentions-queue53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/intentions-queue b/lib/intentions-queue
index 56742fa..6710eb5 100755
--- a/lib/intentions-queue
+++ b/lib/intentions-queue
@@ -26,3 +26,56 @@ fi
# 3. update mysql database
# 4. upload database to mirror
# 5. update packages on mirror
+
+# intent_something
+# create an intention, provided on stdin
+# note, that this function is not thread-safe
+intent_something() {
+ local next_number
+ next_number=$((
+ $(
+ find "${intentions_directory}" \
+ -maxdepth 1 \
+ -type f \
+ -name 'intention.*' \
+ -printf '%f\n' \
+ | sed '
+ s/^intention\.//
+ t
+ d
+ ' \
+ | sort -nr \
+ | grep -xm1 '[0-9]\+' \
+ || echo 0
+ )+1
+ ))
+ {
+ printf '%s\n' \
+ '#!/bin/sh' \
+ 'set -e'
+ cat
+ printf 'rm "%s"\n' "${intentions_directory}/intention.${next_number}"
+ } > "${intentions_directory}/intention.${next_number}"
+ chmod +x "${intentions_directory}/intention.${next_number}"
+}
+
+# execute_intention
+# executes the next intention
+execute_intention() {
+ local next_number
+ next_number=$(
+ find "${intentions_directory}" \
+ -maxdepth 1 \
+ -type f \
+ -name 'intention.*' \
+ -printf '%f\n' \
+ | sed '
+ s/^intention\.//
+ t
+ d
+ ' \
+ | sort -n \
+ | grep -xm1 '[0-9]\+'
+ ) || return 0
+ "${intentions_directory}/intention.${next_number}"
+}