summaryrefslogtreecommitdiffstats
path: root/cron-jobs
diff options
context:
space:
mode:
Diffstat (limited to 'cron-jobs')
-rwxr-xr-xcron-jobs/cleanup2.sh46
-rwxr-xr-xcron-jobs/ftpdir-cleanup60
-rwxr-xr-xcron-jobs/genpkglist74
3 files changed, 180 insertions, 0 deletions
diff --git a/cron-jobs/cleanup2.sh b/cron-jobs/cleanup2.sh
new file mode 100755
index 0000000..4a79654
--- /dev/null
+++ b/cron-jobs/cleanup2.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+usage() {
+ echo "Usage: $0 repo architecture"
+}
+
+getpkgname() {
+ local tmp
+
+ tmp=${1##*/}
+ tmp=${tmp%.pkg.tar.gz}
+ tmp=${tmp%-i686}
+ tmp=${tmp%-x86_64}
+ echo ${tmp%-*-*}
+}
+
+FTPBASEDIR="/home/ftp"
+FTPDIR=${FTPBASEDIR}/${1}/os/${2}
+DBFILE=${FTPDIR}/${1}.db.tar.gz
+OBSOLETEFILES=""
+
+if [ $# -lt 2 -o ! -f ${DBFILE} ]; then
+ usage
+ exit 1
+fi
+
+TMPDIR=$(mktemp -d /tmp/cleanup.XXXXXX) || exit 1
+cd ${TMPDIR}
+tar xzf ${DBFILE}
+
+cd ${FTPDIR}
+for pkgfile in *.pkg.tar.gz; do
+ pkgname="$(getpkgname ${pkgfile})"
+ for p in ${FTPDIR}/${pkgname}-*; do
+ if [ "$(getpkgname $(basename ${p}))" = "${pkgname}" ]; then
+ continue 2
+ fi
+ done
+ OBSOLETEFILES="${OBSOLETEFILES} ${pkgfile}"
+done
+
+cd - >/dev/null
+rm -rf ${TMPDIR}
+
+echo -ne "DIRECTORY:\n${FTPDIR}\n\n"
+echo -ne "OBSOLETEFILES:\n${OBSOLETEFILES}\n\n"
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
new file mode 100755
index 0000000..18e26f2
--- /dev/null
+++ b/cron-jobs/ftpdir-cleanup
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+usage() {
+ echo "Usage: $0 repo architecture"
+}
+
+getpkgname() {
+ local tmp
+
+ tmp=${1##*/}
+ tmp=${tmp%.pkg.tar.gz}
+ tmp=${tmp%-i686}
+ tmp=${tmp%-x86_64}
+ echo ${tmp%-*-*}
+}
+
+reponame=$1
+arch=$2
+
+FTPBASEDIR="/home/ftp"
+FTPDIR=${FTPBASEDIR}/$reponame/os/$arch
+DBFILE=${FTPDIR}/$reponame.db.tar.gz
+MISSINGFILES=""
+DELETEFILES=""
+
+if [ $# -lt 2 -o ! -f ${DBFILE} ]; then
+ usage
+ exit 1
+fi
+
+TMPDIR=$(mktemp -d /tmp/cleanup.XXXXXX) || exit 1
+
+cd ${TMPDIR}
+tar xzf ${DBFILE}
+for pkg in *; do
+ filename=$(grep -A1 '^%FILENAME%$' ${pkg}/desc | tail -n1)
+ [ -z "${filename}" ] && filename="${pkg}.pkg.tar.gz"
+ if [ ! -f ${FTPDIR}/${filename} ]; then
+ MISSINGFILES="${MISSINGFILES} ${filename}"
+ else
+ pkgname="$(getpkgname ${filename})"
+ for otherfile in ${FTPDIR}/${pkgname}-*; do
+ otherfile="$(basename ${otherfile})"
+ if [ "${otherfile}" != "${filename}" -a "${pkgname}" = "$(getpkgname ${otherfile})" ]; then
+ DELETEFILES="${DELETEFILES} ${otherfile}"
+ fi
+ done
+ fi
+done
+
+cd - >/dev/null
+rm -rf ${TMPDIR}
+
+echo -ne "DIRECTORY:\n${FTPDIR}\n\n"
+echo -ne "DELETEFILES:\n${DELETEFILES}\n\n"
+echo -ne "MISSINGFILES:\n${MISSINGFILES}\n\n"
+
+cd ${FTPDIR}
+[ -n "${DELETEFILES}" ] && mv ${DELETEFILES} /home/package-cleanup/
+cd - >/dev/null
diff --git a/cron-jobs/genpkglist b/cron-jobs/genpkglist
new file mode 100755
index 0000000..31b7c78
--- /dev/null
+++ b/cron-jobs/genpkglist
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+# genpkglist
+#
+# Generates a text package database for use with the setup script
+# (also used to check for missing packages in the download directory)
+#
+
+# Get the package name from the filename
+# hackish, but should work for now
+getpkgname() {
+ local tmp
+
+ tmp=${1##*/}
+ tmp=${tmp%.pkg.tar.gz}
+ tmp=${tmp%-i686}
+ tmp=${tmp%-x86_64}
+ echo ${tmp%-*-*}
+}
+
+pkgfile="$(pwd)/packages.txt"
+ftppath=$1
+repotag=$2
+
+rm -f $pkgfile
+for package in *; do
+ if [ -d "$package/$repotag/" ]; then
+ cd "$package/$repotag/"
+ if [ -f PKGBUILD ]; then
+ . PKGBUILD
+ if [ -f $ftppath/$pkgname-$pkgver-$pkgrel.pkg.tar.gz ]; then
+ echo "$pkgname-$pkgver-$pkgrel.pkg.tar.gz" >>$pkgfile
+ elif [ -f $ftppath/$pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz ]; then
+ echo "$pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz" >>$pkgfile
+ else
+ echo "notice: Missing $pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz in ftp site" >&2
+ fi
+ fi
+ cd ..
+ fi
+done
+
+cd $ftppath
+unset DUPES DUPEFILES last
+for pkg in *.pkg.tar.gz; do
+ pkgname=$(getpkgname $pkg)
+ if [ "$last" = "$pkgname" ]; then
+ DUPES="$DUPES $pkgname"
+ DUPEFILES="$DUPEFILES $pkg"
+ fi
+ last=$pkgname
+done
+
+showdupes() {
+ done=
+ for i in *.pkg.tar.gz; do
+ pkgname=$(getpkgname $i)
+ if [ "$pkgname" = "$1" ]; then
+ ls -l $i | awk '{print $6" "$7" "$8" "$9}'
+ done=1
+ else
+ [ "$done" = "1" ] && return
+ fi
+ done
+}
+
+if [ "$DUPES" ]; then
+ DUPES=$((for d in $DUPES; do echo $d; done) | sort -u)
+ echo "Possible Dupes for $ftppath (remove old versions)"
+ echo "Date Filename"
+ for dupe in $DUPES; do
+ showdupes $dupe
+ done
+fi