diff options
author | Erich Eckner <git@eckner.net> | 2020-01-30 10:44:25 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-01-30 10:44:25 +0100 |
commit | f67e43ca9ba64ffdfa4c41614ce62b81936f6e4b (patch) | |
tree | 0202b62f9a0fd6da970ccfde44d4a069ea7cc485 /lib | |
parent | 132f43c70bd30ae73b03c68b562b7be8d6e2954d (diff) | |
download | builder-f67e43ca9ba64ffdfa4c41614ce62b81936f6e4b.tar.xz |
lib/intentions-queue: a start
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/intentions-queue | 53 |
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}" +} |