-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 67 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.h | 17 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 23 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 4 |
5 files changed, 136 insertions, 63 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index b92a245..bbb0be75 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -31,9 +31,9 @@ #include "destination.h" #include "installdlgimpl.h" #include "global.h" -InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) +InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) : InstallDlg( parent, name, modal, fl ) { upgradePackages = false; dataMgr = dataManager; @@ -45,9 +45,10 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM cfg.setGroup( "settings" ); defaultDest = cfg.readEntry( "dest", "root" ); // Grab flags - Turn MAKE_LINKS on by default (if no flags found) - flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); +// flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); + flags = 0; #else flags = 0; #endif @@ -69,30 +70,30 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM } destination->setCurrentItem( defIndex ); - vector<QString>::iterator it; + vector<InstallData>::iterator it; // setup package data QString remove = "Remove\n"; QString install = "\nInstall\n"; QString upgrade = "\nUpgrade\n"; for ( it = packageList.begin() ; it != packageList.end() ; ++it ) { - QString name = *it; - if ( name.startsWith( "I" ) ) + InstallData item = *it; + if ( item.option == "I" ) { - installList.push_back( name.mid(1) ); - install += " " + name.mid(1) + "\n"; + installList.push_back( item ); + install += " " + item.packageName + "\n"; } - else if ( name.startsWith( "D" ) ) + else if ( item.option == "D" ) { - removeList.push_back( name.mid(1) ); - remove += " " + name.mid(1) + "\n"; + removeList.push_back( item ); + remove += " " + item.packageName + "\n"; } - else if ( name.startsWith( "U" ) ) + else if ( item.option == "U" ) { - updateList.push_back( name.mid(1) ); - upgrade += " " + name.mid(1) + "\n"; + updateList.push_back( item ); + upgrade += " " + item.packageName + "\n"; } } output->setText( remove + install + upgrade ); @@ -135,10 +136,8 @@ void InstallDlgImpl :: optionsSelected() if ( opt.forceRemove->isChecked() ) flags |= FORCE_REMOVE; if ( opt.forceOverwrite->isChecked() ) flags |= FORCE_OVERWRITE; - if ( opt.makeLinks->isChecked() ) - flags |= MAKE_LINKS; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); @@ -170,8 +169,11 @@ void InstallDlgImpl :: installSelected() output->setText( "" ); Destination *d = dataMgr->getDestination( destination->currentText() ); QString dest = d->getDestinationName(); QString destDir = d->getDestinationPath(); + int instFlags = 0; + if ( d->linkToRoot() ) + instFlags = MAKE_LINKS; #ifdef QWS // Save settings Config cfg( "aqpkg" ); @@ -179,31 +181,50 @@ void InstallDlgImpl :: installSelected() cfg.writeEntry( "dest", dest ); #endif // First run through the remove list, then the install list then the upgrade list - vector<QString>::iterator it; + vector<InstallData>::iterator it; ipkg.setOption( "remove" ); - ipkg.setDestination( dest ); - ipkg.setDestinationDir( destDir ); - ipkg.setFlags( flags ); for ( it = removeList.begin() ; it != removeList.end() ; ++it ) { - ipkg.setPackage( *it ); + ipkg.setDestination( it->destination->getDestinationName() ); + ipkg.setDestinationDir( it->destination->getDestinationPath() ); + ipkg.setPackage( it->packageName ); + + int tmpFlags = flags; + if ( it->destination->linkToRoot() ) + tmpFlags |= MAKE_LINKS; + else + tmpFlags ^= MAKE_LINKS; + + ipkg.setFlags( tmpFlags ); ipkg.runIpkg(); } ipkg.setOption( "install" ); + ipkg.setDestination( dest ); + ipkg.setDestinationDir( destDir ); + ipkg.setFlags( instFlags ); for ( it = installList.begin() ; it != installList.end() ; ++it ) { - ipkg.setPackage( *it ); + ipkg.setPackage( it->packageName ); ipkg.runIpkg(); } flags |= FORCE_REINSTALL; - ipkg.setFlags( flags ); + ipkg.setOption( "reinstall" ); for ( it = updateList.begin() ; it != updateList.end() ; ++it ) { - ipkg.setPackage( *it ); + ipkg.setDestination( it->destination->getDestinationName() ); + ipkg.setDestinationDir( it->destination->getDestinationPath() ); + ipkg.setPackage( it->packageName ); + + int tmpFlags = flags; + if ( it->destination->linkToRoot() && it->recreateLinks ) + tmpFlags |= MAKE_LINKS; + else + tmpFlags ^= MAKE_LINKS; + ipkg.setFlags( tmpFlags ); ipkg.runIpkg(); } } diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index 8b05c52..3a5d8b8 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h @@ -24,12 +24,21 @@ using namespace std; #include "ipkg.h" #include "install.h" +class InstallData +{ +public: + QString option; // I - install, D - delete, U - upgrade + QString packageName; + Destination *destination; + bool recreateLinks; +}; + class InstallDlgImpl : public InstallDlg { public: - InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); + InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); InstallDlgImpl( QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); ~InstallDlgImpl(); bool showDlg(); @@ -38,11 +47,11 @@ public: protected: private: DataManager *dataMgr; - vector<QString> installList; - vector<QString> removeList; - vector<QString> updateList; + vector<InstallData> installList; + vector<InstallData> removeList; + vector<InstallData> updateList; int flags; Ipkg ipkg; bool upgradePackages; diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 6d0edad..02d4258 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp @@ -40,9 +40,9 @@ Ipkg :: Ipkg() Ipkg :: ~Ipkg() { } -// Option is what we are going to do - install, upgrade, download +// Option is what we are going to do - install, upgrade, download, reinstall // package is the package name to install - either a fully qualified path and ipk // file (if stored locally) or just the name of the package (for a network package) // packageName is the package name - (for a network package this will be the same as // package parameter) @@ -88,26 +88,32 @@ bool Ipkg :: runIpkg( ) // to root already. if ( destDir == "/" ) flags ^= MAKE_LINKS; } - } #ifdef X86 cmd += " -f "; cmd += IPKG_CONF; #endif - cmd += " " + option; + + if ( option == "reinstall" ) + cmd += " install"; + else + cmd += " " + option; if ( option != "upgrade" ) cmd += " " + package; cmd += " 2>&1"; + + emit outputText( QString( "Dealing with package " ) + package ); + qApp->processEvents(); // If we are removing packages and make links option is selected // create the links - if ( option == "remove" ) + if ( option == "remove" || option == "reinstall" ) { createLinks = false; if ( flags & MAKE_LINKS ) { @@ -124,9 +130,9 @@ bool Ipkg :: runIpkg( ) dependantPackages->setAutoDelete( true ); ret = executeIpkgCommand( cmd, option ); - if ( option == "install" ) + if ( option == "install" || option == "reinstall" ) { // If we are not removing packages and make links option is selected // create the links createLinks = true; @@ -152,8 +158,9 @@ bool Ipkg :: runIpkg( ) delete dependantPackages; emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") ); + emit outputText( "" ); return ret; } @@ -181,9 +188,9 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) if ( lineStr != lineStrOld ) { //See if we're finished - if ( option == "install" ) + if ( option == "install" || option == "reinstall" ) { // Need to keep track of any dependant packages that get installed // so that we can create links to them as necessary if ( lineStr.startsWith( "Installing " ) ) @@ -241,13 +248,13 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des { QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list"; QFile f( packageFileDir ); - cout << "Try to open " << packageFileDir.latin1() << endl; + cout << "Try to open " << packageFileDir << endl; if ( !f.open(IO_ReadOnly) ) { // Couldn't open from dest, try from / -// cout << "Could not open:" << packageFileDir << endl; + cout << "Could not open:" << packageFileDir << endl; f.close(); packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list"; f.setName( packageFileDir ); diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 6f528a1..ed5bf75 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -203,8 +203,26 @@ void NetworkPackageManager :: serverSelected( int ) text += "*"; } QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); + + if ( it->isInstalled() ) + { + QString destName = ""; + if ( it->getLocalPackage() ) + { + if ( it->getLocalPackage()->getInstalledTo() ) + destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); + } + else + { + if ( it->getInstalledTo() ) + destName = it->getInstalledTo()->getDestinationName(); + } + if ( destName != "" ) + new QCheckListItem( item, QString( "Installed To - " ) + destName ); + } + if ( !it->isPackageStoredLocally() ) new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); else new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); @@ -254,22 +272,15 @@ void NetworkPackageManager :: updateServer() // First, write out ipkg_conf file so that ipkg can use it dataMgr->writeOutIpkgConf(); -// if ( serverName == LOCAL_SERVER ) -// ; -// else if ( serverName == LOCAL_IPKGS ) -// ; -// else - { - QString option = "update"; - QString dummy = ""; - Ipkg ipkg; - connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); - ipkg.setOption( option ); - - ipkg.runIpkg( ); - } + QString option = "update"; + QString dummy = ""; + Ipkg ipkg; + connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); + ipkg.setOption( option ); + + ipkg.runIpkg( ); // Reload data dataMgr->reloadServerData( serversList->currentText() ); serverSelected(-1); @@ -393,25 +404,25 @@ void NetworkPackageManager :: downloadPackage() void NetworkPackageManager :: applyChanges() { - // Disable buttons to stop silly people clicking lots on them :) + stickyOption = ""; // First, write out ipkg_conf file so that ipkg can use it dataMgr->writeOutIpkgConf(); // Now for each selected item // deal with it - vector<QString> workingPackages; + vector<InstallData> workingPackages; for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { - QString p = dealWithItem( item ); - workingPackages.push_back( p ); + InstallData data = dealWithItem( item ); + workingPackages.push_back( data ); } } // do the stuff @@ -436,9 +447,9 @@ void NetworkPackageManager :: applyChanges() // Current rules: // If not installed - install // If installed and different version available - upgrade // If installed and version up to date - remove -QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) +InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); int pos = name.find( "*" ); name.truncate( pos ); @@ -457,31 +468,54 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) - return QString( "I" ) + name; + { + InstallData item; + item.option = "I"; + item.packageName = name; + return item; + } else { - if ( p->getVersion() == p->getInstalledVersion() ) + InstallData item; + item.option = "D"; + item.packageName = name; + if ( p->getInstalledTo() ) + item.destination = p->getInstalledTo(); + else + item.destination = p->getLocalPackage()->getInstalledTo(); + + // Sticky option not implemented yet, but will eventually allow + // the user to say something like 'remove all' + if ( stickyOption == "" ) { QString msgtext; msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); switch( QMessageBox::information( this, "Remove or ReInstall", msgtext, "Remove", "ReInstall" ) ) { case 0: // Try again or Enter - return QString( "D" ) + name; + item.option = "D"; break; case 1: // Quit or Escape - return QString( "U" ) + name; + item.option = "U"; break; } - - // User hit cancel (on dlg - assume remove) - return QString( "D" ) + name; } else - return QString( "U" ) + name; + { +// item.option = stickyOption; + } + + // Check if we are reinstalling the same version + if ( p->getVersion() != p->getInstalledVersion() ) + item.recreateLinks = true; + else + item.recreateLinks = false; + + // User hit cancel (on dlg - assume remove) + return item; } } void NetworkPackageManager :: displayText( const QString &t ) diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 0ae64a6..7efa42c 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h @@ -25,8 +25,9 @@ #include <qlistview.h> #include "datamgr.h" #include "progressdlg.h" +class InstallData; /** NetworkPackageManager is the base class of the project */ class NetworkPackageManager : public QWidget { @@ -58,9 +59,10 @@ private: void initGui(); void setupConnections(); void showProgressDialog( char *initialText ); - QString dealWithItem( QCheckListItem *item ); + InstallData dealWithItem( QCheckListItem *item ); + QString stickyOption; public slots: void serverSelected( int index ); void applyChanges(); |