diff options
author | Erich Eckner <git@eckner.net> | 2017-09-13 10:26:35 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-09-13 10:26:35 +0200 |
commit | ef1582777fff756ed391b403266b3bbbabb182a0 (patch) | |
tree | 5206fb6eea39cac7f51cead224ad40d9909efe8c /bin | |
parent | 79ee1532e6b4bc23a23398f7d60442feddb85b72 (diff) | |
download | builder-ef1582777fff756ed391b403266b3bbbabb182a0.tar.xz |
bin/get-assignment, bin/return-assignment: clean up some "grep -l" occurences
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/get-assignment | 11 | ||||
-rwxr-xr-x | bin/return-assignment | 24 |
2 files changed, 22 insertions, 13 deletions
diff --git a/bin/get-assignment b/bin/get-assignment index 93f2886..bb9cb40 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -43,10 +43,13 @@ hand_out_assignment() { echo "${slave}" > "${work_dir}/package-states/$1.$2.$3.$4.locked" # lock every loop this package breaks - grep -lxF "${1}" "${work_dir}/build-list.loops/"loop_* | \ - tee -a "${work_dir}/package-states/$1.$2.$3.$4.locked" | \ - sed 's|$|.locked|' | \ - xargs -rn1 touch + find "${work_dir}/build-list.loops" -maxdepth 1 \ + -name 'loop_*' \ + -not -name 'loop_*.locked' \ + -exec grep -qxF "$1" '{}' \; \ + -exec touch '{}.locked' \; \ + -print >> \ + "${work_dir}/package-states/$1.$2.$3.$4.locked" exit 0 diff --git a/bin/return-assignment b/bin/return-assignment index 05a8569..4cb8859 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -68,7 +68,11 @@ if [ "$5" = 'ERROR' ]; then find "${work_dir}/package-states/" -maxdepth 1 -name '*.locked' -printf '%f\n' | \ sed 's@^\(.\+\)\.\([0-9a-f]\{40\}\.\)\{2\}[^.]\+\.locked$@\1@' ) - grep -lxF "${1}" "${work_dir}/build-list.loops/loop_"* 2> /dev/null | \ + find "${work_dir}/build-list.loops" -maxdepth 1 \ + -name 'loop_*' \ + -not -name 'loop_*.locked' \ + -exec grep -qxF "$1" '{}' \; \ + -print | \ while read -r loop; do if [ -z "$( ( @@ -202,16 +206,18 @@ done # remove old state files (these should be only "done" markers, but # actually we don't care what it is) - as long as it's not "testing" -find "${work_dir}/package-states" -maxdepth 1 | \ - grep "/$(str_to_regex "$1")\(\.[^.]\+\)\{4\}\$" | \ - grep -v "/$(str_to_regex "$1.$2.$3.$4")\.[^.]\+\$" | \ - grep -v '\.testing$' | \ - xargs -rn1 rm -f +find "${work_dir}/package-states" -maxdepth 1 -regextype grep \ + -not -name '*.testing' \ + -regex ".*/$(str_to_regex "$1")\(\.[^.]\+\)\{4\}" \ + -not -regex ".*/$(str_to_regex "$1.$2.$3.$4")\.[^.]\+" \ + -exec rm '{}' \; # remove all loops which are broken by this package -grep -lxF "$1" "${work_dir}/build-list.loops/loop_"* 2> /dev/null | \ - sed 'p;s|$|.locked|' | \ - xargs -rn1 rm -f +find "${work_dir}/build-list.loops" -maxdepth 1 \ + -name 'loop_*' \ + -not -name 'loop_*.locked' \ + -exec grep -qxF "$1" '{}' \; \ + -exec rm '{}' '{}.locked' \; if ! find "${work_dir}/build-list.loops" -maxdepth 1 -printf '%f\n' | \ grep -q '^loop_[0-9]\+$'; then |