diff --git a/packaging/bin/create-deb-repo.sh b/packaging/bin/create-deb-repo.sh index e26347b5c4e8..4cf102d4a23d 100755 --- a/packaging/bin/create-deb-repo.sh +++ b/packaging/bin/create-deb-repo.sh @@ -19,15 +19,16 @@ _usage="Usage: $0 [s3bucket=${_s3bucket}]" PKGDIR="${1?${_usage}}" # The directory where .deb files are located REPODIR="${2?${_usage}}" # The package repository working directory S3PATH="${3-${_s3bucket}}/deb" -# Number of packages to keep for each architecture, older packages will be deleted. -RETAIN_PKG_COUNT=25 +# Remove packages older than N number of days (730 is roughly ~2 years). +REMOVE_PKG_DAYS=730 log() { - echo "$(date -Iseconds) $*" + echo "$(date -Iseconds) $*" } delete_old_pkgs() { - find "$1" -name '*.deb' -type f | sort -r | tail -n "+$((RETAIN_PKG_COUNT+1))" | xargs -r rm -v + find "$1" -name '*.deb' -type f -daystart -mtime "+${REMOVE_PKG_DAYS}" -print0 | xargs -r0 rm -v + # Remove any dangling .asc files find "$1" -name '*.asc' -type f -print0 | while read -r -d $'\0' f; do if ! [ -r "${f%.*}" ]; then diff --git a/packaging/bin/create-msi-repo.sh b/packaging/bin/create-msi-repo.sh index c237106bf0d7..0eec9818f41b 100755 --- a/packaging/bin/create-msi-repo.sh +++ b/packaging/bin/create-msi-repo.sh @@ -14,15 +14,15 @@ _usage="Usage: $0 [s3bucket=${_s3bucket}]" PKGDIR="${1?${_usage}}" # The directory where .msi files are located REPODIR="${2?${_usage}}" # The package repository working directory S3PATH="${3-${_s3bucket}}/msi" -# Number of packages to keep, older packages will be deleted. -RETAIN_PKG_COUNT=25 +# Remove packages older than N number of days (730 is roughly ~2 years). +REMOVE_PKG_DAYS=730 log() { - echo "$(date -Iseconds) $*" + echo "$(date -Iseconds) $*" } delete_old_pkgs() { - find "$1" -name '*.msi' -type f | sort -r | tail -n "+$((RETAIN_PKG_COUNT+1))" | xargs -r rm -v + find "$1" -name '*.msi' -type f -daystart -mtime "+${REMOVE_PKG_DAYS}" -print0 | xargs -r0 rm -v } sync_to_s3() { diff --git a/packaging/bin/create-rpm-repo.sh b/packaging/bin/create-rpm-repo.sh index 4c7b5416a07f..a55c7ca792a3 100755 --- a/packaging/bin/create-rpm-repo.sh +++ b/packaging/bin/create-rpm-repo.sh @@ -19,15 +19,15 @@ _usage="Usage: $0 [s3bucket=${_s3bucket}]" PKGDIR="${1?${_usage}}" # The directory where .rpm files are located REPODIR="${2?${_usage}}" # The package repository working directory S3PATH="${3-${_s3bucket}}/rpm" -# Number of packages to keep for each architecture, older packages will be deleted. -RETAIN_PKG_COUNT=25 +# Remove packages older than N number of days (730 is roughly ~2 years). +REMOVE_PKG_DAYS=730 log() { echo "$(date -Iseconds) $*" } delete_old_pkgs() { - find "$1" -name '*.rpm' -type f | sort -r | tail -n "+$((RETAIN_PKG_COUNT+1))" | xargs -r rm -v + find "$1" -name '*.rpm' -type f -daystart -mtime "+${REMOVE_PKG_DAYS}" -print0 | xargs -r0 rm -v } sync_to_s3() {