summaryrefslogtreecommitdiff
path: root/bin/db-update
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-10-30 11:29:38 +0100
committerErich Eckner <git@eckner.net>2017-10-30 11:29:38 +0100
commitecb99b288c713811a3eaf3f53732ca2cda0ba648 (patch)
tree95f440f70c678a3fdb158667b8e6c2f96edf2a3a /bin/db-update
parent4ebe9383773cb4712c44632b389cf0debf1a6088 (diff)
downloadbuilder-ecb99b288c713811a3eaf3f53732ca2cda0ba648.tar.xz
bin/db-update: remove *.tested and *.testing state files when unstaging a package
Diffstat (limited to 'bin/db-update')
-rwxr-xr-xbin/db-update16
1 files changed, 12 insertions, 4 deletions
diff --git a/bin/db-update b/bin/db-update
index 9bd6024..9b3f92f 100755
--- a/bin/db-update
+++ b/bin/db-update
@@ -52,6 +52,7 @@ move_packages() {
local from_repo
local to_repo
local from_ending
+ local rm_ending
local to_ending
local repo
local part
@@ -102,12 +103,14 @@ move_packages() {
echo "${to_repo}" | \
grep -q 'testing$'; then
from_ending='done'
+ rm_ending='test\(ing\|ed\)'
to_ending='testing'
elif echo "${from_repo}" | \
grep -q 'testing$' && \
! echo "${to_repo}" | \
grep -q 'testing$\|staging$'; then
from_ending='tested'
+ rm_ending=''
to_ending=''
else
>&2 printf 'move_packages: Cannot move package "%s" from "%s" to "%s".\n' "${package}" "${from_repo}" "${to_repo}"
@@ -120,6 +123,8 @@ move_packages() {
"${tmp_dir}/tmp/${package}.to_repo"
echo "${from_ending}" > \
"${tmp_dir}/tmp/${package}.from_ending"
+ echo "${rm_ending}" > \
+ "${tmp_dir}/tmp/${package}.rm_ending"
echo "${to_ending}" > \
"${tmp_dir}/tmp/${package}.to_ending"
@@ -291,6 +296,9 @@ move_packages() {
from_ending=$(
cat "${tmp_dir}/tmp/${package}.from_ending"
)
+ rm_ending=$(
+ cat "${tmp_dir}/tmp/${package}.rm_ending"
+ )
to_ending=$(
cat "${tmp_dir}/tmp/${package}.to_ending"
)
@@ -299,10 +307,10 @@ move_packages() {
${dummynator} rm \
"${work_dir}/package-states/${package}.${from_ending}"
else
- # remove old state files of $package with ending $to_ending
- find "${work_dir}/package-states" -maxdepth 1 | \
- grep "/$(str_to_regex "${package%.*.*.*}")\(\.[^.]\+\)\{3\}\.${to_ending}\$" | \
- xargs -rn1 ${dummynator} rm
+ # remove old state files of $package with ending $rm_ending
+ find "${work_dir}/package-states" -maxdepth 1 -regextype grep \
+ -regex ".*/$(str_to_regex "${package%.*.*.*}")\(\.[^.]\+\)\{3\}\.${rm_ending}" \
+ -execdir ${dummynator} rm {} \;
${dummynator} mv \
"${work_dir}/package-states/${package}.${from_ending}" \
"${work_dir}/package-states/${package}.${to_ending}"