#!/bin/bash

# Pfad zur distributions-Datei
DIST_FILE="/var/lib/mini-buildd/repositories/ckvsoft/conf/distributions"

# Packages, die überprüft werden sollen
PACKAGES=("sqlite3" "zj-58" "qrk")

# Hole alle Distributionen (Codenames) aus der distributions-Datei
DISTRIBUTIONS=$(grep "Codename:" $DIST_FILE | awk '{print $2}')

# Basisverzeichnis für reprepro
REPO_BASE="/var/lib/mini-buildd/repositories/ckvsoft"

# Für jede Distribution und jedes Paket den reprepro-Befehl ausführen
for DIST in $DISTRIBUTIONS; do
    echo "Processing distribution: $DIST"
    for PACKAGE in "${PACKAGES[@]}"; do
        echo "Checking package: $PACKAGE in distribution: $DIST"
        reprepro --delete -b $REPO_BASE remove $DIST $PACKAGE
	reprepro --delete -b $REPO_BASE removefilter $DIST "Package (== $PACKAGE)"
	reprepro -b $REPO_BASE export $DIST
    done
done
