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,61 +1,70 @@ #include "package.h" #include <qpe/process.h> #include <qpe/stringutil.h> +#include <qfile.h> +#include <qtextstream.h> +#include <stdlib.h> +#include <unistd.h> #include "debug.h" Package::~Package() { } Package::Package( PackageManagerSettings *s ) { init(s); } void Package::init( PackageManagerSettings *s ) { settings = s; _size = ""; _section = ""; _subsection = ""; _shortDesc = ""; _desc = ""; _name = ""; _toProcess = false; _status = ""; - _dest = ""; + _dest = settings->getDestinationName(); + _link = settings->createLinks(); } Package::Package( QStringList pack, PackageManagerSettings *s ) { init(s); parsePackage( pack ); - _toProcess = false; } Package::Package( QString n, PackageManagerSettings *s ) { init(s); - _name = QString( n ); - _toProcess = false; + if ( !QFile::exists( n ) ) + { + _name = QString( n ); + }else{ + parseIpkgFile( n ); + _toProcess = true; + _packageName = QString( n ); + } } Package::Package( Package *pi ) { init(pi->settings); copyValues( pi ); - _toProcess = false; } void Package::setValue( QString n, QString t ) { if ( n == "Status" && installed() ) return; if ( n == "Package" ) { _name = QString( t ); } if ( n == "Installed-Size" ) { @@ -202,30 +211,30 @@ QString Package::subSection() return _subsection; } void Package::parsePackage( QStringList pack ) { if ( pack.isEmpty() ) return; int count = pack.count(); for( int i = 0; i < count; i++ ) { QString line = pack[i]; int sep = line.find( QRegExp(":[\t ]+") ); if ( sep >= 0 ) - { - QString tag = line.left(sep); - QString value = line.mid(sep+2).simplifyWhiteSpace(); - setValue( tag, value ); - }else{ - } + { + QString tag = line.left(sep); + QString value = line.mid(sep+2).simplifyWhiteSpace(); + setValue( tag, value ); + }else{ + } } return; } QString Package::details() { QString status; Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); QString description; if ( ipkg_status.exec("",status) ) { QStringList lines = QStringList::split('\n',status,TRUE); @@ -286,12 +295,37 @@ void Package::setOn() } bool Package::link() { if ( _dest == "root" || (!installed() && !_toProcess) ) return false; return _link; } void Package::setLink(bool b) { _link = b; } + +void Package::parseIpkgFile( QString file) +{ + system("tar xzf "+file+" -C /tmp"); + system("tar xzf /tmp/control.tar.gz -C /tmp"); + QFile f("/tmp/control"); + if ( f.open(IO_ReadOnly) ) + { + QTextStream t( &f ); + QStringList pack; + while ( !t.eof() ) + { + pack << t.readLine(); + } + f.close(); + parsePackage( pack ); + } + +} + +QString Package::getPackageName() +{ + if ( _packageName.isEmpty() ) return _name; + else return _packageName; +} |