author | tille <tille> | 2002-07-19 12:44:48 (UTC) |
---|---|---|
committer | tille <tille> | 2002-07-19 12:44:48 (UTC) |
commit | 8a1649fdf89b0bdc09869e0cc7cebe0d40ce1b19 (patch) (side-by-side diff) | |
tree | 80226f49cd3d881d9e5b7eec1cc53ebbe9a46276 | |
parent | c100ad1cb7db849aec5b9baa7df1a88980602688 (diff) | |
download | opie-8a1649fdf89b0bdc09869e0cc7cebe0d40ce1b19.zip opie-8a1649fdf89b0bdc09869e0cc7cebe0d40ce1b19.tar.gz opie-8a1649fdf89b0bdc09869e0cc7cebe0d40ce1b19.tar.bz2 |
fixes bug #131
ipkg commandstring moved to conf file
-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 74 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 6 |
3 files changed, 7 insertions, 75 deletions
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp index c579df8..f989f30 100644 --- a/noncore/unsupported/oipkg/main.cpp +++ b/noncore/unsupported/oipkg/main.cpp @@ -1,26 +1,26 @@ #include "mainwindow.h" #include <qpe/qpeapplication.h> #include <qstring.h> -//#include <qmessagebox.h> +#include <unistd.h> int debugLevel; int main( int argc, char ** argv ) { setpgid(0,0); printf("This is oipkg\n"); printf("$Id$\n"); debugLevel = 2; if (argc > 1) { debugLevel = QString ( argv[1] ).toInt(); qDebug("setting debug level to %i",debugLevel); } QPEApplication a( argc, argv ); MainWindow mw; // if (argc > 2) // QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); a.showMainDocumentWidget( &mw ); return a.exec(); } diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index bffad15..a7deb8f 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,212 +1,158 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "pmipkg.h" #include "pksettings.h" #include "package.h" #include "packagelistitem.h" -#include <opie/oprocess.h> +//#include <opie/oprocess.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/stringutil.h> #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qgroupbox.h> #include <qmultilineedit.h> #include <qstring.h> #include <qcheckbox.h> #include <qtextstream.h> #include <qtextview.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qlayout.h> #include <stdlib.h> #include <unistd.h> #include "mainwindow.h" -//#define OPROCESS PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) : QObject ( p ) { settings = s; runwindow = new RunWindow( p, name, true, f ); -#ifdef OPROCESS - ipkgProcess = new OProcess(); - connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), - this, SLOT(getIpkgOutput(OProcess*,char*,int))); - connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), - this, SLOT(getIpkgOutput(OProcess*,char*,int))); - installDialog = 0; -#endif + Config cfg( "oipkg", Config::User ); + cfg.setGroup( "ipkg" ); + ipkg_cmd = cfg.readEntry( "cmd", "ipkg" ); } PmIpkg::~PmIpkg() { -#ifdef OPROCESS - delete ipkgProcess; -#endif } bool PmIpkg::runIpkg(const QString& args, const QString& dest ) { bool ret=false; QDir::setCurrent("/tmp"); - QString cmd = "/usr/bin/ipkg "; -#ifdef OPROCESS - ipkgProcess->kill(); - ipkgProcess->clearArguments(); - *ipkgProcess << "/usr/bin/ipkg "; - cmd = ""; -#endif + QString cmd = ipkg_cmd; pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if (!args.contains("update")) { if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; if ( installDialog && installDialog->_force_depends ) { if (installDialog->_force_depends->isChecked()) cmd += " -force-depends "; if (installDialog->_force_reinstall->isChecked()) cmd += " -force-reinstall "; if (installDialog->_force_remove->isChecked()) cmd += " -force-removal-of-essential-packages "; } } //!args.contains("update") out( "Starting to "+ args+"\n"); qApp->processEvents(); cmd += args; out( "running:\n"+cmd+"\n" ); pvDebug(2,"running:"+cmd); -#ifdef OPROCESS - *ipkgProcess << args; - out( "running:\n" + cmd); - *ipkgProcess << cmd; - -//debug - delete ipkgProcess; - ipkgProcess = new OProcess(); - ipkgProcess->clearArguments(); - *ipkgProcess << "/bin/ls "; -//debug - QValueList<QCString> a = ipkgProcess->args(); - QValueList<QCString>::Iterator it; - for( it = a.begin(); it != a.end(); ++it ) - { - out( *it ); - cmd += *it; - } - - pvDebug(2,"running:"+cmd); - qApp->processEvents(); -// sleep(1); - ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); - if ( !ret ) { - pvDebug(2,"Could not execute '" + cmd); - out("\nError while executing "+ cmd+"\n\n"); - out("\nError while executing\n\n"); - // return false; - } - - while ( ipkgProcess->isRunning() ) - { - out("."); - pvDebug(7,"wait for oprocess to terminate"); - qApp->processEvents(); - }; -#else qApp->processEvents(); FILE *fp; char line[130]; QString lineStr, lineStrOld; sleep(1); cmd +=" 2>&1"; fp = popen( (const char *) cmd, "r"); if ( fp == NULL ) { qDebug("Could not execute '" + cmd + "'! err=%d", fp); out("\nError while executing "+ cmd+"\n\n"); ret = false; } else { while ( fgets( line, sizeof line, fp) != NULL) { lineStr = line; lineStr=lineStr.left(lineStr.length()-1); //Configuring opie-oipkg...Done if (lineStr.contains("Done")) ret = true; if (lineStr!=lineStrOld) out(lineStr); lineStrOld = lineStr; qApp->processEvents(); } } pclose(fp); -#endif - //out( "Finished!"); pvDebug(2,QString(ret?"success\n":"failure\n")); return ret; } void PmIpkg::makeLinks(Package *pack) { pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); QString pn = pack->name(); linkPackage( pack->packageName(), pack->dest() ); } QStringList* PmIpkg::getList( QString packFileName, QString d ) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; // if (dest == "/" ) return 0; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; QFile f( packFileDir ); qDebug("Try to open %s", packFileDir.latin1()); if ( ! f.open(IO_ReadOnly) ) { out( "Could not open:\n"+packFileDir ); f.close(); packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; f.setName( packFileDir ); qDebug("Try to open %s", packFileDir.latin1()); if ( ! f.open(IO_ReadOnly) ) { qDebug(" Panik! Could not open"+packFileDir); out( "Could not open:\n"+packFileDir+"\n Panik!" ); return (QStringList*)0; } } QStringList *fileList = new QStringList(); QTextStream t( &f ); while ( !t.eof() ) { *fileList += t.readLine(); } f.close(); return fileList; } @@ -448,58 +394,48 @@ void PmIpkg::out( QString o ) void PmIpkg::show() { if (!runwindow->isVisible()) { runwindow->showMaximized(); runwindow->show(); } runwindow->outPut->setText(""); } void PmIpkg::installFile(const QString &fileName, const QString &dest) { to_install.clear(); to_remove.clear(); pvDebug( 2,"PmIpkg::installFile "+ fileName); Package *p = new Package(fileName,settings); if ( dest!="") p->setDest( dest ); to_install.append( p ); commit(); delete p; } void PmIpkg::removeFile(const QString &fileName, const QString &dest) { to_install.clear(); to_remove.clear(); pvDebug( 2,"PmIpkg::removeFile "+ fileName); Package *p = new Package(fileName,settings); if ( dest!="") p->setDest( dest ); to_remove.append( p ); commit(); delete p; } void PmIpkg::clearLists() { to_remove.clear(); to_install.clear(); } -void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) -{ - QString lineStr, lineStrOld; - lineStr = buffer; - lineStr=lineStr.left(buflen); - //Configuring opie-oipkg...Done - if (lineStr!=lineStrOld) - out(lineStr); - lineStrOld = lineStr; -} diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index c84acfa..2f4d6ae 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -1,73 +1,69 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #ifndef PMIPKG_H #define PMIPKG_H - -#include <opie/oprocess.h> #include <qobject.h> #include <qlist.h> #include <qstring.h> #include <qwidget.h> #include "pksettings.h" #include "runwindow.h" #include "packagelist.h" #include "installdialog.h" #include "debug.h" #define createLink 0 #define removeLink 1 class Package; class PmIpkg : public QObject { Q_OBJECT public: PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 ); ~PmIpkg(); int linkOpp; void loadList( PackageList* ); void commit(); void update(); void show(); void clearLists(); public slots: void doIt(); void install(); void remove(); void installFile(const QString &fileName, const QString &dest=""); void removeFile(const QString &fileName, const QString &dest=""); void createLinks( const QString &dest ); void removeLinks( const QString &dest ); -//private slots: - void getIpkgOutput(OProcess *proc, char *buffer, int buflen); private: - OProcess *ipkgProcess; + QString ipkg_cmd; PackageManagerSettings* settings; RunWindow *runwindow; InstallDialog *installDialog; QList<Package> to_remove; QList<Package> to_install; void makeLinks(Package*); void linkPackage( QString, QString ); void processLinkDir( QString , QString ); bool runIpkg(const QString& args, const QString& dest="" ); void out( QString ); QStringList* getList( QString, QString ); void processFileList( QStringList*, QString ); }; #endif |