Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/common-functions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-07-19 16:32:47 +0200
committerErich Eckner <git@eckner.net>2017-07-19 16:32:47 +0200
commite7fcf00a9fe393749066ad7c2c933c55b4f3e149 (patch)
tree0b8eed1c7607fceb8253be4fc74910b12e0432f8 /bin/common-functions
parentba0dc8e491b6b202e0e407a07169804d9bdb0143 (diff)
bin/common-functions: delete_old_metadata: keep at least one version of every known package
Diffstat (limited to 'bin/common-functions')
-rwxr-xr-xbin/common-functions114
1 files changed, 91 insertions, 23 deletions
diff --git a/bin/common-functions b/bin/common-functions
index 938c18a..74f3a54 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -199,33 +199,101 @@ generate_package_metadata() {
delete_old_metadata() {
+ local current_metadata
+
+ current_metadata="$(
+ ls "${work_dir}/package-infos" | \
+ sed '
+ s|\.[^.]\+$||
+ s|\.\([^.]\+\)\.\([^.]\+\)$| \1 \2|
+ ' | \
+ sort -u
+ )"
+
(
+ # what we have
+ echo "${current_metadata}"
+
+ # package-states should stay
+ ls -1 "${work_dir}/package-states" | \
+ sed '
+ s|\.\([^.]\+\)\.\([^.]\+\)\(\.[^.]\+\)\{2\}$| \1 \2|
+ ' | \
+ sort -u | \
+ sed 'p'
+
+ # build-list items should stay
+ cut -d' ' -f1,2,3 "${work_dir}/build-list" | \
+ sed 'p'
+
+ current_metadata_file="$(mktemp)"
+ trap 'rm -f "${current_metadata_file}"' EXIT
+
+ echo "${current_metadata}" | \
+ sort -k1,1 > \
+ "${current_metadata_file}"
+
+ # the newest of the following should stay:
(
- ls -1 "${work_dir}/package-infos" | \
- sed '
- s|\.\([^.]\+\)\.\([^.]\+\)\.[^.]\+$| \1 \2|
- ' | \
- sort -u
- ls -1 "${work_dir}/package-states" | \
- sed '
- s|\.\([^.]\+\)\.\([^.]\+\)\(\.[^.]\+\)\{2\}$| \1 \2|
- ' | \
- sort -u | \
- sed 'p'
- cut -d' ' -f1,2,3 "${work_dir}/build-list" | \
- sed 'p'
+ # deletion-list items
+ cat "${work_dir}/deletion-list"
+ # all packages in the repos
+ for repo in ${repo_names}; do
+ eval 'git -C "${repo_paths__'"${repo}"'}" archive '"$(cat "${work_dir}/${repo}.revision")" | \
+ tar -t | \
+ sed '
+ s|/$||
+ /\//d
+ '
+ done
) | \
- sort | \
- uniq -u | \
- awk '{print $2 " " $3 " " $1}'
- sed '
- s|^|whatever whatever |
- p
- ' "${work_dir}/deletion-list"
+ sort -u | \
+ join -j 1 -o 2.2,2.3,2.1 - "${current_metadata_file}" | \
+ sort -k3,3 | \
+ uniq --group=append -f2 | \
+ (
+ revs=''
+ mod_revs=''
+ opkg=''
+ while read -r rev mod_rev pkg; do
+
+ if [ -z "${rev}" ] && \
+ [ -z "${mod_rev}" ] && \
+ [ -z "${pkg}" ]; then
+
+ printf '%s %s %s\n' \
+ "$(
+ printf '%s\n' ${revs} | \
+ find_newest_of_git_revisions
+ )" \
+ "$(
+ printf '%s\n' ${mod_revs} | \
+ find_newest_of_git_revisions
+ )" \
+ "${opkg}"
+
+ revs=''
+ mod_revs=''
+ opkg=''
+ continue
+ fi
+ revs="$(
+ printf '%s\n' ${revs} ${rev} | \
+ sort -u
+ )"
+ mod_revs="$(
+ printf '%s\n' ${mod_revs} ${mod_rev} | \
+ sort -u
+ )"
+ opkg="${pkg}"
+ done
+ ) | \
+ awk '{print $3 " " $1 " " $2}' | \
+ sed 'p'
) | \
- sort -k3,3 | \
- uniq -uf2 | \
- while read -r rev mod_rev pkg; do
+ sort | \
+ uniq -u | \
+ while read -r pkg rev mod_rev; do
rm -f "${work_dir}/package-infos/${pkg}.${rev}.${mod_rev}".*
done
}