- for i in [ "add", "help", "list", "quiet", "set" ]:
- if not Cnf.has_key("Natalie::Options::%s" % (i)):
- Cnf["Natalie::Options::%s" % (i)] = "";
- if not Cnf.has_key("Natalie::Options::Component"):
- Cnf["Natalie::Options::Component"] = "main";
- if not Cnf.has_key("Natalie::Options::Suite"):
- Cnf["Natalie::Options::Suite"] = "unstable";
- if not Cnf.has_key("Natalie::Options::Type"):
- Cnf["Natalie::Options::Type"] = "deb";
-
- file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
-
- if Cnf["Natalie::Options::Help"]:
- usage();
-
- projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
- db_access.init(Cnf, projectB);
-
- action = None;
- for i in [ "add", "list", "set" ]:
- if Cnf["Natalie::Options::%s" % (i)]:
- if action:
- utils.fubar("Can not perform more than one action at once.");
- action = i;
-
- (suite, component, type) = (Cnf["Natalie::Options::Suite"], Cnf["Natalie::Options::Component"], Cnf["Natalie::Options::Type"])
-
- if action == "list":
- list(suite, component, type);
+ for i in [ "add", "help", "list", "quiet", "set", "change", "no-action" ]:
+ if not cnf.has_key("Control-Overrides::Options::%s" % (i)):
+ cnf["Control-Overrides::Options::%s" % (i)] = ""
+ if not cnf.has_key("Control-Overrides::Options::Component"):
+ cnf["Control-Overrides::Options::Component"] = "main"
+ if not cnf.has_key("Control-Overrides::Options::Suite"):
+ cnf["Control-Overrides::Options::Suite"] = "unstable"
+ if not cnf.has_key("Control-Overrides::Options::Type"):
+ cnf["Control-Overrides::Options::Type"] = "deb"
+
+ file_list = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
+
+ if cnf["Control-Overrides::Options::Help"]:
+ usage()
+
+ session = DBConn().session()
+
+ mode = None
+ for i in [ "add", "list", "set", "change" ]:
+ if cnf["Control-Overrides::Options::%s" % (i)]:
+ if mode:
+ utils.fubar("Can not perform more than one action at once.")
+ mode = i
+
+ # Need an action...
+ if mode is None:
+ utils.fubar("No action specified.")
+
+ (suite, component, otype) = (cnf["Control-Overrides::Options::Suite"],
+ cnf["Control-Overrides::Options::Component"],
+ cnf["Control-Overrides::Options::Type"])
+
+ if mode == "list":
+ list_overrides(suite, component, otype, session)