summaryrefslogtreecommitdiff
authortille <tille>2002-04-24 09:33:16 (UTC)
committer tille <tille>2002-04-24 09:33:16 (UTC)
commit8f67324fd1a60c165ae7043b9457f911b9690e43 (patch) (side-by-side diff)
tree89956792ee33b839a463082e8a43bd1d919afaf9
parentd3fe6dead3c84f1cd94b913c3c6c8657485d70a1 (diff)
downloadopie-8f67324fd1a60c165ae7043b9457f911b9690e43.zip
opie-8f67324fd1a60c165ae7043b9457f911b9690e43.tar.gz
opie-8f67324fd1a60c165ae7043b9457f911b9690e43.tar.bz2
fixed: ipkg c version issues
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO1
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp36
2 files changed, 33 insertions, 4 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index d81e873..c53ca93 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,10 +1,11 @@
* search
* Settings Class
* make oipkg determine dest of "to remove" apps
* tr() ;)
* Dialog to display ipkg output live
* parse "to install" and "to remove" from status
* install local file
* install to dest with click on packet
+* qcop
* error handling
* manage links
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 681f2d4..94ca824 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,219 +1,247 @@
#include "pmipkg.h"
#include "pkdesc.h"
#include "pkfind.h"
#include "pksettings.h"
#include "package.h"
#include "packagelistitem.h"
#include <qpe/process.h>
#include <qpe/resource.h>
+#include <qpe/config.h>
#include <qpe/stringutil.h>
#include <qpe/qcopenvelope_qws.h>
#include <qdir.h>
#include <qfile.h>
#include <qmultilineedit.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <stdlib.h>
#include <unistd.h>
#include "mainwindow.h"
#include "runwindow.h"
+#define PARSE_FILELIST
+// #define IPKG_FILELIST
+
PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
// : RunWindow ( p, name, f )
: QObject ( p )
{
settings = s;
runwindow = new RunWindow ( p, name, f );
linkDest = new QCopChannel( "QPE/MakeLinks", this );
connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(linkDestination( const QString &, const QByteArray&)) );
}
PmIpkg::~PmIpkg()
{
}
//#define PROC
#define SYSTEM
int PmIpkg::runIpkg(const QString& args)
{
pvDebug(2,"PmIpkg::runIpkg "+args);
#ifdef PROC
QStringList cmd = "/usr/bin/ipkg ";
#endif
#ifdef SYSTEM
QString cmd = "/usr/bin/ipkg ";
#endif
cmd += " -dest "+settings->getDestinationName();
cmd += " -force-defaults ";
- out( "Starting to "+ args+"<br>\n");
+ out( "<hr><br>Starting to "+ args+"<br>\n");
cmd += args;
out( "running:<br>\n"+cmd+"<br>\n" );
int r = 0;
#ifdef PROC
QString o = "start";
Process ipkg( cmd );
QString description;
ipkg.exec("",o);
out( o );
#endif
#ifdef SYSTEM
QString redirect = "/tmp/oipkg.pipe";
cmd += " | tee "+redirect+" 2>&1";
+ pvDebug(2, "running >"+cmd+"<");
r = system(cmd.latin1());
QFile f( redirect );
while ( ! f.open(IO_ReadOnly) ) {};
// if ( f.open(IO_ReadOnly) ) {};
{
QTextStream t( &f );
QString fp;
while ( !t.eof() )
{
out( t.readLine() +"<br>" );
}
}
f.close();
out( "Finished!<br>");
#endif
return r;
}
-void PmIpkg::makeLinks(QString file)
+void PmIpkg::makeLinks(QString pack)
{
+ pvDebug( 2, "PmIpkg::makeLinks "+ pack);
out( "<br>creating links<br>" );
QString dest = settings->getDestinationUrl();
- out("for package "+file+" in "+dest+"<br>");
- system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe 2>&1").latin1());
+ out("for package "+pack+" in "+dest+"<br>");
+#ifdef IPKG_FILELIST
+ system(("ipkg -d "+dest+" files "+pack+"> /tmp/oipkg.pipe 2>&1").latin1());
QFile f( "/tmp/oipkg.pipe" );
while ( ! f.open(IO_ReadOnly) ) {};
+#endif
+#ifdef PARSE_FILELIST
+ {
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Common" );
+ QString statusDir = cfg.readEntry( "statusDir", "" );
+ }
+ QString fn = dest+"/"+statusDir+"/info/"+pack+".list";
+ QFile f( fn );
+ if ( ! f.open(IO_ReadOnly) )
+ {
+ out( "<b>Panik!</b> Could not open:<br>"+fn );
+ };
+#endif
QTextStream t( &f );
QString fp;
while ( !t.eof() )
{
fp = t.readLine();
processLinkDir( fp, dest );
}
f.close();
}
void PmIpkg::processLinkDir( QString file, QString dest )
{
+
+#ifdef PARSE_FILELIST
+ QString destFile = file;
+ file = dest+"/"+file;
+#endif
+#ifdef IPKG_FILELIST
QString destFile = file.right( file.length() - dest.length() );
+#endif
QFileInfo fileInfo( file );
if ( fileInfo.isDir() )
{
QDir destDir( destFile );
destDir.mkdir( destFile, true );
QDir d( file );
d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) )
{
out( "<b>"+fi->absFilePath()+"</b>" );
processLinkDir( fi->absFilePath(), dest );
++it;
}
} else
if ( fileInfo.isFile() )
{
const char *instFile = strdup( (file).ascii() );
const char *linkFile = strdup( (destFile).ascii());
out( "linking: "+file+" -> "+destFile );
qDebug( "linking: %s -> %s", instFile, linkFile );
symlink( instFile, linkFile );
}
}
void PmIpkg::commit( PackageList pl )
{
runwindow->showMaximized();
// exec();
runwindow->outPut->setText("");
out( "<h1>Starting...</h1><br>\n");
QStringList to_remove, to_install;
QString rem="<b>To remove:</b><br>\n";
QString inst="<b>To install:</b><br>\n";;
for( Package *pack = pl.first();pack ; (pack = pl.next()) )
{
if ( pack && (pack->name() != "") && pack)
{
if ( pack->toInstall() )
{
to_install.append( pack->name() );
inst += pack->name()+"<br>";
}
if ( pack->toRemove() )
{
to_remove.append( pack->name() );
rem += pack->name()+"<br>";
}
}
}
out("<p>"+inst+"</p>"+"<p>"+rem+"</p>");
bool ok=TRUE;
qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count());
int jobs = to_remove.count()+to_install.count();
if ( jobs < 1 ) return;
if ( to_remove.count() )
for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it)
if ( runIpkg("remove " + *it) != 0 ) ok = false;
if ( to_install.count() )
for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it)
{
if ( runIpkg("install " + *it) == 0 )
{
if ( settings->createLinks() )
makeLinks( *it );
}else{
ok = false;
}
}
// ##### If we looked in the list of files, we could send out accurate
// ##### messages. But we don't bother yet, and just do an "all".
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
}
void PmIpkg::linkDestination( const QString msg, const QByteArray dest )
// add 3rd package parameter
{
qDebug("msg="+msg+" -- "+QString(dest) );
// QDir d( src );
// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
//// if (! d.exists() ) return;
// const QFileInfoList *list = d.entryInfoList();
// QFileInfoListIterator it( *list );
// QFileInfo *fi;
// while ( (fi=it.current()) ) {
// processLinkDir( fi->absFilePath(), dest );
// ++it;
// }
}
void PmIpkg::update()
{
runwindow->showMaximized();
runIpkg( "update" );
}
void PmIpkg::out( QString o )
{
runwindow->outPut->setText( runwindow->outPut->text()+o );
runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight());
}