ignore upgrades to pinned packages and warn about install/remove
[fapman] / aaptinterface.cpp
index f900f1c..1a0f046 100644 (file)
@@ -1303,6 +1303,7 @@ void AAptInterface::startPkgListRead()
        }
 
        readBlacklist();
+       readPinnedPackages();
 
        communicateStatusToUi(true, "Operation finished", "Package data read");
        iCanCancel = false;
@@ -1861,6 +1862,37 @@ bool AAptInterface::dateCacheExists()
        return f.exists();
 }
 
+void AAptInterface::readPinnedPackages()
+{
+       QFile f(KAptPreferencesFile);
+       if( !f.exists() )
+               return;
+
+       if( f.open(QIODevice::ReadOnly | QIODevice::Text ) )
+       {
+               qDebug() << "apt preferences exist: reading pinned packages";
+               int pinned_packages = 0;
+               while( !f.atEnd() )
+               {
+                       QString line = f.readLine().trimmed();
+                       if( line.startsWith("Package:") ) {
+                               pinned_packages++;
+                               QString pkg = line.mid(8).trimmed();
+                               Package* pkg_i = iPackagesInstalled.value(pkg,0);
+                               if( pkg_i ) {
+                                       pkg_i->setPinned(true);
+                               }
+                               Package* pkg_a = iPackagesAvailable.value(pkg,0);
+                               if( pkg_a ) {
+                                       pkg_a->setPinned(true);
+                               }
+                       }
+               }
+               f.close();
+               qDebug() << "read" << pinned_packages << "pinned packages";
+       }
+}
+
 bool AAptInterface::loadInstallFiles(QStringList files_)
 {
        qDebug() << files_;