pyther / upstream_sync

script to help mirror upstream repositories
MIT License
47 stars 16 forks source link

Feature add exclude support for reposync #3

Closed ghost closed 8 years ago

ghost commented 8 years ago

For example, this package is broken in rhn:

gfs2-utils-3.0.12-23.el6.x86_6 FAILED
gfs2-utils-3.0.12-23.el6.x86_64: [Errno 256] No more mirrors to try.
WARNING:root:sync failed: rhel-6-x86_64-os

$ rm /var/repo/yum/rhel/6/x86_64/os/Packages/gfs2-utils-3.0.12-23.el6.x86_64.rpm
rm: remove regular empty file ‘/var/repo/yum/rhel/6/x86_64/os/Packages/gfs2-utils-3.0.12-23.el6.x86_64.rpm’?

Add exclude option:

$ cat /home/repo/config/rhel-6-x86_64.repo | grep exclu -B4 -A1
[rhel-6-x86_64-os]
auth = rhel-6-main
url = https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/os
path = rhel/6/x86_64/os
exclude = gfs2-utils*
createrepo = true

Run with reposync:

...
Removing obsolete gfs2-utils-3.0.12-23.el6.x86_64.rpm
INFO:root:generating package metadata: rhel-6-x86_64-os
...

yum.conf(5)

exclude List of packages to exclude from all repositories, so yum works as if that package was never in  the
              repositories.  This  should be a space separated list.  This is commonly used so a package isn't upgraded or
              installed accidentally, but can be used to remove packages in any way that "yum list"  will  show  packages.
              Shell globs using wildcards (eg. * and ?) are allowed.
pyther commented 8 years ago

@mmyagkov Thanks for the pull request. I have some mixed feelings.

Regarding your particular issue, you should open a support case with Red Hat regarding the missing package. If this was a package such as udev or redhat-release you'd be in trouble! I have experienced this same problem. I have noticed that sometimes running a sync a few times will eventually fetch the package. As a matter of fact, I am currently dealing with this for an openstack repo and rhel-7-supplementary-sprm repo - I have engaged Red Hat.

Outside of this use case, I'm not sure when one would want to exclude packages from Red Hat repositories. I am actually rather surprised that reposync respected the exclude option in the yum config. Did you verify that the gfs2-utils package was not download? I've seen reposync fail to download a package the first time, but a second run results in successful download.

I lean towards not accepting this PR, as I see this as an unnecessary feature, but I could probably be convinced to easily change my mind.

ghost commented 8 years ago

@pyther Thanks for the feedback.

reposync exclude option may be required if you do not use KDE, Gnome, etc.. in production environment . Do not make sense to keep a copy of the full repository, if for understandable reasons, most will never be used.

Example:

$ find . -type f -name 'libreoffice*' | xargs du -sm | awk '{ sum+=$1} END {print sum "M"}'
4979M
$ find . -type f -name 'kde-*' | xargs du -sm | awk '{ sum+=$1} END {print sum "M"}'
2753M
$ find . -type f -name 'gnome-*' | xargs du -sm | awk '{ sum+=$1} END {print sum "M"}'
2026M

p.s. gfs2-utils now is ok.

$ curl --cacert /etc/rhsm/ca/redhat-uep.pem -E cert.pem --key key.pem https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/os/Packages/gfs2-utils-3.0.12-23.el6.x86_64.rpm -o /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  241k  100  241k    0     0  70245      0  0:00:03  0:00:03 --:--:-- 70231
pyther commented 8 years ago

@mmyagkov Thanks for the explanation. I live in a world where disk space is plentiful and I would prefer wasted storage than potentially broken repos, but I realize I'm lucky and can understand where you are coming from. I'll work on merging this in.

ghost commented 8 years ago

@pyther You say as a programmer, and not as a system administrator. I would prefer to work and updated repository here and now, rather than waiting on the RHN fixes. An exception can be removed completely when similar problems of this kind will be removed. Security issues are concerned not only there, where I came from ;)