Baptiste AGASSE wrote: % Hi all, % % I've modified "/backend/satellite_tools/reposync.py" to add "filters" % support with dependencies solving (like the "--rpm-list" option of % cobbler) to spacewalk reposync command.
Hi Baptiste, this is good feature, thanks for sharing it. % It add the "--filters" option to reposync eg: --filters "osad rhncfg-* % foo* bar" So the --filters 'xyz*' means to include xyz* packages only; It would be great to have also the opposite option to exclude some packages which can even stack on each other. E.g. spacewalk-repo-sync --exclude=openoffice.org-langpack-* \ --include=openoffice.org-langpack-en-* ... % It allow to download only selected packages from a repository in order % to save disk space, mainly if you use only few packages from it, and % deletes packages already present on your system (in spacewalk server % and on the filesystem) that don't meet any filters (only packages with % the same NVREA) % % TODO: - Search in spacewalk server older versions of packages % downloaded previously that don't match filters and remove them (I will % work on it). - Make it available from web UI in repositories % management part. % % Maybe someone can work on the web UI and the database schema to make % this option available directly from web UI ? (i'm not familiar with % java and oracle DB) % % Any comments are welcome, it's the first time that i'm programming in % python :). % diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py % index 6834adb..0428bb9 100644 % --- a/backend/satellite_tools/reposync.py % +++ b/backend/satellite_tools/reposync.py ... % @@ -132,6 +137,7 @@ class RepoSync: % self.parser.add_option('-t', '--type', action='store', dest='type', help='The type of repo, currently only "yum" is supported', default='yum') % self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation") % self.parser.add_option('-q', '--quiet', action='store_true', dest='quiet', default=False, help="Print no output, still logs output") % + self.parser.add_option('-p', '--filters', action='store_true', dest='filters', help="Synchronize only the packets that meet the filter and their dependencies") action='store_true' means it's True/False option but you likely want return a string (list of patterns) % return self.parser.parse_args() % % def load_plugin(self): % @@ -308,9 +314,43 @@ class RepoSync: % self.regen = True % ... % + def filter_packages(self, filters, packages): % + # Returns 3 lists : selected packages, dependencies, and others % + selected = [] % + dependencies = [] % + others = [] % + for pack in packages: % + # Select all packages that match one filter % + match = False % + for filter_str in filters: % + reg = re.compile("^" + filter_str.replace("*",".*") + "$") % + if reg.match(pack.name): Wouldn't be fnmatch.filter() better/easier to use here? % + match = True % + break % + if match: ... % + % + def package_deps(self, package, packages_list): ... This is yum repo plugin specific code and it would be better to implement it in the plugin itself, i.e. repo_plugins/yum_src.py in this case. Moreover it would be better to call yum's internal depsolver and not reinvent it again. Regards, -- Michael Mráka Satellite Engineering, Red Hat _______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel