summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-04-17 19:15:50 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-04-17 19:15:50 -0400
commita0ce264fbacc79068bda2d7e9e3ffab65795e80f (patch)
treee14551abd017e0dbc2f5efa154f8a0fed0b47b64
parentae3d0acd8f001180b6a26fb25167394613a80e17 (diff)
un-delete the repo sanity check
-rw-r--r--README1
-rwxr-xr-xdb-check-repo-sanity57
2 files changed, 58 insertions, 0 deletions
diff --git a/README b/README
index 5304360..d119db0 100644
--- a/README
+++ b/README
@@ -13,6 +13,7 @@ The executables that you (might) care about are:
├── db-check-nonfree [Parabola only]
├── db-check-nonfree-in-db [Parabola only]
├── db-check-package-libraries [Parabola only]
+ ├── db-check-repo-sanity [Parabola only]
├── db-check-unsigned-packages [Parabola only]
├── db-check-unsigned-packages.py [Parabola only]
├── db-import [Parabola only]
diff --git a/db-check-repo-sanity b/db-check-repo-sanity
new file mode 100755
index 0000000..239f042
--- /dev/null
+++ b/db-check-repo-sanity
@@ -0,0 +1,57 @@
+#!/bin/bash
+# Solves issue165... on the old roundup install. From the database
+# backups, the title was "Older/deprecated packages never leave the
+# repo", I don't know how the body of the issue is stored in the DB,
+# but the title says enough, I think.
+
+. "$(dirname "$(readlink -e "$0")")/../config"
+. "$(dirname "$(readlink -e "$0")")/../db-functions"
+
+# Traverse all repos
+for _repo in "${PKGREPOS[@]}"; do
+ msg "Cleaning up [%s]" "${_repo}"
+
+ # Find all pkgnames on this repo's abs
+ on_abs=($(
+ find "${SVNREPO}/${_repo}" -name PKGBUILD | \
+ while read pkgbuild; do
+ source "${pkgbuild}" >/dev/null 2>&1
+ # cleanup to save memory
+ unset build package source md5sums pkgdesc pkgver pkgrel epoch \
+ url license arch depends makedepends optdepends options \
+ >/dev/null 2>&1
+
+ # also cleanup package functions
+ for _pkg in "${pkgname[@]}"; do
+ unset "package_${pkg}" >/dev/null 2>&1
+ done
+
+ # this fills the on_abs array
+ echo "${pkgname[@]}"
+ done
+ ))
+
+ # quit if abs is empty
+ if [ ${#on_abs[*]} -eq 0 ]; then
+ warning "[%s]'s ABS tree is empty, skipping" "${_repo}"
+ break
+ fi
+
+ # Find all pkgnames on repos
+ on_repo=($(
+ find "${FTP_BASE}/${_repo}" -name "*.pkg.tar.?z" \
+ -printf "%f\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+-[^-]\+$/\1/"
+ ))
+
+ # Compares them, whatever is on repos but not on abs should be removed
+ remove=($(comm -13 \
+ <(printf '%s\n' "${on_abs[@]}" | sort -u) \
+ <(printf '%s\n' "${on_repo[@]}" | sort -u) ))
+
+ # Remove them from databases, ftpdir-cleanup will take care of the rest
+ find "${FTP_BASE}/${_repo}" -name "*.db.tar.?z" \
+ -exec repo-remove {} "${remove[@]}" \; >/dev/null 2>&1
+
+ msg2 "Removed the following packages:"
+ plain '%s' "${remove[@]}"
+done