Fail when given invalid package names
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Fri, 4 Dec 2009 00:20:03 +0000 (19:20 -0500)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Tue, 22 Dec 2009 03:09:50 +0000 (22:09 -0500)
Signed-off-by: Michael Spang <mspang@csclub.uwaterloo.ca>
inapt.cc
inapt.h

index 12c75f4..aa36ad2 100644 (file)
--- a/inapt.cc
+++ b/inapt.cc
@@ -193,6 +193,12 @@ int main(int argc, char *argv[]) {
     scanner(&actions);
 
     for (vector<inapt_action>::iterator i = actions.begin(); i < actions.end(); i++) {
+        pkgCache::PkgIterator pkg = cache->FindPkg(i->package);
+        if (pkg.end())
+            fatal("%s:%d: No such package: %s", i->filename, i->linenum, i->package);
+    }
+
+    for (vector<inapt_action>::iterator i = actions.begin(); i < actions.end(); i++) {
         switch(i->action) {
             case inapt_action::INSTALL:
                 DCache->MarkInstall(cache->FindPkg(i->package), true);
diff --git a/inapt.h b/inapt.h
index 73c62ba..d695613 100644 (file)
--- a/inapt.h
+++ b/inapt.h
@@ -5,6 +5,7 @@ struct inapt_action {
     enum action_t { INSTALL, REMOVE, UNSET } action;
     const char *filename;
     int linenum;
+    void *obj;
 };
 
 void scanner(std::vector<inapt_action> *actions);