author | andyq <andyq> | 2002-10-17 22:58:36 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-17 22:58:36 (UTC) |
commit | cd48ed3935f1baa6392afee5764d0927abcf62cc (patch) (side-by-side diff) | |
tree | 54423b7242c59457ded23ce0dd1e89ce05b630b1 | |
parent | 4ce3fb5c10a50aece4ef8a78d07ed116ad754c27 (diff) | |
download | opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.zip opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.gz opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.bz2 |
Changed so that installings/removing and upgrading from/to multiple destinations
works better
-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 | 21 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 74 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 4 |
5 files changed, 128 insertions, 55 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 @@ -29,13 +29,13 @@ #include "datamgr.h" #include "instoptionsimpl.h" #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; vector<Destination>::iterator dit; @@ -43,13 +43,14 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM #ifdef QWS Config cfg( "aqpkg" ); 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 // Output text is read only output->setReadOnly( true ); @@ -67,34 +68,34 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM if ( dit->getDestinationName() == defaultDest ) defIndex = i; } 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 ); connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); @@ -133,14 +134,12 @@ void InstallDlgImpl :: optionsSelected() if ( opt.forceReinstall->isChecked() ) flags |= FORCE_REINSTALL; 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" ); cfg.writeEntry( "installFlags", flags ); #endif @@ -168,44 +167,66 @@ void InstallDlgImpl :: installSelected() else { 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" ); cfg.setGroup( "settings" ); 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(); } } btnInstall->setEnabled( true ); btnInstall->setText( tr( "Close" ) ); 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 @@ -22,29 +22,38 @@ using namespace std; #include <qstring.h> #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(); bool upgradeServer( QString &server ); 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; bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 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 @@ -38,13 +38,13 @@ 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) // dest is the destination alias (from ipk.conf) // destDir is the dir that the destination alias points to (used to link to root) @@ -86,30 +86,36 @@ bool Ipkg :: runIpkg( ) { // If destDir == / turn off make links as package is being insalled // to root already. if ( destDir == "/" ) flags ^= MAKE_LINKS; } - } #ifdef X86 cmd += " -f "; cmd += IPKG_CONF; #endif + + 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 ) { emit outputText( QString( "Removing symbolic links...\n" ) ); linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); @@ -122,13 +128,13 @@ bool Ipkg :: runIpkg( ) // Execute command dependantPackages = new QList<QString>; 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; if ( flags & MAKE_LINKS ) { @@ -150,12 +156,13 @@ bool Ipkg :: runIpkg( ) } } delete dependantPackages; emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") ); + emit outputText( "" ); return ret; } int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) { @@ -179,13 +186,13 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) lineStr = line; lineStr=lineStr.left( lineStr.length()-1 ); 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 " ) ) { cout << "LineStr = " << lineStr << endl; @@ -239,17 +246,17 @@ void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, cons QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) { 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 ); // cout << "Try to open " << packageFileDir.latin1() << endl; if ( ! f.open(IO_ReadOnly) ) 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 @@ -201,12 +201,30 @@ void NetworkPackageManager :: serverSelected( int ) // If a different version of package is available, postfix it with an * if ( it->getVersion() != it->getInstalledVersion() ) 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() ); new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); @@ -252,26 +270,19 @@ void NetworkPackageManager :: updateServer() // Disable buttons to stop silly people clicking lots on them :) // 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( ); - } // Reload data dataMgr->reloadServerData( serversList->currentText() ); serverSelected(-1); delete dlg; } @@ -391,29 +402,29 @@ void NetworkPackageManager :: downloadPackage() serverSelected( -1 ); } 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 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); dlg.showDlg(); @@ -434,13 +445,13 @@ void NetworkPackageManager :: applyChanges() // decide what to do - either remove, upgrade or install // 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 ); // if (there is a (installed), remove it @@ -455,35 +466,58 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) 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 ) { cout << t << endl; 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 @@ -23,12 +23,13 @@ #include <qwidget.h> #include <qcombobox.h> #include <qlistview.h> #include "datamgr.h" #include "progressdlg.h" +class InstallData; /** NetworkPackageManager is the base class of the project */ class NetworkPackageManager : public QWidget { Q_OBJECT public: @@ -56,13 +57,14 @@ private: void timerEvent ( QTimerEvent * ); 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(); void upgradePackages(); void downloadPackage(); |