How do I delete old packages in local repository server?
Environment
- Red Hat Enterprise Linux Server (RHEL)
Issue
- On local repository created with the
reposynccommand:- How do I delete the old packages in a repository?
- How to keep only the latest version of packages in a repository?
Resolution
-
Use
repomanage --oldto list older packages, and remove them:# rm -f $(repomanage --old <TARGET_DIR>) -
For AppStream repository, use
repomanage --newto list packages from latest streams, and remove all the others:# find <TARGET_DIR> -type f -name \*.rpm | grep -vf <(repomanage --new <TARGET_DIR>) | xargs -I % rm -v %
SBR
Product(s)
Components
Category
Tags
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.