How to remove packages more than 3 releases old - clean.sh

Asked by Michael Woods

Hello.

Is there a way to tailor clean.sh to leave the 3 most recent releases of a package intact and remove the packages older than that? I'd like to keep more recent packages on my mirror incase I need to revert.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu apt-mirror Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1
Revision history for this message
Michael Woods (mikeaw2010) said :
#2

By default for apt-mirror it is located in the var directory, in my case: /var/spool/apt-mirror/var/clean.sh

Revision history for this message
Michael Woods (mikeaw2010) said :
#3

After researching further, it looks like apt-mirror itself is what tells clean.sh what packages to remove and clean.sh just hosts the rm -f commands directed at the packages, so I guess what really needs to be done is telling apt-mirror specifically not to include packages on the clean.sh script that are less than 3 releases old. Is there a way to do this?

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

What is the output of:

cat /var/spool/apt-mirror/var/clean.sh

Thanks

Revision history for this message
Michael Woods (mikeaw2010) said :
#5

#!/bin/sh
set -e

cd '/var/spool/apt-mirror/mirror'

echo 'Removing 0 unnecessary files [0 bytes]...'
echo 'done.'
echo

echo 'Removing 0 unnecessary directories...'
echo 'done.'
echo

Revision history for this message
Manfred Hampl (m-hampl) said :
#6

looking into the apt-mirror source, I conclude that a new clean.sh script is created by apt-mirror whenever it runs.

What do you mean by "less than 3 releases old"?
Currently supported releases are 19.04, 18.10 (will be EOL soon), 18.04, 16.04, 14.04 (ESM) and 19.10 (in development), see https://wiki.ubuntu.com/Releases
I expect that a correctly configured apt-mirror system will serve these releases, not more, not less.

Have you already looked into the configuration file /etc/apt/mirror.list ?
Maybe you can fine-tune it to achieve what you want.

Revision history for this message
Michael Woods (mikeaw2010) said :
#7

Sorry for the mis-interpretation.

I mean the releases of the packages that I am mirroring on the local repository to other devices, not the releases of apt-mirror itself. If i understand correctly, apt-mirror uses the postmirror.sh and clean.sh to remove outdated packages that are no longer on the parent repository to keep it from taking too much space.

I checked the mirror.list file but I didn't see anything that could be specified to target older package releases.

Revision history for this message
Manfred Hampl (m-hampl) said :
#8

Are you talking about
Ubuntu releases
or
package versions
?

Revision history for this message
Michael Woods (mikeaw2010) said :
#9

package versions.

Revision history for this message
Manfred Hampl (m-hampl) said :
#10

Sorry, if it is about package versions and not about Ubuntu releases, then I completely misunderstood your question.

It seems to me that the feature that you want (keeping a certain number of older package versions) is not available in apt-mirror.
apt-mirror is replicating central mirror contents, and the logic there is to delete older versions as soon as a new version of a package is published and supersedes the older one.

As already written above: Have you looked into the /etc/apt/mirror.list configuration file? It should be possible to completely disable running of the clean.sh script. Of course then you have to care for manual removal of obsolete versions to avoid running out of space.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#11

The script doesn't do anything so disabling it doesn't really do much.

Revision history for this message
Manfred Hampl (m-hampl) said :
#12

@actionparsnip: This is not true.
The apt-mirror bash script creates a new version of clean.sh whenever it runs.
Currently clean.sh is more or less empty, but at other times it deletes several cached files.

My idea was not disabling the current script, but to disable the function to create and run a new one.

Can you help with this problem?

Provide an answer of your own, or ask Michael Woods for more information if necessary.

To post a message you must log in.