- count installs vs upgrades + repackages correctly for progress bar usage
authorpmatilai <pmatilai>
Mon, 31 Jul 2006 17:12:48 +0000 (17:12 +0000)
committerpmatilai <pmatilai>
Mon, 31 Jul 2006 17:12:48 +0000 (17:12 +0000)
- fix progress repackage progress bars

apt-pkg/rpm/rpmpm.cc
apt-pkg/rpm/rpmshowprogress.cc

index c558a9c..efe8116 100644 (file)
@@ -299,12 +299,21 @@ bool pkgRPMPM::Go()
                  break;
               }
            }
+           // This looks backwards but it's supposed to "fix problems where a 
+           // package with a different name is being installed with 
+           // Allow-Duplicated and requires additional dependencies, but there's 
+           // no other package with the same name in the system."
            if (Installed)
               install.push_back(I->File.c_str());
            else
               upgrade.push_back(I->File.c_str());
         } else {
-           upgrade.push_back(I->File.c_str());
+           // perform pure installs on non-installed normal packages, not upgrades
+           if (I->Pkg->CurrentVer != NULL) {
+              upgrade.push_back(I->File.c_str());
+           } else {
+              install.push_back(I->File.c_str());
+           }
         }
         install_or_upgrade.push_back(I->File.c_str());
         pkgs_install.push_back(I->Pkg);
@@ -822,10 +831,10 @@ bool pkgRPMLibPM::Process(vector<const char*> &install,
    if (upgrade.empty() == false)
        AddToTransaction(Item::RPMUpgrade, upgrade);
 
-   // FIXME: This ain't right because most things show up in upgrade 
-   // even if they're really just installs, and repackaging isn't taken
-   // into account either.
    packagesTotal = install.size() + upgrade.size() * 2 + uninstall.size();
+   if (tsFlags & RPMTRANS_FLAG_REPACKAGE) {
+      packagesTotal += upgrade.size() + uninstall.size();
+   }
 
 #if RPM_VERSION >= 0x040100
    if (_config->FindB("RPM::NoDeps", false) == false) {
index 5a09022..7240a87 100644 (file)
@@ -75,6 +75,7 @@ void * rpmpmShowProgress(const void * arg,
     const char * filename = (const char *) pkgKey;
     static FD_t fd = NULL;
     static rpmCallbackType state;
+    static bool repackage;
 
     switch (what) {
     case RPMCALLBACK_INST_OPEN_FILE:
@@ -99,7 +100,7 @@ void * rpmpmShowProgress(const void * arg,
        if (h == NULL || !(flags & INSTALL_LABEL))
            break;
 
-       if (state != what) {
+       if (state != what && repackage == false) {
            state = what;
            fprintf(stdout, "%s\n", _("Installing / Updating..."));
            (void) fflush(stdout);
@@ -138,6 +139,7 @@ void * rpmpmShowProgress(const void * arg,
 
     case RPMCALLBACK_TRANS_START:
        state = what;
+       repackage = false;
        hashesCurrent = 0;
        progressTotal = 1;
        progressCurrent = 0;
@@ -159,8 +161,8 @@ void * rpmpmShowProgress(const void * arg,
 
     case RPMCALLBACK_REPACKAGE_START:
         hashesCurrent = 0;
-        progressTotal = total;
         progressCurrent = 0;
+        repackage = true;
         if (!(flags & INSTALL_LABEL))
             break;
         if (flags & INSTALL_HASH)
@@ -181,14 +183,7 @@ void * rpmpmShowProgress(const void * arg,
         if (flags & INSTALL_HASH)
             printHash(1, 1);    /* Fixes "preparing..." progress bar */
         progressTotal = packagesTotal;
-        progressCurrent = 0;
-        if (!(flags & INSTALL_LABEL))
-            break;
-        if (flags & INSTALL_HASH)
-            fprintf(stdout, "%-28s\n", _("Upgrading..."));
-        else
-            fprintf(stdout, "%s\n", _("Upgrading..."));
-        (void) fflush(stdout);
+        repackage = false;
         break;
 
     case RPMCALLBACK_UNINST_PROGRESS: