summaryrefslogtreecommitdiff
authorkergoth <kergoth>2002-11-29 18:58:15 (UTC)
committer kergoth <kergoth>2002-11-29 18:58:15 (UTC)
commit17906c7fefc001c74af2141610c23c28c28a4e52 (patch) (unidiff)
tree527fe02d74b54debefd4f66eb5989e14a6d2d1ba
parentd85d0022270da220f219764593c98dc8f28439b7 (diff)
downloadopie-17906c7fefc001c74af2141610c23c28c28a4e52.zip
opie-17906c7fefc001c74af2141610c23c28c28a4e52.tar.gz
opie-17906c7fefc001c74af2141610c23c28c28a4e52.tar.bz2
Compile fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index 1efe030..407abe9 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -229,297 +229,297 @@ void Ipkg :: removeStatusEntry()
229 do 229 do
230 { 230 {
231 in.getline( line, 1000 ); 231 in.getline( line, 1000 );
232 if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) 232 if ( in.eof() || QString( line ).stripWhiteSpace() == "" )
233 continue; 233 continue;
234 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); 234 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" );
235 } 235 }
236 236
237 lines.push_back( QString( line ) ); 237 lines.push_back( QString( line ) );
238// out << line << endl; 238// out << line << endl;
239 } while ( !in.eof() ); 239 } while ( !in.eof() );
240 240
241 // Write lines out 241 // Write lines out
242 vector<QString>::iterator it; 242 vector<QString>::iterator it;
243 for ( it = lines.begin() ; it != lines.end() ; ++it ) 243 for ( it = lines.begin() ; it != lines.end() ; ++it )
244 { 244 {
245 cout << "Writing " << (const char *)(*it) << endl; 245 cout << "Writing " << (const char *)(*it) << endl;
246 out << (const char *)(*it) << endl; 246 out << (const char *)(*it) << endl;
247 } 247 }
248 248
249 in.close(); 249 in.close();
250 out.close(); 250 out.close();
251 251
252 // Remove old status file and put tmp stats file in its place 252 // Remove old status file and put tmp stats file in its place
253 remove( statusFile ); 253 remove( statusFile );
254 rename( outStatusFile, statusFile ); 254 rename( outStatusFile, statusFile );
255} 255}
256 256
257int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option ) 257int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option )
258{ 258{
259 // OK we're gonna use OProcess to run this thing 259 // OK we're gonna use OProcess to run this thing
260 proc = new OProcess(); 260 proc = new OProcess();
261 261
262 // Connect up our slots 262 // Connect up our slots
263 connect(proc, SIGNAL(processExited(OProcess *)), 263 connect(proc, SIGNAL(processExited(OProcess *)),
264 this, SLOT( processFinished())); 264 this, SLOT( processFinished()));
265 265
266 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 266 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
267 this, SLOT(commandStdout(OProcess *, char *, int))); 267 this, SLOT(commandStdout(OProcess *, char *, int)));
268 268
269 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 269 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
270 this, SLOT(commandStderr(OProcess *, char *, int))); 270 this, SLOT(commandStderr(OProcess *, char *, int)));
271 271
272 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) 272 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
273 { 273 {
274 qDebug( "%s ", (*it).latin1() ); 274 qDebug( "%s ", (*it).latin1() );
275 *proc << (*it).latin1(); 275 *proc << (*it).latin1();
276 } 276 }
277 cout << endl; 277 cout << endl;
278 278
279 // Start the process going 279 // Start the process going
280 finished = false; 280 finished = false;
281 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) 281 if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
282 { 282 {
283 emit outputText( QString( "Couldn't start ipkg process" ) ); 283 emit outputText( QString( "Couldn't start ipkg process" ) );
284 qDebug( "Couldn't start ipkg process!" ); 284 qDebug( "Couldn't start ipkg process!" );
285 } 285 }
286 286
287 // Now wait for it to finish 287 // Now wait for it to finish
288 while ( !finished ) 288 while ( !finished )
289 qApp->processEvents(); 289 qApp->processEvents();
290} 290}
291 291
292void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) 292void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
293{ 293{
294 qDebug("received stdout %d bytes", buflen); 294 qDebug("received stdout %d bytes", buflen);
295 295
296 QString lineStr = buffer; 296 QString lineStr = buffer;
297 if ( lineStr[buflen-1] == '\n' ) 297 if ( lineStr[buflen-1] == '\n' )
298 buflen --; 298 buflen --;
299 lineStr = lineStr.left( buflen ); 299 lineStr = lineStr.left( buflen );
300 emit outputText( lineStr ); 300 emit outputText( lineStr );
301 qDebug(lineStr); 301 qDebug(lineStr);
302 buffer[0] = '\0'; 302 buffer[0] = '\0';
303} 303}
304 304
305void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) 305void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
306{ 306{
307 qDebug("received stderrt %d bytes", buflen); 307 qDebug("received stderrt %d bytes", buflen);
308 308
309 QString lineStr = buffer; 309 QString lineStr = buffer;
310 if ( lineStr[buflen-1] == '\n' ) 310 if ( lineStr[buflen-1] == '\n' )
311 buflen --; 311 buflen --;
312 lineStr=lineStr.left( buflen ); 312 lineStr=lineStr.left( buflen );
313 emit outputText( lineStr ); 313 emit outputText( lineStr );
314 buffer[0] = '\0'; 314 buffer[0] = '\0';
315} 315}
316 316
317void Ipkg::processFinished() 317void Ipkg::processFinished()
318{ 318{
319 delete proc; 319 delete proc;
320 finished = true; 320 finished = true;
321} 321}
322 322
323 323
324 324
325/* 325/*
326int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 326int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
327{ 327{
328 FILE *fp = NULL; 328 FILE *fp = NULL;
329 char line[130]; 329 char line[130];
330 QString lineStr, lineStrOld; 330 QString lineStr, lineStrOld;
331 int ret = false; 331 int ret = false;
332 332
333 fp = popen( (const char *) cmd, "r"); 333 fp = popen( (const char *) cmd, "r");
334 if ( fp == NULL ) 334 if ( fp == NULL )
335 { 335 {
336 cout << "Couldn't execute " << cmd << "! err = " << fp << endl; 336 cout << "Couldn't execute " << cmd << "! err = " << fp << endl;
337 QString text; 337 QString text;
338 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); 338 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
339 emit outputText( text ); 339 emit outputText( text );
340 } 340 }
341 else 341 else
342 { 342 {
343 while ( fgets( line, sizeof line, fp) != NULL ) 343 while ( fgets( line, sizeof line, fp) != NULL )
344 { 344 {
345 lineStr = line; 345 lineStr = line;
346 lineStr=lineStr.left( lineStr.length()-1 ); 346 lineStr=lineStr.left( lineStr.length()-1 );
347 347
348 if ( lineStr != lineStrOld ) 348 if ( lineStr != lineStrOld )
349 { 349 {
350 //See if we're finished 350 //See if we're finished
351 if ( option == "install" || option == "reinstall" ) 351 if ( option == "install" || option == "reinstall" )
352 { 352 {
353 // Need to keep track of any dependant packages that get installed 353 // Need to keep track of any dependant packages that get installed
354 // so that we can create links to them as necessary 354 // so that we can create links to them as necessary
355 if ( lineStr.startsWith( "Installing " ) ) 355 if ( lineStr.startsWith( "Installing " ) )
356 { 356 {
357 int start = lineStr.find( " " ) + 1; 357 int start = lineStr.find( " " ) + 1;
358 int end = lineStr.find( " ", start ); 358 int end = lineStr.find( " ", start );
359 QString *package = new QString( lineStr.mid( start, end-start ) ); 359 QString *package = new QString( lineStr.mid( start, end-start ) );
360 dependantPackages->append( package ); 360 dependantPackages->append( package );
361 } 361 }
362 } 362 }
363 363
364 if ( option == "update" ) 364 if ( option == "update" )
365 { 365 {
366 if (lineStr.contains("Updated list")) 366 if (lineStr.contains("Updated list"))
367 ret = true; 367 ret = true;
368 } 368 }
369 else if ( option == "download" ) 369 else if ( option == "download" )
370 { 370 {
371 if (lineStr.contains("Downloaded")) 371 if (lineStr.contains("Downloaded"))
372 ret = true; 372 ret = true;
373 } 373 }
374 else 374 else
375 { 375 {
376 if (lineStr.contains("Done")) 376 if (lineStr.contains("Done"))
377 ret = true; 377 ret = true;
378 } 378 }
379 379
380 emit outputText( lineStr ); 380 emit outputText( lineStr );
381 } 381 }
382 lineStrOld = lineStr; 382 lineStrOld = lineStr;
383 qApp->processEvents(); 383 qApp->processEvents();
384 } 384 }
385 pclose(fp); 385 pclose(fp);
386 } 386 }
387 387
388 return ret; 388 return ret;
389} 389}
390*/ 390*/
391 391
392void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) 392void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
393{ 393{
394 if ( dest == "root" || dest == "/" ) 394 if ( dest == "root" || dest == "/" )
395 return; 395 return;
396 396
397 qApp->processEvents(); 397 qApp->processEvents();
398 QStringList *fileList = getList( packFileName, destDir ); 398 QStringList *fileList = getList( packFileName, destDir );
399 qApp->processEvents(); 399 qApp->processEvents();
400 processFileList( fileList, destDir ); 400 processFileList( fileList, destDir );
401 delete fileList; 401 delete fileList;
402} 402}
403 403
404QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) 404QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
405{ 405{
406 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list"; 406 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list";
407 QFile f( packageFileDir ); 407 QFile f( packageFileDir );
408 408
409 cout << "Try to open " << packageFileDir << endl; 409 cout << "Try to open " << packageFileDir << endl;
410 if ( !f.open(IO_ReadOnly) ) 410 if ( !f.open(IO_ReadOnly) )
411 { 411 {
412 // Couldn't open from dest, try from / 412 // Couldn't open from dest, try from /
413 cout << "Could not open:" << packageFileDir << endl; 413 cout << "Could not open:" << packageFileDir << endl;
414 f.close(); 414 f.close();
415 415
416 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list"; 416 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list";
417 f.setName( packageFileDir ); 417 f.setName( packageFileDir );
418 qDebug( "Try to open %s", packageFileDir.latin1() ); 418 qDebug( "Try to open %s", packageFileDir.latin1() );
419 if ( ! f.open(IO_ReadOnly) ) 419 if ( ! f.open(IO_ReadOnly) )
420 { 420 {
421 qDebug( "Could not open: %s", packageFileDir ); 421 qDebug( "Could not open: %s", packageFileDir.latin1() );
422 emit outputText( QString( "Could not open :" ) + packageFileDir ); 422 emit outputText( QString( "Could not open :" ) + packageFileDir );
423 return (QStringList*)0; 423 return (QStringList*)0;
424 } 424 }
425 } 425 }
426 QStringList *fileList = new QStringList(); 426 QStringList *fileList = new QStringList();
427 QTextStream t( &f ); 427 QTextStream t( &f );
428 while ( !t.eof() ) 428 while ( !t.eof() )
429 *fileList += t.readLine(); 429 *fileList += t.readLine();
430 430
431 f.close(); 431 f.close();
432 return fileList; 432 return fileList;
433} 433}
434 434
435void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) 435void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
436{ 436{
437 if ( !fileList || fileList->isEmpty() ) 437 if ( !fileList || fileList->isEmpty() )
438 return; 438 return;
439 439
440 QString baseDir = ROOT; 440 QString baseDir = ROOT;
441 441
442 if ( createLinks == true ) 442 if ( createLinks == true )
443 { 443 {
444 for ( uint i=0; i < fileList->count(); i++ ) 444 for ( uint i=0; i < fileList->count(); i++ )
445 { 445 {
446 processLinkDir( (*fileList)[i], baseDir, destDir ); 446 processLinkDir( (*fileList)[i], baseDir, destDir );
447 qApp->processEvents(); 447 qApp->processEvents();
448 } 448 }
449 } 449 }
450 else 450 else
451 { 451 {
452 for ( int i = fileList->count()-1; i >= 0 ; i-- ) 452 for ( int i = fileList->count()-1; i >= 0 ; i-- )
453 { 453 {
454 processLinkDir( (*fileList)[i], baseDir, destDir ); 454 processLinkDir( (*fileList)[i], baseDir, destDir );
455 qApp->processEvents(); 455 qApp->processEvents();
456 } 456 }
457 } 457 }
458} 458}
459 459
460void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) 460void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
461{ 461{
462 462
463 QString sourceFile = baseDir + file; 463 QString sourceFile = baseDir + file;
464 464
465 QString linkFile = destDir; 465 QString linkFile = destDir;
466 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) 466 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" )
467 { 467 {
468 linkFile += file.mid( 1 ); 468 linkFile += file.mid( 1 );
469 } 469 }
470 else 470 else
471 { 471 {
472 linkFile += file; 472 linkFile += file;
473 } 473 }
474 QString text; 474 QString text;
475 if ( createLinks ) 475 if ( createLinks )
476 { 476 {
477 // If this file is a directory (ends with a /) and it doesn't exist, 477 // If this file is a directory (ends with a /) and it doesn't exist,
478 // we need to create it 478 // we need to create it
479 if ( file.right(1) == "/" ) 479 if ( file.right(1) == "/" )
480 { 480 {
481 QFileInfo f( linkFile ); 481 QFileInfo f( linkFile );
482 if ( !f.exists() ) 482 if ( !f.exists() )
483 { 483 {
484 emit outputText( QString( "Creating directory " ) + linkFile ); 484 emit outputText( QString( "Creating directory " ) + linkFile );
485 QDir d; 485 QDir d;
486 d.mkdir( linkFile, true ); 486 d.mkdir( linkFile, true );
487 } 487 }
488 else 488 else
489 emit outputText( QString( "Directory " ) + linkFile + " already exists" ); 489 emit outputText( QString( "Directory " ) + linkFile + " already exists" );
490 490
491 } 491 }
492 else 492 else
493 { 493 {
494 int rc = symlink( sourceFile, linkFile ); 494 int rc = symlink( sourceFile, linkFile );
495 text = (rc == 0 ? "Linked " : "Failed to link "); 495 text = (rc == 0 ? "Linked " : "Failed to link ");
496 text += sourceFile + " to " + linkFile; 496 text += sourceFile + " to " + linkFile;
497 emit outputText( text ); 497 emit outputText( text );
498 } 498 }
499 } 499 }
500 else 500 else
501 { 501 {
502 QFileInfo f( linkFile ); 502 QFileInfo f( linkFile );
503 if ( f.exists() ) 503 if ( f.exists() )
504 { 504 {
505 if ( f.isFile() ) 505 if ( f.isFile() )
506 { 506 {
507 QFile f( linkFile ); 507 QFile f( linkFile );
508 bool rc = f.remove(); 508 bool rc = f.remove();
509 509
510 text = (rc ? "Removed " : "Failed to remove "); 510 text = (rc ? "Removed " : "Failed to remove ");
511 text += linkFile; 511 text += linkFile;
512 emit outputText( text ); 512 emit outputText( text );
513 } 513 }
514 else if ( f.isDir() ) 514 else if ( f.isDir() )
515 { 515 {
516 QDir d; 516 QDir d;
517 bool rc = d.rmdir( linkFile, true ); 517 bool rc = d.rmdir( linkFile, true );
518 text = (rc ? "Removed " : "Failed to remove "); 518 text = (rc ? "Removed " : "Failed to remove ");
519 text += linkFile; 519 text += linkFile;
520 emit outputText( text ); 520 emit outputText( text );
521 } 521 }
522 } 522 }
523 } 523 }
524 524
525} 525}