ignore upgrades to pinned packages and warn about install/remove
authorHeikki Holstila <heikki.holstila@gmail.com>
Fri, 20 Aug 2010 12:28:20 +0000 (15:28 +0300)
committerHeikki Holstila <heikki.holstila@gmail.com>
Fri, 20 Aug 2010 12:28:20 +0000 (15:28 +0300)
TODO.txt
aaptinterface.cpp
aaptinterface.h
fapman
mainwindow.cpp
package.cpp
packageview.cpp

index 5b46a83..15fb75a 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -6,8 +6,8 @@
 
 
 0.6.5
-- ignore upgrades for pinned packages
-- warn when trying to do a system upgrade
+* ignore upgrades to pinned packages and warn about install/remove
+* warn when trying to do a system upgrade
 - promote to extras-testing
 
 
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_;
index 5fce974..2390249 100644 (file)
@@ -130,6 +130,7 @@ private:
        void readBlacklist();
        void writeDateCache();
        void readDateCache();
+       void readPinnedPackages();
 
 private slots:
        void errorAptGetUpdate(QProcess::ProcessError error);
diff --git a/fapman b/fapman
index bfc7ef2..8468d29 100755 (executable)
Binary files a/fapman and b/fapman differ
index 036d6ee..ddebc48 100644 (file)
@@ -351,7 +351,8 @@ void MainWindow::operationQueueFinished(QList<AAptInterface::interfaceMode> last
                if( inst.count()>0 )
                        pkglist += QString("Total download size: %L1 kB<br>").arg(total_dl_size);
                bool mismatch = false;
-               bool warn_system_package = false;
+               bool warn_system_package_remove = false;
+               bool warn_system_package_install = false;
 
                if( remv.count()>0 ) {
                        pkglist += "<br><b><u>REMOVE:</u></b><br><font size=\"-1\">";
@@ -365,7 +366,7 @@ void MainWindow::operationQueueFinished(QList<AAptInterface::interfaceMode> last
                                }
 #ifdef Q_WS_MAEMO_5
                                if( pkg && pkg->maemoDisplayName()=="Maemo 5" ) {
-                                       warn_system_package = true;
+                                       warn_system_package_remove = true;
                                }
 #endif
                                if( remvver.count()>i ) {
@@ -401,7 +402,7 @@ void MainWindow::operationQueueFinished(QList<AAptInterface::interfaceMode> last
                                }
 #ifdef Q_WS_MAEMO_5
                                if( pkg && pkg->maemoDisplayName()=="Maemo 5" ) {
-                                       warn_system_package = true;
+                                       warn_system_package_install = true;
                                }
 #endif
                                if( instver.count()>i ) {
@@ -431,10 +432,15 @@ void MainWindow::operationQueueFinished(QList<AAptInterface::interfaceMode> last
                        b.setText("Warning","Blacklisted package(s) will be installed");
                        b.exec();
                }
-               if( warn_system_package ) {
+               if( warn_system_package_remove ) {
                        ConfirmDialog s(false, this);
-                       s.setText("Warning","You are trying to perform an operation on a critical system package. This is an operation which has not been tested and " \
-                                         "it is unknown whether it will succeed or result in a horrible failure. You have been warned.");
+                       s.setText("Warning","You are about to remove a critical system package.");
+                       s.exec();
+               }
+               if( warn_system_package_install ) {
+                       ConfirmDialog s(false, this);
+                       s.setText("Warning","You are trying to perform an install/upgrade operation on a critical system package. Doing a system upgrade with " \
+                                         "Faster Application Manager has not been tested and it could result in a horrible failure. You have been warned.");
                        s.exec();
                }
 
index 1204101..4757c4d 100644 (file)
@@ -90,7 +90,7 @@ void Package::convertIcon()
 
 bool Package::isUpgradeable()
 {
-       if( iSection=="user/hidden" )
+       if( iSection=="user/hidden" || iPinned )
                return false;
 
        if( iIsInstalled )
index 27ac149..1789e32 100644 (file)
@@ -659,6 +659,13 @@ void PackageView::on_listWidget_itemClicked(QListWidgetItem* item)
                        op = Package::PkgOpNone;
        }
 
+       if( pkg->isPinned() && op != Package::PkgOpNone ) {
+               ConfirmDialog d(true, this);
+               d.setText("Warning","Package has been pinned in apt preferences. Operation might not go as expected. Mark anyway?");
+               if( !d.exec() )
+                       op = Package::PkgOpNone;
+       }
+
        pkg->setMarkedForOperation( op );
        item->setData( UserRoleMarked, (int)op );
        updateLabel();