Don't unnecessarily re-mark packages
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Sun, 13 Dec 2009 03:52:50 +0000 (22:52 -0500)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Tue, 22 Dec 2009 03:11:48 +0000 (22:11 -0500)
Signed-off-by: Michael Spang <mspang@csclub.uwaterloo.ca>
inapt.cc
parser.rl

index 3e6ac19..b4e6102 100644 (file)
--- a/inapt.cc
+++ b/inapt.cc
@@ -244,7 +244,7 @@ static void exec_actions(std::vector<inapt_action *> *final_actions) {
         pkgCache::PkgIterator j = (*i)->pkg;
         switch ((*i)->action) {
             case inapt_action::INSTALL:
-                if (!j.CurVersion() || cachef[j].Delete()) {
+                if (!j.CurrentVer() || cachef[j].Delete()) {
                     printf("preinstall %s %s:%d\n", (*i)->package, (*i)->filename, (*i)->linenum);
                     DCache->MarkInstall(j, true);
                 }
@@ -260,7 +260,7 @@ static void exec_actions(std::vector<inapt_action *> *final_actions) {
         pkgCache::PkgIterator j = (*i)->pkg;
         switch ((*i)->action) {
             case inapt_action::INSTALL:
-                if (!j.CurVersion() || cachef[j].Delete()) {
+                if ((!j.CurrentVer() && !cachef[j].Install()) || cachef[j].Delete()) {
                     printf("install %s %s:%d\n", (*i)->package, (*i)->filename, (*i)->linenum);
                     DCache->MarkInstall(j, false);
                 } else {
@@ -268,8 +268,8 @@ static void exec_actions(std::vector<inapt_action *> *final_actions) {
                 }
                 break;
             case inapt_action::REMOVE:
-                if (j.CurVersion() || cachef[j].Install()) {
-                    printf("remove %s %s:%d %s\n", (*i)->package, (*i)->filename, (*i)->linenum, j.CurVersion());
+                if ((j.CurrentVer() && !cachef[j].Delete()) || cachef[j].Install()) {
+                    printf("remove %s %s:%d\n", (*i)->package, (*i)->filename, (*i)->linenum);
                     DCache->MarkDelete(j, false);
                 } else {
                     //printf("remove %s %s:%d NTD\n", (*i)->package, (*i)->filename, (*i)->linenum);
index af4adbc..b0e070f 100644 (file)
--- a/parser.rl
+++ b/parser.rl
@@ -85,13 +85,12 @@ using namespace std;
     package_list = ((whitespace+ package_name)+ %add_list whitespace*);
     cmd_install = ('install' @install package_list ';');
     cmd_remove = ('remove' @remove package_list ';');
-    simple_cmd = cmd_install | cmd_remove;
     start_block = '{' @start_block;
     end_block = '}' @end_block;
     macro = alpha (alpha | digit | '-' | '+' | '.')*;
     cmd_if = 'if' whitespace+ macro >pkgstart %start_conditional whitespace* start_block whitespace*
              ('else' whitespace* start_block whitespace* ';' @full_conditional | ';' @half_conditional);
-    cmd_list = (simple_cmd | cmd_if | whitespace)* end_block?;
+    cmd_list = (cmd_install | cmd_remove | cmd_if | whitespace)* end_block?;
     main := cmd_list;
 }%%