summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-08-11 16:46:56 -0700
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-08-11 16:46:56 -0700
commit71a5b9a8fa9b1e3fca1c9de582317778ed2bc8d2 (patch)
tree6af624fab9425e184f8ce9a4a84d1d321c4de601
parent8c44d7716baf5eb4073863359d1d3e8416842ec1 (diff)
parent986fbe51101674c290df8f5c9d0dc3f507c172e2 (diff)
Merge branch 'master' of http://projects.parabolagnulinux.org/dbscripts into stable
-rw-r--r--cron-jobs/repo-sanity-check46
1 files changed, 46 insertions, 0 deletions
diff --git a/cron-jobs/repo-sanity-check b/cron-jobs/repo-sanity-check
new file mode 100644
index 0000000..a6249b5
--- /dev/null
+++ b/cron-jobs/repo-sanity-check
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Solves issue165
+
+. "$(dirname $0)/../db-functions"
+. "$(dirname $0)/../config"
+
+# Traverse all repos
+for _repo in ${REPOS[@]}; do
+
+# 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
+ ))
+
+# 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 <(echo ${on_abs[@]} | tr ' ' "\n" | sort) \
+ <(echo ${on_repo[@]} | tr ' ' "\n" | sort)))
+
+# Remove them from databases, ftpdir-cleanup will take care of the rest
+ find ${FTP_BASE}/${_repo} -name "*.db.tar.?z" -print0 | \
+ xargs -0 repo-remove {} ${remove[@]}
+
+done
+
+exit $?