Diffstat (limited to 'noncore/unsupported/oipkg/package.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 9f602b5..5f0e5fa 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp | |||
@@ -1,8 +1,12 @@ | |||
1 | #include "package.h" | 1 | #include "package.h" |
2 | 2 | ||
3 | #include <qpe/process.h> | 3 | #include <qpe/process.h> |
4 | #include <qpe/stringutil.h> | 4 | #include <qpe/stringutil.h> |
5 | #include <qfile.h> | ||
6 | #include <qtextstream.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <unistd.h> | ||
5 | 9 | ||
6 | #include "debug.h" | 10 | #include "debug.h" |
7 | 11 | ||
8 | Package::~Package() | 12 | Package::~Package() |
@@ -24,30 +28,35 @@ void Package::init( PackageManagerSettings *s ) | |||
24 | _desc = ""; | 28 | _desc = ""; |
25 | _name = ""; | 29 | _name = ""; |
26 | _toProcess = false; | 30 | _toProcess = false; |
27 | _status = ""; | 31 | _status = ""; |
28 | _dest = ""; | 32 | _dest = settings->getDestinationName(); |
33 | _link = settings->createLinks(); | ||
29 | } | 34 | } |
30 | 35 | ||
31 | Package::Package( QStringList pack, PackageManagerSettings *s ) | 36 | Package::Package( QStringList pack, PackageManagerSettings *s ) |
32 | { | 37 | { |
33 | init(s); | 38 | init(s); |
34 | parsePackage( pack ); | 39 | parsePackage( pack ); |
35 | _toProcess = false; | ||
36 | } | 40 | } |
37 | 41 | ||
38 | Package::Package( QString n, PackageManagerSettings *s ) | 42 | Package::Package( QString n, PackageManagerSettings *s ) |
39 | { | 43 | { |
40 | init(s); | 44 | init(s); |
41 | _name = QString( n ); | 45 | if ( !QFile::exists( n ) ) |
42 | _toProcess = false; | 46 | { |
47 | _name = QString( n ); | ||
48 | }else{ | ||
49 | parseIpkgFile( n ); | ||
50 | _toProcess = true; | ||
51 | _packageName = QString( n ); | ||
52 | } | ||
43 | } | 53 | } |
44 | 54 | ||
45 | Package::Package( Package *pi ) | 55 | Package::Package( Package *pi ) |
46 | { | 56 | { |
47 | init(pi->settings); | 57 | init(pi->settings); |
48 | copyValues( pi ); | 58 | copyValues( pi ); |
49 | _toProcess = false; | ||
50 | } | 59 | } |
51 | 60 | ||
52 | 61 | ||
53 | void Package::setValue( QString n, QString t ) | 62 | void Package::setValue( QString n, QString t ) |
@@ -210,14 +219,14 @@ void Package::parsePackage( QStringList pack ) | |||
210 | { | 219 | { |
211 | QString line = pack[i]; | 220 | QString line = pack[i]; |
212 | int sep = line.find( QRegExp(":[\t ]+") ); | 221 | int sep = line.find( QRegExp(":[\t ]+") ); |
213 | if ( sep >= 0 ) | 222 | if ( sep >= 0 ) |
214 | { | 223 | { |
215 | QString tag = line.left(sep); | 224 | QString tag = line.left(sep); |
216 | QString value = line.mid(sep+2).simplifyWhiteSpace(); | 225 | QString value = line.mid(sep+2).simplifyWhiteSpace(); |
217 | setValue( tag, value ); | 226 | setValue( tag, value ); |
218 | }else{ | 227 | }else{ |
219 | } | 228 | } |
220 | } | 229 | } |
221 | return; | 230 | return; |
222 | } | 231 | } |
223 | 232 | ||
@@ -294,4 +303,29 @@ bool Package::link() | |||
294 | void Package::setLink(bool b) | 303 | void Package::setLink(bool b) |
295 | { | 304 | { |
296 | _link = b; | 305 | _link = b; |
297 | } | 306 | } |
307 | |||
308 | void Package::parseIpkgFile( QString file) | ||
309 | { | ||
310 | system("tar xzf "+file+" -C /tmp"); | ||
311 | system("tar xzf /tmp/control.tar.gz -C /tmp"); | ||
312 | QFile f("/tmp/control"); | ||
313 | if ( f.open(IO_ReadOnly) ) | ||
314 | { | ||
315 | QTextStream t( &f ); | ||
316 | QStringList pack; | ||
317 | while ( !t.eof() ) | ||
318 | { | ||
319 | pack << t.readLine(); | ||
320 | } | ||
321 | f.close(); | ||
322 | parsePackage( pack ); | ||
323 | } | ||
324 | |||
325 | } | ||
326 | |||
327 | QString Package::getPackageName() | ||
328 | { | ||
329 | if ( _packageName.isEmpty() ) return _name; | ||
330 | else return _packageName; | ||
331 | } | ||