-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 91 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.h | 3 |
2 files changed, 91 insertions, 3 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 420863c..17efda9 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -143,7 +143,6 @@ void Ipkg :: runIpkg() | |||
143 | dependantPackages->setAutoDelete( true ); | 143 | dependantPackages->setAutoDelete( true ); |
144 | 144 | ||
145 | executeIpkgCommand( commands, option ); | 145 | executeIpkgCommand( commands, option ); |
146 | |||
147 | } | 146 | } |
148 | 147 | ||
149 | void Ipkg :: createSymLinks() | 148 | void Ipkg :: createSymLinks() |
@@ -274,6 +273,64 @@ void Ipkg :: removeStatusEntry() | |||
274 | rename( outStatusFile, statusFile ); | 273 | rename( outStatusFile, statusFile ); |
275 | } | 274 | } |
276 | 275 | ||
276 | int Ipkg :: executeIpkgLinkCommand( QStringList *cmd ) | ||
277 | { | ||
278 | // If one is already running - should never be but just to be safe | ||
279 | if ( proc ) | ||
280 | { | ||
281 | delete proc; | ||
282 | proc = 0; | ||
283 | } | ||
284 | |||
285 | // OK we're gonna use OProcess to run this thing | ||
286 | proc = new OProcess(); | ||
287 | aborted = false; | ||
288 | |||
289 | // Connect up our slots | ||
290 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
291 | this, SLOT( linkProcessFinished())); | ||
292 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | ||
293 | this, SLOT(linkCommandStdout(Opie::Core::OProcess*,char*,int))); | ||
294 | |||
295 | *proc << *cmd; | ||
296 | |||
297 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) | ||
298 | { | ||
299 | emit outputText( tr("Couldn't start ipkg-link process" ) ); | ||
300 | } | ||
301 | } | ||
302 | |||
303 | void Ipkg::linkProcessFinished() | ||
304 | { | ||
305 | // Report that the link process succeeded/failed | ||
306 | |||
307 | if ( error ) | ||
308 | emit outputText( tr("Symbolic linking failed!\n") ); | ||
309 | else | ||
310 | emit outputText( tr("Symbolic linking succeeded.\n") ); | ||
311 | |||
312 | delete proc; | ||
313 | proc = 0; | ||
314 | finished = true; | ||
315 | } | ||
316 | |||
317 | void Ipkg::linkCommandStdout(OProcess*, char *buffer, int buflen) | ||
318 | { | ||
319 | QString lineStr = buffer; | ||
320 | if ( lineStr[buflen-1] == '\n' ) | ||
321 | buflen --; | ||
322 | lineStr = lineStr.left( buflen ); | ||
323 | emit outputText( lineStr ); | ||
324 | |||
325 | if ( lineStr.find( " not found." ) != -1 ) | ||
326 | { | ||
327 | // Capture ipkg-link errors | ||
328 | error = true; | ||
329 | } | ||
330 | |||
331 | buffer[0] = '\0'; | ||
332 | } | ||
333 | |||
277 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | 334 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) |
278 | { | 335 | { |
279 | // If one is already running - should never be but just to be safe | 336 | // If one is already running - should never be but just to be safe |
@@ -383,13 +440,40 @@ void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, cons | |||
383 | if ( dest == "root" || dest == "/" ) | 440 | if ( dest == "root" || dest == "/" ) |
384 | return; | 441 | return; |
385 | 442 | ||
443 | if( option == "remove" || option == "reinstall" || option == "upgrade" ) | ||
444 | { | ||
445 | QStringList commands; | ||
446 | |||
447 | if ( runtimeDir != "" ) | ||
448 | { | ||
449 | commands << "cd "; | ||
450 | commands << runtimeDir; | ||
451 | commands << ";"; | ||
452 | } | ||
453 | commands << "ipkg-link" << "remove" << packFileName; | ||
454 | executeIpkgLinkCommand( &commands ); | ||
455 | } | ||
456 | |||
457 | if( option == "install" || option == "reinstall" || option == "upgrade" ) | ||
458 | { | ||
459 | QStringList commands; | ||
460 | if ( runtimeDir != "" ) | ||
461 | { | ||
462 | commands << "cd "; | ||
463 | commands << runtimeDir; | ||
464 | commands << ";"; | ||
465 | } | ||
466 | commands << "ipkg-link" << "add" << packFileName; | ||
467 | executeIpkgLinkCommand( &commands ); | ||
468 | } | ||
469 | /* | ||
386 | qApp->processEvents(); | 470 | qApp->processEvents(); |
387 | QStringList *fileList = getList( packFileName, destDir ); | 471 | QStringList *fileList = getList( packFileName, destDir ); |
388 | qApp->processEvents(); | 472 | qApp->processEvents(); |
389 | processFileList( fileList, destDir ); | 473 | processFileList( fileList, destDir ); |
390 | delete fileList; | 474 | delete fileList;*/ |
391 | } | 475 | } |
392 | 476 | /* | |
393 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 477 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) |
394 | { | 478 | { |
395 | QString packageFileDir = destDir; | 479 | QString packageFileDir = destDir; |
@@ -519,3 +603,4 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
519 | } | 603 | } |
520 | } | 604 | } |
521 | } | 605 | } |
606 | */ | ||
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h index e216d17..5df63f1 100644 --- a/noncore/settings/aqpkg/ipkg.h +++ b/noncore/settings/aqpkg/ipkg.h | |||
@@ -70,8 +70,10 @@ signals: | |||
70 | void ipkgFinished(); | 70 | void ipkgFinished(); |
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | void linkCommandStdout(Opie::Core::OProcess*, char *buffer, int buflen); | ||
73 | void commandStdout(Opie::Core::OProcess*, char *buffer, int buflen); | 74 | void commandStdout(Opie::Core::OProcess*, char *buffer, int buflen); |
74 | void commandStderr(Opie::Core::OProcess*, char *buffer, int buflen); | 75 | void commandStderr(Opie::Core::OProcess*, char *buffer, int buflen); |
76 | void linkProcessFinished(); | ||
75 | void processFinished(); | 77 | void processFinished(); |
76 | void abort(); | 78 | void abort(); |
77 | 79 | ||
@@ -92,6 +94,7 @@ private: | |||
92 | 94 | ||
93 | QList<QString> *dependantPackages; | 95 | QList<QString> *dependantPackages; |
94 | 96 | ||
97 | int executeIpkgLinkCommand( QStringList *cmd ); | ||
95 | int executeIpkgCommand( QStringList &cmd, const QString option ); | 98 | int executeIpkgCommand( QStringList &cmd, const QString option ); |
96 | void removeStatusEntry(); | 99 | void removeStatusEntry(); |
97 | void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); | 100 | void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); |