summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/global.h2
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp115
-rw-r--r--noncore/settings/aqpkg/ipkg.h16
3 files changed, 106 insertions, 27 deletions
diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h
index e1a4ed4..cec9aa5 100644
--- a/noncore/settings/aqpkg/global.h
+++ b/noncore/settings/aqpkg/global.h
@@ -20,3 +20,3 @@
20 20
21#define VERSION_TEXT "AQPkg Version 1.5" 21#define VERSION_TEXT "AQPkg Version 1.6 BETA"
22 22
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index dad34b0..1efe030 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -33,2 +33,4 @@ using namespace std;
33 33
34#include <opie/oprocess.h>
35
34#include "utils.h" 36#include "utils.h"
@@ -57,5 +59,5 @@ bool Ipkg :: runIpkg( )
57 bool ret = false; 59 bool ret = false;
60 QStringList commands;
58 61
59 QDir::setCurrent( "/tmp" ); 62 QDir::setCurrent( "/tmp" );
60 QString cmd = "";
61 63
@@ -63,7 +65,7 @@ bool Ipkg :: runIpkg( )
63 { 65 {
64 cmd += "cd "; 66 commands << "cd ";
65 cmd += runtimeDir; 67 commands << runtimeDir;
66 cmd += " ; "; 68 commands << ";";
67 } 69 }
68 cmd += "ipkg -force-defaults"; 70 commands << "ipkg" << "-force-defaults";
69 71
@@ -71,3 +73,3 @@ bool Ipkg :: runIpkg( )
71 if ( option == "install" ) 73 if ( option == "install" )
72 cmd += " -dest "+ destination; 74 commands << "-dest" << destination;
73 75
@@ -77,11 +79,11 @@ bool Ipkg :: runIpkg( )
77 if ( flags & FORCE_DEPENDS ) 79 if ( flags & FORCE_DEPENDS )
78 cmd += " -force-depends"; 80 commands << "-force-depends";
79 if ( flags & FORCE_REINSTALL ) 81 if ( flags & FORCE_REINSTALL )
80 cmd += " -force-reinstall"; 82 commands << "-force-reinstall";
81 if ( flags & FORCE_REMOVE ) 83 if ( flags & FORCE_REMOVE )
82 cmd += " -force-removal-of-essential-packages"; 84 commands << "-force-removal-of-essential-packages";
83 if ( flags & FORCE_OVERWRITE ) 85 if ( flags & FORCE_OVERWRITE )
84 cmd += " -force-overwrite"; 86 commands << "-force-overwrite";
85 if ( flags & VERBOSE_WGET ) 87 if ( flags & VERBOSE_WGET )
86 cmd += " -verbose_wget"; 88 commands << "-verbose_wget";
87 89
@@ -100,4 +102,4 @@ bool Ipkg :: runIpkg( )
100#ifdef X86 102#ifdef X86
101 cmd += " -f "; 103 commands << "-f";
102 cmd += IPKG_CONF; 104 commands << IPKG_CONF;
103#endif 105#endif
@@ -106,8 +108,7 @@ bool Ipkg :: runIpkg( )
106 if ( option == "reinstall" ) 108 if ( option == "reinstall" )
107 cmd += " install"; 109 commands << "install";
108 else 110 else
109 cmd += " " + option; 111 commands << option;
110 if ( package != "" ) 112 if ( package != "" )
111 cmd += " " + package; 113 commands << package;
112 cmd += " 2>&1";
113 114
@@ -132,4 +133,2 @@ bool Ipkg :: runIpkg( )
132 133
133 emit outputText( cmd );
134
135 // Execute command 134 // Execute command
@@ -138,3 +137,3 @@ bool Ipkg :: runIpkg( )
138 137
139 ret = executeIpkgCommand( cmd, option ); 138 ret = executeIpkgCommand( commands, option );
140 139
@@ -173,3 +172,2 @@ bool Ipkg :: runIpkg( )
173 172
174// emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") );
175 emit outputText( "Finished" ); 173 emit outputText( "Finished" );
@@ -177,2 +175,3 @@ bool Ipkg :: runIpkg( )
177 return ret; 175 return ret;
176
178} 177}
@@ -257,3 +256,71 @@ void Ipkg :: removeStatusEntry()
257 256
257int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option )
258{
259 // OK we're gonna use OProcess to run this thing
260 proc = new OProcess();
261
262 // Connect up our slots
263 connect(proc, SIGNAL(processExited(OProcess *)),
264 this, SLOT( processFinished()));
258 265
266 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
267 this, SLOT(commandStdout(OProcess *, char *, int)));
268
269 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
270 this, SLOT(commandStderr(OProcess *, char *, int)));
271
272 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
273 {
274 qDebug( "%s ", (*it).latin1() );
275 *proc << (*it).latin1();
276 }
277 cout << endl;
278
279 // Start the process going
280 finished = false;
281 if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
282 {
283 emit outputText( QString( "Couldn't start ipkg process" ) );
284 qDebug( "Couldn't start ipkg process!" );
285 }
286
287 // Now wait for it to finish
288 while ( !finished )
289 qApp->processEvents();
290}
291
292void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
293{
294 qDebug("received stdout %d bytes", buflen);
295
296 QString lineStr = buffer;
297 if ( lineStr[buflen-1] == '\n' )
298 buflen --;
299 lineStr = lineStr.left( buflen );
300 emit outputText( lineStr );
301 qDebug(lineStr);
302 buffer[0] = '\0';
303}
304
305void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
306{
307 qDebug("received stderrt %d bytes", buflen);
308
309 QString lineStr = buffer;
310 if ( lineStr[buflen-1] == '\n' )
311 buflen --;
312 lineStr=lineStr.left( buflen );
313 emit outputText( lineStr );
314 buffer[0] = '\0';
315}
316
317void Ipkg::processFinished()
318{
319 delete proc;
320 finished = true;
321}
322
323
324
325/*
259int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 326int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
@@ -322,3 +389,3 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
322} 389}
323 390*/
324 391
@@ -350,6 +417,6 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des
350 f.setName( packageFileDir ); 417 f.setName( packageFileDir );
351// cout << "Try to open " << packageFileDir.latin1() << endl; 418 qDebug( "Try to open %s", packageFileDir.latin1() );
352 if ( ! f.open(IO_ReadOnly) ) 419 if ( ! f.open(IO_ReadOnly) )
353 { 420 {
354 cout << "Could not open:" << packageFileDir << endl; 421 qDebug( "Could not open: %s", packageFileDir );
355 emit outputText( QString( "Could not open :" ) + packageFileDir ); 422 emit outputText( QString( "Could not open :" ) + packageFileDir );
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
index 7099ca7..25bae59 100644
--- a/noncore/settings/aqpkg/ipkg.h
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -27,2 +27,3 @@
27#include <qstring.h> 27#include <qstring.h>
28#include <qstringlist.h>
28#include <qlist.h> 29#include <qlist.h>
@@ -36,2 +37,4 @@
36 37
38class OProcess;
39
37class Ipkg : public QObject 40class Ipkg : public QObject
@@ -54,2 +57,8 @@ signals:
54 57
58public slots:
59 void commandStdout(OProcess*, char *buffer, int buflen);
60 void commandStderr(OProcess*, char *buffer, int buflen);
61 void processFinished();
62
63
55private: 64private:
@@ -60,4 +69,6 @@ private:
60 QString destDir; 69 QString destDir;
61 int flags;
62 QString runtimeDir; 70 QString runtimeDir;
71 OProcess *proc;
72 int flags;
73 bool finished;
63 74
@@ -65,3 +76,3 @@ private:
65 76
66 int executeIpkgCommand( QString &cmd, const QString option ); 77 int executeIpkgCommand( QStringList &cmd, const QString option );
67 void removeStatusEntry(); 78 void removeStatusEntry();
@@ -71,2 +82,3 @@ private:
71 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); 82 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir );
83
72}; 84};