Delete packages more than 3 versions out of date
This commit is contained in:
parent
0024777b74
commit
9b14a99309
2 changed files with 23 additions and 1 deletions
|
@ -26,6 +26,10 @@ dir_repo="repo";
|
||||||
# The id of the GPG key to use for signing
|
# The id of the GPG key to use for signing
|
||||||
gpg_key_id="7A37B795C20E4651D9BBE1B2D48D801C6A66A5D8";
|
gpg_key_id="7A37B795C20E4651D9BBE1B2D48D801C6A66A5D8";
|
||||||
|
|
||||||
|
# Keep the most recent X versions of packages.
|
||||||
|
# Note that this correctly handles packages that have multiple architectures per version.
|
||||||
|
keep_versions=3;
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Check out the lantern git submodule if needed
|
# Check out the lantern git submodule if needed
|
||||||
|
@ -116,6 +120,8 @@ _symlink_deb() {
|
||||||
}
|
}
|
||||||
|
|
||||||
task_update() {
|
task_update() {
|
||||||
|
tasks_run delete-old;
|
||||||
|
|
||||||
task_begin "Symlinking new packages";
|
task_begin "Symlinking new packages";
|
||||||
package_count_before="$(find ${dir_repo} -name "*.deb" | wc -l)";
|
package_count_before="$(find ${dir_repo} -name "*.deb" | wc -l)";
|
||||||
export -f _symlink_deb;
|
export -f _symlink_deb;
|
||||||
|
@ -170,6 +176,12 @@ task_metafiles() {
|
||||||
# 3. Package description
|
# 3. Package description
|
||||||
__analyse_package() { dpkg --info "$1" | awk '/^\s*Package:/ { gsub("\\s*Package:\\s*", ""); printf($0 "\t"); } /^\s*Version:/ { gsub("\\s*Version:\\s*", ""); printf($0 "\t"); } /^\s*Description:/ { gsub("\\s*Description:\\s*", ""); print($0); }'; };
|
__analyse_package() { dpkg --info "$1" | awk '/^\s*Package:/ { gsub("\\s*Package:\\s*", ""); printf($0 "\t"); } /^\s*Version:/ { gsub("\\s*Version:\\s*", ""); printf($0 "\t"); } /^\s*Description:/ { gsub("\\s*Description:\\s*", ""); print($0); }'; };
|
||||||
|
|
||||||
|
# Spits out a TSV record with 2 columns:
|
||||||
|
# 1. Filename
|
||||||
|
# 2. Package version
|
||||||
|
__analyse_package_simple() { dpkg --info "$1" | awk -v filename="$1" 'BEGIN { printf(filename "\t"); } /^\s*Version:/ { gsub("\\s*Version:\\s*", ""); print($0); }'; };
|
||||||
|
|
||||||
|
|
||||||
_generate_summary() {
|
_generate_summary() {
|
||||||
# xargs: Generate the TSV records in parallel
|
# xargs: Generate the TSV records in parallel
|
||||||
# sort: Sort on the package name, then version (note the 2V does a *version sort* on column 2)
|
# sort: Sort on the package name, then version (note the 2V does a *version sort* on column 2)
|
||||||
|
@ -186,6 +198,16 @@ task_generate-summary() {
|
||||||
task_end "$?";
|
task_end "$?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task_delete-old() {
|
||||||
|
task_begin "Deleting packages more than ${keep_versions} versions ago";
|
||||||
|
# Find and delete old package versions
|
||||||
|
export -f __analyse_package_simple;
|
||||||
|
find sources/ -type f -name "*.deb" -print0 | xargs -0 -n1 -P "$(nproc)" -I{} bash -c '__analyse_package "{}"' | sort -k1,2Vr | uniq | awk -v keep_ago=${keep_versions} '{ package=$1; gsub(/^.*\//, "", package); gsub(/_.*+$/, "", package); arch=$1; gsub(/^.*_/, "", arch); gsub(/\.deb$/, "", arch); counts[package arch]++; if(counts[package arch] > keep_ago) print($1); }' | xargs --verbose rm
|
||||||
|
# Result resultant broken symlinks
|
||||||
|
find "${dir_repo}" -xtype l -delete -print0 | xargs -0 -n1 echo Deleting;
|
||||||
|
task_end "$?";
|
||||||
|
}
|
||||||
|
|
||||||
task_update-cron() {
|
task_update-cron() {
|
||||||
tmpfile="$(mktemp --suffix ".aptosaurus.log")";
|
tmpfile="$(mktemp --suffix ".aptosaurus.log")";
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ sudo apt update</code></pre>
|
||||||
|
|
||||||
<p>A human-readable summary of the packages available in this repository can be found in <a href="/SUMMARY.txt"><code>SUMMARY.txt</code></a>, which is automatically generated from the source packages in the repo.</p>
|
<p>A human-readable summary of the packages available in this repository can be found in <a href="/SUMMARY.txt"><code>SUMMARY.txt</code></a>, which is automatically generated from the source packages in the repo.</p>
|
||||||
|
|
||||||
<p>Note that while older versions of packages <em>do</em> exist in this repository, they are not guaranteed to stick around - as they may be cleared out periodically (todo: automatically clear out packages older than ~2-3 versions behind) to save on disk space.</p>
|
<p>Note that while older versions of packages <em>do</em> exist in this repository, packages more than 3 versions out of date are now automatically deleted to save on disk space. If you need really old versions, download them and keep them as backups ☺</p>
|
||||||
|
|
||||||
<p>Finally, as many CPU architectures will be attempted to be supported here as possible. If binary packages are being released by a project, they are probably packaged here. The exception to this is the 32-bit x86 architecture. This is deprecated by many Linux distributions - so effort is not made to package it here (though if you've got a valid use-case get in touch and I'll see if I can help).</p>
|
<p>Finally, as many CPU architectures will be attempted to be supported here as possible. If binary packages are being released by a project, they are probably packaged here. The exception to this is the 32-bit x86 architecture. This is deprecated by many Linux distributions - so effort is not made to package it here (though if you've got a valid use-case get in touch and I'll see if I can help).</p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue