summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/package.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/package.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/package.cpp56
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
@@ -2,6 +2,10 @@
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
@@ -25,28 +29,33 @@ void Package::init( PackageManagerSettings *s )
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
31Package::Package( QStringList pack, PackageManagerSettings *s ) 36Package::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
38Package::Package( QString n, PackageManagerSettings *s ) 42Package::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
45Package::Package( Package *pi ) 55Package::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
@@ -211,12 +220,12 @@ void Package::parsePackage( QStringList pack )
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}
@@ -295,3 +304,28 @@ void Package::setLink(bool b)
295{ 304{
296 _link = b; 305 _link = b;
297} 306}
307
308void 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
327QString Package::getPackageName()
328{
329 if ( _packageName.isEmpty() ) return _name;
330 else return _packageName;
331}