summaryrefslogtreecommitdiff
authorandyq <andyq>2002-12-20 13:00:05 (UTC)
committer andyq <andyq>2002-12-20 13:00:05 (UTC)
commit48bab4b65417d12dac1e2ef61f9b059fc5dabdcc (patch) (side-by-side diff)
tree0ac43a75511b3b0feed0c357ecc21a31b09c1afa
parent9328bf79f49294e14c1753c9ee17ddd2985c1969 (diff)
downloadopie-48bab4b65417d12dac1e2ef61f9b059fc5dabdcc.zip
opie-48bab4b65417d12dac1e2ef61f9b059fc5dabdcc.tar.gz
opie-48bab4b65417d12dac1e2ef61f9b059fc5dabdcc.tar.bz2
Should create links for installed dependant packages again
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index 7afe04f..29bf40d 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -218,192 +218,207 @@ void Ipkg :: removeStatusEntry()
in.getline( line, 1000 );
if ( in.eof() )
continue;
k[0] = '\0';
v[0] = '\0';
sscanf( line, "%[^:]: %[^\n]", k, v );
key = k;
value = v;
key = key.stripWhiteSpace();
value = value.stripWhiteSpace();
if ( key == "Package" && value == package )
{
// Ignore all lines up to next empty
do
{
in.getline( line, 1000 );
if ( in.eof() || QString( line ).stripWhiteSpace() == "" )
continue;
} while ( !in.eof() && QString( line ).stripWhiteSpace() != "" );
}
lines.push_back( QString( line ) );
// out << line << endl;
} while ( !in.eof() );
// Write lines out
vector<QString>::iterator it;
for ( it = lines.begin() ; it != lines.end() ; ++it )
{
cout << "Writing " << (const char *)(*it) << endl;
out << (const char *)(*it) << endl;
}
in.close();
out.close();
// Remove old status file and put tmp stats file in its place
remove( statusFile );
rename( outStatusFile, statusFile );
}
int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option )
{
// If one is already running - should never be but just to be safe
if ( proc )
{
delete proc;
proc = 0;
}
// OK we're gonna use OProcess to run this thing
proc = new OProcess();
aborted = false;
// Connect up our slots
connect(proc, SIGNAL(processExited(OProcess *)),
this, SLOT( processFinished()));
connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
this, SLOT(commandStdout(OProcess *, char *, int)));
connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
this, SLOT(commandStderr(OProcess *, char *, int)));
for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
{
qDebug( "%s ", (*it).latin1() );
*proc << (*it).latin1();
}
cout << endl;
// Start the process going
finished = false;
if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
{
emit outputText( QString( "Couldn't start ipkg process" ) );
qDebug( "Couldn't start ipkg process!" );
}
// Now wait for it to finish
while ( !finished )
qApp->processEvents();
}
void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
{
qDebug("received stdout %d bytes", buflen);
QString lineStr = buffer;
if ( lineStr[buflen-1] == '\n' )
buflen --;
lineStr = lineStr.left( buflen );
emit outputText( lineStr );
+
+ // check if we are installing dependant packages
+ if ( option == "install" || option == "reinstall" )
+ {
+ // Need to keep track of any dependant packages that get installed
+ // so that we can create links to them as necessary
+ if ( lineStr.startsWith( "Installing " ) )
+ {
+ int start = lineStr.find( " " ) + 1;
+ int end = lineStr.find( " ", start );
+ QString *package = new QString( lineStr.mid( start, end-start ) );
+ dependantPackages->append( package );
+ }
+ }
+
qDebug(lineStr);
buffer[0] = '\0';
}
void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
{
qDebug("received stderrt %d bytes", buflen);
QString lineStr = buffer;
if ( lineStr[buflen-1] == '\n' )
buflen --;
lineStr=lineStr.left( buflen );
emit outputText( lineStr );
buffer[0] = '\0';
}
void Ipkg::processFinished()
{
delete proc;
proc = 0;
finished = true;
}
void Ipkg :: abort()
{
if ( proc )
{
proc->kill();
aborted = true;
}
}
/*
int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
{
FILE *fp = NULL;
char line[130];
QString lineStr, lineStrOld;
int ret = false;
fp = popen( (const char *) cmd, "r");
if ( fp == NULL )
{
cout << "Couldn't execute " << cmd << "! err = " << fp << endl;
QString text;
text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
emit outputText( text );
}
else
{
while ( fgets( line, sizeof line, fp) != NULL )
{
lineStr = line;
lineStr=lineStr.left( lineStr.length()-1 );
if ( lineStr != lineStrOld )
{
//See if we're finished
if ( option == "install" || option == "reinstall" )
{
// Need to keep track of any dependant packages that get installed
// so that we can create links to them as necessary
if ( lineStr.startsWith( "Installing " ) )
{
int start = lineStr.find( " " ) + 1;
int end = lineStr.find( " ", start );
QString *package = new QString( lineStr.mid( start, end-start ) );
dependantPackages->append( package );
}
}
if ( option == "update" )
{
if (lineStr.contains("Updated list"))
ret = true;
}
else if ( option == "download" )
{
if (lineStr.contains("Downloaded"))
ret = true;
}
else
{
if (lineStr.contains("Done"))
ret = true;
}
emit outputText( lineStr );
}
lineStrOld = lineStr;
qApp->processEvents();
}
pclose(fp);
}