From: Heikki Holstila Date: Fri, 20 Aug 2010 12:28:20 +0000 (+0300) Subject: ignore upgrades to pinned packages and warn about install/remove X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=0cd056de74ad46cfcd0cdca7f21a4ea47ff06b14;p=fapman ignore upgrades to pinned packages and warn about install/remove --- diff --git a/TODO.txt b/TODO.txt index 5b46a83..15fb75a 100644 --- 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 diff --git a/aaptinterface.cpp b/aaptinterface.cpp index f900f1c..1a0f046 100644 --- a/aaptinterface.cpp +++ b/aaptinterface.cpp @@ -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_; diff --git a/aaptinterface.h b/aaptinterface.h index 5fce974..2390249 100644 --- a/aaptinterface.h +++ b/aaptinterface.h @@ -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 Binary files a/fapman and b/fapman differ diff --git a/mainwindow.cpp b/mainwindow.cpp index 036d6ee..ddebc48 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -351,7 +351,8 @@ void MainWindow::operationQueueFinished(QList last if( inst.count()>0 ) pkglist += QString("Total download size: %L1 kB
").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 += "
REMOVE:
"; @@ -365,7 +366,7 @@ void MainWindow::operationQueueFinished(QList 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 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 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(); } diff --git a/package.cpp b/package.cpp index 1204101..4757c4d 100644 --- a/package.cpp +++ b/package.cpp @@ -90,7 +90,7 @@ void Package::convertIcon() bool Package::isUpgradeable() { - if( iSection=="user/hidden" ) + if( iSection=="user/hidden" || iPinned ) return false; if( iIsInstalled ) diff --git a/packageview.cpp b/packageview.cpp index 27ac149..1789e32 100644 --- a/packageview.cpp +++ b/packageview.cpp @@ -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();