]> git.ipfire.org Git - pakfire.git/blobdiff - pakfire/__init__.py
Make option to disable repositories on command line.
[pakfire.git] / pakfire / __init__.py
index 951c8604d8e26529ee2e90d387a465e11544d4ef..81143520322130c245d092c5e280746e8f7e8de3 100644 (file)
@@ -17,14 +17,15 @@ import repository
 import transaction
 
 from constants import *
-from errors import BuildError
+from errors import BuildError, PakfireError
 from i18n import _
 
 __version__ = 0.1
 
 
 class Pakfire(object):
-       def __init__(self, path="/tmp/pakfire", builder=False, configs=[]):
+       def __init__(self, path="/tmp/pakfire", builder=False, configs=[],
+                       disable_repos=None):
                # The path where we are operating in
                self.path = path
 
@@ -59,7 +60,18 @@ class Pakfire(object):
                # Run plugins that implement an initialization method.
                self.plugins.run("init")
 
-               # XXX disable repositories if passed on command line
+               # Disable repositories if passed on command line
+               if disable_repos:
+                       for repo in disable_repos:
+                               self.repos.disable_repo(repo)
+
+               # Check if there is at least one enabled repository.
+               if len(self.repos) < 2:
+                       raise PakfireError, "No repositories were configured."
+
+               # Update all indexes of the repositories (not force) so that we will
+               # always work with valid data.
+               self.repos.update_indexes()
 
        def check_build_mode(self):
                """