Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added --exclude option to rhnget #23

Open
wants to merge 1 commit into from

2 participants

@ghost

--filter already existed, but that was an inclusive list. --exclude
allows you to exclude certain packages by passing a comma-separated
list of patterns.

@aronparsons aronparsons added --exclude option to rhnget
--filter already existed, but that was an inclusive list.  --exclude
allows you to exclude certain packages by passing a comma-separated
list of patterns.
801f640
@zyv
Collaborator

I guess we can add the options already once we know what we prefer to do.

+1

--filter should probably become --include and the order of the --include/--exclude sequences should match lftp/rsync.

+1

The reason to postpone it was so that we could look at the syntax of the exlude/include format eg. regexp or glob ? comma-separated lists or space-separated lists ? etc...

Good point. Globbing vs. regexp vs. something else is a non-trivial issue indeed.

  • I think lists are redundant, because you can just build a regexp like (a|b|c) if you only want a couple of packages. Need to be careful escaping things though.

  • One thing that I'd like to point out is that if we just remove --filter it will break existing users' configurations.

  • Also if we just tell them that we renamed --filter to --include and use regexps or whatever else instead of globs, confusion will for sure ensue.

  • We can keep --filter and show a deprecation message that it will be soon removed, and if --filter is used, --include / --exclude logic will be disabled or an 'invalid combination of options' error message will be shown straight away.

  • Finally, do we have to deprecate --filter if we go for regexps instead of globs?

@ghost

A space-separated list in the config file seems good. Package names should never have spaces in them, so it seems like a good delimiter.

Regular expressions seem like a good way to go. YUM uses regex for it's exclude list, so it might make it easier for people to just drop their exclude list right into mrepo. I'm not strongly opinionated either way though, as long as I can exclude packages I don't want.

For ordering, are you talking about include or exclude first, or the items in those lists? The latter shouldn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 14, 2011
  1. @aronparsons

    added --exclude option to rhnget

    aronparsons authored
    --filter already existed, but that was an inclusive list.  --exclude
    allows you to exclude certain packages by passing a comma-separated
    list of patterns.
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 2 deletions.
  1. +16 −2 rhnget
View
18 rhnget
@@ -47,6 +47,7 @@ class Options:
self.cleanup = False
self.downloadall = False
self.dryrun = False
+ self.exclude = []
self.filter = None
self.list = None
self.quiet = False
@@ -59,8 +60,8 @@ class Options:
try:
opts, args = getopt.getopt (args, 'hlnqp:r:s:u:v',
- ('delete', 'download-all', 'dry-run', 'filter=', 'help', 'list', 'password=', 'quiet',
- 'release=', 'source', 'systemid=', 'username=', 'verbose', 'version' ))
+ ('delete', 'download-all', 'dry-run', 'exclude=', 'filter=', 'help', 'list', 'password=',
+ 'quiet', 'release=', 'source', 'systemid=', 'username=', 'verbose', 'version' ))
except getopt.error, exc:
print 'rhnget: %s, try rhnget -h for a list of all the options' % str(exc)
sys.exit(1)
@@ -70,6 +71,8 @@ class Options:
self.cleanup = True
elif opt in ('--download-all', ):
self.downloadall = True
+ elif opt in ('--exclude', ):
+ self.exclude = parts = arg.split(',')
elif opt in ('--filter', ):
self.filter = arg
self.downloadall = True
@@ -138,6 +141,7 @@ class Options:
rhnget options:
--delete delete files that are not on the sender side
--download-all download all package versions available
+ --exclude list of packages to exclude based on regexp (e.g., java*bea*,auto-kickstart*)
--filter filter packages based on regexp
-l, --list list the available packages
-n, --dry-run show what would have been done
@@ -413,6 +417,16 @@ def mirrorrhn(url, path):
filename = '%s-%s-%s.%s.rpm' % (pkg[0], pkg[1], pkg[2], pkg[4])
filesize = int(pkg[5])
+ ### Exclude files
+ skip = False
+ for pattern in op.exclude:
+ if fnmatch.fnmatch(filename, pattern):
+ info(4, 'Package %s excluded by %s' % (filename, pattern))
+ skip = True
+ break
+
+ if skip: continue
+
### Filter packagelist
if op.filter and not fnmatch.fnmatch(filename, op.filter):
info(4, 'Packages %s excluded by filter' % filename)
Something went wrong with that request. Please try again.