#!/bin/bash

RPM_DIR=/home/cpanel/RPM
cd "$RPM_DIR"

for version in 11.* easyapache; do
	# Skip anything before the RPM-ification that occurred in 11.36.
	[ "$version" = "11.30" -o "$version" = "11.32" -o "$version" = "11.34" ] && continue

	# Correct the checksums of the files 
	echo "Recalculating checksums for $version:"
	pushd "$version" >/dev/null
	for file in centos/*/* src; do
                echo "  $file"
                (cd $file && md5sum *.rpm > rpm.md5 && sha512sum *.rpm > rpm.sha512 && chown tux: rpm.md5 && chown tux: rpm.sha512)
                /usr/local/scripts/sign-build --key release --files $file/rpm.md5
                /usr/local/scripts/sign-build --key release --files $file/rpm.sha512
                chown tux: $file/rpm.md5.asc
                chown tux: $file/rpm.sha512.asc
	done
	popd >/dev/null
done

# Sync the corrected MD5-sum files
/usr/local/scripts/publish_rpm01
