Aptly repo purge old versions?

1,845 views
Skip to first unread message

geoff...@york.ac.uk

unread,
Oct 28, 2014, 5:28:40 AM10/28/14
to aptly-...@googlegroups.com
Does anyone have a straightforward method for removing old versions of a package from a local repo? There will be cases where we discover a security flaw in an old release, and just want to delete all but the most recent version.

Cheers, Geoff

Andrey Smirnov

unread,
Oct 28, 2014, 5:30:27 AM10/28/14
to geoff...@york.ac.uk, aptly-...@googlegroups.com
Hi Geoff!

You can do something like:

  aptly repo remove your-repo 'your-package (<<1.2.9)'

Before removing, verify list of packages to be removed:

  aptly repo search your-repo 'your-package (<<1.2.9)'


2014-10-28 12:28 GMT+03:00 <geoff...@york.ac.uk>:
Does anyone have a straightforward method for removing old versions of a package from a local repo?  There will be cases where we discover a security flaw in an old release, and just want to delete all but the most recent version.

Cheers, Geoff

--
You received this message because you are subscribed to the Google Groups "aptly-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aptly-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Andrey Smirnov,
http://smira.ru/

geoff...@york.ac.uk

unread,
Oct 28, 2014, 10:02:15 AM10/28/14
to aptly-...@googlegroups.com, geoff...@york.ac.uk
Thanks, that will work well for getting rid of the old versions.

A related question: it looks like there is no sorting on the output of "aptly repo search your-repo <Query>" Is this something that would be considered as a future enhancement?

Geoff

Andrey Smirnov

unread,
Oct 30, 2014, 2:05:59 AM10/30/14
to geoff...@york.ac.uk, aptly-...@googlegroups.com
I've created issue on result sort: https://github.com/smira/aptly/issues/135

To unsubscribe from this group and stop receiving emails from it, send an email to aptly-discuss+unsubscribe@googlegroups.com.

daniel....@gmail.com

unread,
Aug 28, 2015, 2:35:54 PM8/28/15
to aptly-discuss, geoff...@york.ac.uk
Here's a script that claims to call aptly repo remove once for each
package with older versions that need removing, for a particular
architecture. It relies on gnu sort's -V option, which sorts first by
package name then by package version. It's really ugly, but it illustrates
that "purge old versions" is nontrivial and might be worth adding as a
feature in aptly itself.

#!/bin/sh
set -x
set -e
repo=_my_repo_
arch=amd64

dup=false
for p in `aptly repo search $repo "Architecture ($arch)" | sort -V`
do
pkg=`echo $p | sed 's,_.*,,'`
if test "$pkg" = "$pkg_old"
then
dup=true
elif $dup
then
dup=false
# $p_old is latest version of some package with more than one version
# Output a search spec for all versions older than this
# Version is 2nd field in output of aptly repo search, separated by _
v_old=`echo $p_old | cut -d_ -f2`
aptly repo remove $repo "$pkg_old (<< $v_old) Architecture ($arch)"
fi
p_old="$p"
pkg_old="$pkg"
done

daniel....@gmail.com

unread,
Aug 28, 2015, 2:38:45 PM8/28/15
to aptly-discuss, geoff...@york.ac.uk, daniel....@gmail.com
Reply all
Reply to author
Forward
0 new messages