# [PKGNG] How to clean up a repository?



## fonz (Sep 10, 2013)

As I am keeping my package repository up to date (I use portmaster to build packages in a jail and export them via HTTP), said repository has been accumulating old versions of an increasing number of packages. Is there an easy pkg command to get rid of those, or does this have to be done manually?


----------



## kpa (Sep 10, 2013)

For the cached packages there is `pkg clean` and the just recently updated ports-mgmt/poudriere-devel has `poudriere pkgclean` to clean up the repository. I haven't checked if the non-devel version has the same pkgclean subcommand yet.


----------



## fonz (Sep 10, 2013)

Unfortunately neither applies. I'm not (currently) using Poudriere and I'm not so much concerned about a local cache of remotely fetched packages either.


----------



## jb_fvwm2 (Sep 11, 2013)

`gnuls -oSr | sort -k 4 | sort -k 8 | [grep -v "t     " ] | lookat`

One can run that in one terminal [if in [cmd=]X[/cmd] ] and page through the list, building a long remove-all-at-once command line in another terminal, periodically, if need be. Does not take too long, and could be more careful (say, if one does not want to remove *all* the old packages) if expedient...


----------



## kpa (Sep 11, 2013)

@fonz asked for an easy way to clean up outdated packages. I don't think you want to go through hundreds of packages manually, no matter how well you present the options.


----------



## SirDice (Sep 11, 2013)

Before I set up poudriere I used to simply make a ZFS snapshot of the package directory and then delete the whole lot. I always started a new build run with a fresh jail so all packages got created anyway. Cleaning out distfiles was done by portmaster and the -d switch.


----------



## iddqd (Sep 14, 2013)

fonz said:
			
		

> As I am keeping my package repository up to date (I use portmaster to build packages in a jail and export them via HTTP), said repository has been accumulating old versions of an increasing number of packages. Is there an easy pkg command to get rid of those, or does this have to be done manually?



`portmaster --clean-packages -y`

That simple


----------



## fonz (Sep 15, 2013)

iddqd said:
			
		

> That simple


Almost. One does need to (re)move a few files (digests.txz, filesite.txz, packagesite.txz and repo.txz) out of the way that are placed there by `pkg repo ...` and that cause portmaster to bail out with an error message.


----------

