Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/cleanup-isos
diff options
context:
space:
mode:
Diffstat (limited to 'cleanup-isos')
-rwxr-xr-xcleanup-isos101
1 files changed, 101 insertions, 0 deletions
diff --git a/cleanup-isos b/cleanup-isos
new file mode 100755
index 0000000..5b46a8e
--- /dev/null
+++ b/cleanup-isos
@@ -0,0 +1,101 @@
+#!/bin/bash
+
+# parameters
+MIRROR_DIR="/srv/http/mirror/mirror.archlinux32.org"
+ARCHIVE_DIR="/srv/http/mirror/archive.archlinux32.org/iso"
+
+usage() {
+ >&2 echo ""
+ >&2 echo "cleanup-isos: cleanup mirror and archive ISOs of Archlinux32"
+ >&2 echo ""
+ >&2 echo "possible options:"
+ >&2 echo " -h|--help: show this help and exit."
+ >&2 echo " --mirror-dir where are the ISOs stored on the mirror, default is '$MIRROR_DIR'."
+ >&2 echo " --archive-dir where are the ISOs stored in the archive, default is '$ARCHIVE_DIR'."
+ >&2 echo " -n do not do anything, just print what would be done."
+ [ -z "$1" ] && exit 1 || exit "$1"
+}
+
+# fail on first error
+set -e
+
+# cleanup hook
+tmp_dir="$(mktemp -d)"
+cleanup() {
+ rm -rf --one-file-system "${tmp_dir}"
+}
+trap cleanup EXIT
+
+eval set -- "$(
+ getopt -o hn \
+ --long help \
+ --long mirror-dir: \
+ --long archive-dir: \
+ -n "$(basename "$0")" -- "$@" || \
+ echo usage
+)"
+
+mirror_dir="${MIRROR_DIR}"
+archive_dir="${ARCHIVE_DIR}"
+do_it=1
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ '--mirror-dir')
+ shift
+ mirror_dir="$1"
+ ;;
+ '--archive-dir')
+ shift
+ archive_dir="$1"
+ ;;
+ '-n')
+ do_it=0
+ ;;
+ '--help'|'-h')
+ usage 0
+ ;;
+ '--')
+ shift
+ break
+ ;;
+ *)
+ printf 'Whoops, option "%s" is not yet implemented!\n' "$1" >&2
+ exit 42
+ ;;
+ esac
+ shift
+done
+
+if [ $# -gt 0 ]; then
+ >&2 echo 'Too many arguments.'
+ exit 2
+fi
+
+echo "checking for old isos in '${mirror_dir}'..."
+
+exit 0
+
+#--TODO FROM HERE
+
+ find "${destination}" \( -name 'archlinux32-*' -o -name 'archlinux-*' \) -not -name 'archlinux32-'"${date}"'-*' \
+ | while read -r to_delete; do
+ if diff -q "${to_delete}" "${archive}/iso/${to_delete#${destination}/}" >/dev/null; then
+ rm "${to_delete}"
+ printf '%s\n' "${to_delete}" \
+ | sed '
+ s@^.*/@@
+ s/\./\\./g
+ s@.*@/ \0$/d@
+ '
+ fi
+ done \
+ >> "${tmp_dir}/delete-regex"
+ sed -i -f "${tmp_dir}/delete-regex" "${destination}/sha512sums"
+ sed -i -f "${tmp_dir}/delete-regex" "${destination}/md5sums"
+
+ echo '... done.'
+ ;;
+
+
+