Commit 8c75a754 authored by Seblu's avatar Seblu
Browse files

Add repo cleanup script

parent 81e55355
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ package() {
  # install binaries
  install -m755 atc seblu-build seblu-repo-add aurdown seblu-build-commit \
    seblu-update go2chroot seblu-commit	addpkg sign archbuild-dl pkgbuild2json \
    seblu-remove tmpmakepkg "$pkgdir/usr/bin"
    seblu-remove tmpmakepkg seblu-cleanup "$pkgdir/usr/bin"
  # symlink archbuild
  ln -s archbuild $pkgdir/usr/bin/seblu-i686-build
  ln -s archbuild $pkgdir/usr/bin/seblu-x86_64-build

seblu-cleanup

0 → 100755
+53 −0
Original line number Diff line number Diff line
#!/bin/bash

# Copyright © Sébastien Luttringer
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

db='seblu.db.tar.gz'
repo='/srv/http/archlinux/seblu'
arch=('i686' 'x86_64')

# source makepkg config
. /etc/makepkg.conf

cleanup() {
	[[ -e $dir_file ]] && rm -f "$dir_file"
	[[ -e $db_file ]] && rm -f "$db_file"
}

# remove temp file on exit
trap cleanup 0

# create temporary files for computes diff
dir_file=$(mktemp ${0##*/}.XXXXX)
db_file=$(mktemp ${0##*/}.XXXXX)

# naive implementation without locking
for arch in "${arch[@]}"; do
	[[ -t 1 ]] && echo ":: Cleaning $repo/$arch"
	# list files in directory
	find "$repo/$arch" -type f -name "*${PKGEXT}" -printf '%f\n'|sort > "$dir_file"
	# list files in database
	bsdtar -xOf "$repo/$arch/$db" | awk '/^%FILENAME%/{getline;print}'|sort > "$db_file"
	# compute file not in db
	comm -23 "$dir_file" "$db_file" | while read -r file; do
		rm -v -f "$repo/$arch/$file"{,.sig}
	done
done

exit 0

# vim:set ts=2 sw=2 ft=sh noet: