summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp67
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h17
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp23
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp88
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h4
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
@@ -23,84 +23,85 @@
#include <qdialog.h>
#include <qcombobox.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#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;
QString defaultDest = "root";
#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 );
QFont f( "helvetica" );
f.setPointSize( 10 );
output->setFont( f );
// setup destination data
int defIndex = 0;
int i;
for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
{
destination->insertItem( dit->getDestinationName() );
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 &)));
}
InstallDlgImpl::InstallDlgImpl( QWidget *parent, const char *name, bool modal, WFlags fl )
: InstallDlg( parent, name, modal, fl )
{
upgradePackages = true;
@@ -127,26 +128,24 @@ void InstallDlgImpl :: optionsSelected()
opt.exec();
// set options selected from dialog
flags = 0;
if ( opt.forceDepends->isChecked() )
flags |= FORCE_DEPENDS;
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
}
void InstallDlgImpl :: installSelected()
{
if ( btnInstall->text() == "Close" )
{
@@ -162,56 +161,78 @@ void InstallDlgImpl :: installSelected()
Ipkg ipkg;
connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
ipkg.setOption( "upgrade" );
ipkg.runIpkg();
}
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" ) );
}
void InstallDlgImpl :: displayText(const QString &text )
{
QString t = output->text() + "\n" + text;
output->setText( t );
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
@@ -16,41 +16,50 @@
***************************************************************************/
#ifndef INSTALLDLGIMPL_H
#define INSTALLDLGIMPL_H
#include <vector>
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 );
void optionsSelected();
void installSelected();
void displayText(const QString &text );
};
#endif
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
@@ -32,25 +32,25 @@ using namespace std;
#include "utils.h"
#include "ipkg.h"
#include "global.h"
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)
// flags is the ipkg options flags
// dir is the directory to run ipkg in (defaults to "")
bool Ipkg :: runIpkg( )
{
bool ret = false;
@@ -80,61 +80,67 @@ bool Ipkg :: runIpkg( )
cmd += " -force-overwrite";
// Handle make links
// Rules - If make links is switched on, create links to root
// if destDir is NOT /
if ( flags & MAKE_LINKS )
{
// 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
- 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 )
{
emit outputText( QString( "Removing symbolic links...\n" ) );
linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
emit outputText( QString( " " ) );
}
}
emit outputText( cmd );
// 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 )
{
emit outputText( " " );
emit outputText( QString( "Creating symbolic links for " )+ package );
linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
// link dependant packages that were installed with this release
@@ -144,24 +150,25 @@ bool Ipkg :: runIpkg( )
if ( *pkg == package )
continue;
emit outputText( " " );
emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
}
}
}
delete dependantPackages;
emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") );
+ emit outputText( "" );
return ret;
}
int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
{
FILE *fp = NULL;
char line[130];
QString lineStr, lineStrOld;
int ret = false;
fp = popen( (const char *) cmd, "r");
@@ -173,25 +180,25 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
emit outputText( text );
}
else
{
while ( fgets( line, sizeof line, fp) != NULL )
{
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;
int start = lineStr.find( " " ) + 1;
int end = lineStr.find( " ", start );
QString *package = new QString( lineStr.mid( start, end-start ) );
dependantPackages->append( package );
cout << "installing dependant package <" << *package << ">" << endl;
}
@@ -233,29 +240,29 @@ void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, cons
qApp->processEvents();
QStringList *fileList = getList( packFileName, destDir );
qApp->processEvents();
processFileList( fileList, destDir );
delete fileList;
}
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) )
{
cout << "Could not open:" << packageFileDir << endl;
emit outputText( QString( "Could not open :" ) + packageFileDir );
return (QStringList*)0;
}
}
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
@@ -195,24 +195,42 @@ void NetworkPackageManager :: serverSelected( int )
text += it->getPackageName();
if ( it->isInstalled() )
{
text += " (installed)";
// 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() );
if ( it->getLocalPackage() )
{
if ( it->isInstalled() )
new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
}
packagesList->insertItem( item );
@@ -246,38 +264,31 @@ void NetworkPackageManager :: updateServer()
// Update the current server
// Display dialog
ProgressDlg *dlg = new ProgressDlg( this );
QString status = "Updating package lists...";
dlg->show();
dlg->setText( status );
// 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( );
- }
+ 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;
}
void NetworkPackageManager :: upgradePackages()
{
// We're gonna do an upgrade of all packages
// First warn user that this isn't recommended
QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
@@ -385,41 +396,41 @@ void NetworkPackageManager :: downloadPackage()
f.remove();
}
}
}
dataMgr->reloadServerData( LOCAL_IPKGS );
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();
// Reload data
dataMgr->reloadServerData( LOCAL_SERVER );
dataMgr->reloadServerData( serversList->currentText() );
serverSelected(-1);
@@ -428,68 +439,91 @@ void NetworkPackageManager :: applyChanges()
// Finally let the main system update itself
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
#endif
}
// 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
pos = name.find( "(installed)" );
if ( pos > 0 )
name.truncate( pos - 1 );
// Get package
Server *s = dataMgr->getServer( serversList->currentText() );
Package *p = s->getPackage( name );
// 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;
}
void NetworkPackageManager :: letterPushed( QString t )
{
QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
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
@@ -17,24 +17,25 @@
#ifndef NETWORKPKGMGR_H
#define NETWORKPKGMGR_H
#include <qlayout.h>
#include <qpushbutton.h>
#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:
/** construtor */
NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0);
/** destructor */
~NetworkPackageManager();
void updateData();
@@ -50,25 +51,26 @@ private:
QPushButton *apply;
ProgressDlg *progressDlg;
QString currentlySelectedServer;
int timerId;
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();
void updateServer();
void displayText( const QString &t );
void letterPushed( QString t );
};
#endif