Skip to content

Commit

Permalink
Remove old packages based on time
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Apr 7, 2021
1 parent 00341f2 commit b1486d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
9 changes: 5 additions & 4 deletions packaging/bin/create-deb-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ _usage="Usage: $0 <pkgdir> <repodir> [s3bucket=$***REMOVED***_s3bucket***REMOVED
PKGDIR="$***REMOVED***1?$***REMOVED***_usage***REMOVED******REMOVED***" # The directory where .deb files are located
REPODIR="$***REMOVED***2?$***REMOVED***_usage***REMOVED******REMOVED***" # The package repository working directory
S3PATH="$***REMOVED***3-$***REMOVED***_s3bucket***REMOVED******REMOVED***/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() ***REMOVED***
echo "$(date -Iseconds) $*"
echo "$(date -Iseconds) $*"
***REMOVED***

delete_old_pkgs() ***REMOVED***
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 "+$***REMOVED***REMOVE_PKG_DAYS***REMOVED***" -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 "$***REMOVED***f%.****REMOVED***" ]; then
Expand Down
8 changes: 4 additions & 4 deletions packaging/bin/create-msi-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ _usage="Usage: $0 <pkgdir> <repodir> [s3bucket=$***REMOVED***_s3bucket***REMOVED
PKGDIR="$***REMOVED***1?$***REMOVED***_usage***REMOVED******REMOVED***" # The directory where .msi files are located
REPODIR="$***REMOVED***2?$***REMOVED***_usage***REMOVED******REMOVED***" # The package repository working directory
S3PATH="$***REMOVED***3-$***REMOVED***_s3bucket***REMOVED******REMOVED***/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() ***REMOVED***
echo "$(date -Iseconds) $*"
echo "$(date -Iseconds) $*"
***REMOVED***

delete_old_pkgs() ***REMOVED***
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 "+$***REMOVED***REMOVE_PKG_DAYS***REMOVED***" -print0 | xargs -r0 rm -v
***REMOVED***

sync_to_s3() ***REMOVED***
Expand Down
6 changes: 3 additions & 3 deletions packaging/bin/create-rpm-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ _usage="Usage: $0 <pkgdir> <repodir> [s3bucket=$***REMOVED***_s3bucket***REMOVED
PKGDIR="$***REMOVED***1?$***REMOVED***_usage***REMOVED******REMOVED***" # The directory where .rpm files are located
REPODIR="$***REMOVED***2?$***REMOVED***_usage***REMOVED******REMOVED***" # The package repository working directory
S3PATH="$***REMOVED***3-$***REMOVED***_s3bucket***REMOVED******REMOVED***/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() ***REMOVED***
echo "$(date -Iseconds) $*"
***REMOVED***

delete_old_pkgs() ***REMOVED***
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 "+$***REMOVED***REMOVE_PKG_DAYS***REMOVED***" -print0 | xargs -r0 rm -v
***REMOVED***

sync_to_s3() ***REMOVED***
Expand Down

0 comments on commit b1486d5

Please sign in to comment.