Download only new RHEL Packages

Latest response

Hi Team,

Our client's RedHat system does not have much space left to store repository packages. It is using a repository system for offline clients.
At first I will erase all the old packets to get some space.
Secondly, is it possible to download only the new packages and news security patches without having to download all of them?

Thanks for your answers
Best regards, J

Responses

On RHEL 8, something like this should work:

mkdir -p Packages
dnf --refresh --enablerepo='*' makecache
dnf -q -C --enablerepo='*' --security repoquery --latest=1 > latest.txt
dnf --enablerepo='*' download --destdir Packages $(cat latest.txt)

To get ALL latest packages, omit the --security flag. Also, adjust --enablerepo and --destdir as needed. Note that dnf should skip downloading files that are already present in the download directory.

Depending on configuration management requirements, the list of packages ("latest.txt") should be version controlled, along with the repository metadata (comps.xml, modules.yaml, etc).

Thanks for your reply and explanations. It will be working for RHEL 7 too?

Best regards, J

I don't have a RHEL 7 system at hand to test, but an equivalent set of command should be possible with yum, repoquery, and yumdownloader.

Hello Jerome,
You could use reposync on RHEL 7 to do that. For example:

reposync --gpgcheck -l --repoid=$REPO --download_path=$DOWNLOADPATH --downloadcomps --download-metadata -d -n

The option '-d' deletes local packages that are no longer available upstream and '-n' downloads only newest packages per repo. I don't think there is an option to download only package version a RHSA exists for.

Maybe using The Poor Man's RHEL Mirror would be an option for you.

Regards,
Joerg