author | drw <drw> | 2003-04-23 01:04:02 (UTC) |
---|---|---|
committer | drw <drw> | 2003-04-23 01:04:02 (UTC) |
commit | 43b2c74f7d32ce9c744e4d79e62a92e0181604c3 (patch) (unidiff) | |
tree | 894049bfdc5724ea167f3dbc437cf0d18b93f3c1 | |
parent | 509ac60dfd2e0829f56fb65407ddbe57f7668d70 (diff) | |
download | opie-43b2c74f7d32ce9c744e4d79e62a92e0181604c3.zip opie-43b2c74f7d32ce9c744e4d79e62a92e0181604c3.tar.gz opie-43b2c74f7d32ce9c744e4d79e62a92e0181604c3.tar.bz2 |
Fix for bug #864 and some other code tweaks to reduce executable size
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 80 |
1 files changed, 46 insertions, 34 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 7df643e..e906653 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -173,5 +173,4 @@ bool Ipkg :: runIpkg( ) | |||
173 | emit outputText( "" ); | 173 | emit outputText( "" ); |
174 | return ret; | 174 | return ret; |
175 | |||
176 | } | 175 | } |
177 | 176 | ||
@@ -180,12 +179,17 @@ void Ipkg :: removeStatusEntry() | |||
180 | QString statusFile = destDir; | 179 | QString statusFile = destDir; |
181 | if ( statusFile.right( 1 ) != "/" ) | 180 | if ( statusFile.right( 1 ) != "/" ) |
182 | statusFile += "/"; | 181 | statusFile.append( "/" ); |
183 | statusFile += "usr/lib/ipkg/status"; | 182 | statusFile.append( "usr/lib/ipkg/status" ); |
184 | QString outStatusFile = statusFile + ".tmp"; | 183 | QString outStatusFile = statusFile; |
184 | outStatusFile.append( ".tmp" ); | ||
185 | 185 | ||
186 | emit outputText( "" ); | 186 | emit outputText( "" ); |
187 | emit outputText( "Removing status entry..." ); | 187 | emit outputText( "Removing status entry..." ); |
188 | emit outputText( QString( "status file - " )+ statusFile ); | 188 | QString tempstr = "status file - "; |
189 | emit outputText( QString( "package - " )+ package ); | 189 | tempstr.append( statusFile ); |
190 | emit outputText( tempstr ); | ||
191 | tempstr = "package - "; | ||
192 | tempstr.append( package ); | ||
193 | emit outputText( tempstr ); | ||
190 | 194 | ||
191 | ifstream in( statusFile ); | 195 | ifstream in( statusFile ); |
@@ -193,5 +197,7 @@ void Ipkg :: removeStatusEntry() | |||
193 | if ( !in.is_open() ) | 197 | if ( !in.is_open() ) |
194 | { | 198 | { |
195 | emit outputText( QString( "Couldn't open status file - " )+ statusFile ); | 199 | tempstr = "Couldn't open status file - "; |
200 | tempstr.append( statusFile ); | ||
201 | emit outputText( tempstr ); | ||
196 | return; | 202 | return; |
197 | } | 203 | } |
@@ -199,5 +205,7 @@ void Ipkg :: removeStatusEntry() | |||
199 | if ( !out.is_open() ) | 205 | if ( !out.is_open() ) |
200 | { | 206 | { |
201 | emit outputText( QString( "Couldn't create tempory status file - " )+ outStatusFile ); | 207 | tempstr = "Couldn't create tempory status file - "; |
208 | tempstr.append( outStatusFile ); | ||
209 | emit outputText( tempstr ); | ||
202 | return; | 210 | return; |
203 | } | 211 | } |
@@ -235,5 +243,5 @@ void Ipkg :: removeStatusEntry() | |||
235 | 243 | ||
236 | lines.push_back( QString( line ) ); | 244 | lines.push_back( QString( line ) ); |
237 | // out << line << endl; | 245 | out << line << endl; |
238 | } while ( !in.eof() ); | 246 | } while ( !in.eof() ); |
239 | 247 | ||
@@ -242,5 +250,4 @@ void Ipkg :: removeStatusEntry() | |||
242 | for ( it = lines.begin() ; it != lines.end() ; ++it ) | 250 | for ( it = lines.begin() ; it != lines.end() ; ++it ) |
243 | { | 251 | { |
244 | cout << "Writing " << (const char *)(*it) << endl; | ||
245 | out << (const char *)(*it) << endl; | 252 | out << (const char *)(*it) << endl; |
246 | } | 253 | } |
@@ -280,8 +287,6 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | |||
280 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) | 287 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) |
281 | { | 288 | { |
282 | qDebug( "%s ", (*it).latin1() ); | ||
283 | *proc << (*it).latin1(); | 289 | *proc << (*it).latin1(); |
284 | } | 290 | } |
285 | cout << endl; | ||
286 | 291 | ||
287 | // Start the process going | 292 | // Start the process going |
@@ -290,5 +295,4 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | |||
290 | { | 295 | { |
291 | emit outputText( QString( "Couldn't start ipkg process" ) ); | 296 | emit outputText( QString( "Couldn't start ipkg process" ) ); |
292 | qDebug( "Couldn't start ipkg process!" ); | ||
293 | } | 297 | } |
294 | 298 | ||
@@ -300,6 +304,4 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | |||
300 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | 304 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) |
301 | { | 305 | { |
302 | qDebug("received stdout %d bytes", buflen); | ||
303 | |||
304 | QString lineStr = buffer; | 306 | QString lineStr = buffer; |
305 | if ( lineStr[buflen-1] == '\n' ) | 307 | if ( lineStr[buflen-1] == '\n' ) |
@@ -321,6 +323,11 @@ void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | |||
321 | } | 323 | } |
322 | } | 324 | } |
325 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && | ||
326 | lineStr.find( "is depended upon by packages:" ) != -1 ) | ||
327 | { | ||
328 | // Ipkg should send this to STDERR, but doesn't - so trap here | ||
329 | error = true; | ||
330 | } | ||
323 | 331 | ||
324 | qDebug(lineStr); | ||
325 | buffer[0] = '\0'; | 332 | buffer[0] = '\0'; |
326 | } | 333 | } |
@@ -328,6 +335,4 @@ void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | |||
328 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) | 335 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) |
329 | { | 336 | { |
330 | qDebug("received stderrt %d bytes", buflen); | ||
331 | |||
332 | QString lineStr = buffer; | 337 | QString lineStr = buffer; |
333 | if ( lineStr[buflen-1] == '\n' ) | 338 | if ( lineStr[buflen-1] == '\n' ) |
@@ -343,4 +348,5 @@ void Ipkg::processFinished() | |||
343 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file | 348 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file |
344 | // to workaround an ipkg bug which stops reinstall to a different location | 349 | // to workaround an ipkg bug which stops reinstall to a different location |
350 | |||
345 | if ( !error && option == "remove" ) | 351 | if ( !error && option == "remove" ) |
346 | removeStatusEntry(); | 352 | removeStatusEntry(); |
@@ -372,5 +378,4 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) | |||
372 | if ( fp == NULL ) | 378 | if ( fp == NULL ) |
373 | { | 379 | { |
374 | cout << "Couldn't execute " << cmd << "! err = " << fp << endl; | ||
375 | QString text; | 380 | QString text; |
376 | text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); | 381 | text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); |
@@ -442,21 +447,24 @@ void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, cons | |||
442 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 447 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) |
443 | { | 448 | { |
444 | QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list"; | 449 | QString packageFileDir = destDir; |
450 | packageFileDir.append( "/usr/lib/ipkg/info/" ); | ||
451 | packageFileDir.append( packageFilename ); | ||
452 | packageFileDir.append( ".list" ); | ||
445 | QFile f( packageFileDir ); | 453 | QFile f( packageFileDir ); |
446 | 454 | ||
447 | cout << "Try to open " << packageFileDir << endl; | ||
448 | if ( !f.open(IO_ReadOnly) ) | 455 | if ( !f.open(IO_ReadOnly) ) |
449 | { | 456 | { |
450 | // Couldn't open from dest, try from / | 457 | // Couldn't open from dest, try from / |
451 | cout << "Could not open:" << packageFileDir << endl; | ||
452 | f.close(); | 458 | f.close(); |
453 | 459 | ||
454 | packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list"; | 460 | packageFileDir = "/usr/lib/ipkg/info/"; |
461 | packageFileDir.append( packageFilename ); | ||
462 | packageFileDir.append( ".list" ); | ||
455 | f.setName( packageFileDir ); | 463 | f.setName( packageFileDir ); |
456 | qDebug( "Try to open %s", packageFileDir.latin1() ); | ||
457 | if ( ! f.open(IO_ReadOnly) ) | 464 | if ( ! f.open(IO_ReadOnly) ) |
458 | { | 465 | { |
459 | qDebug( "Could not open: %s", packageFileDir.latin1() ); | 466 | QString tempstr = "Could not open :"; |
460 | emit outputText( QString( "Could not open :" ) + packageFileDir ); | 467 | tempstr.append( packageFileDir ); |
468 | emit outputText( tempstr ); | ||
461 | return (QStringList*)0; | 469 | return (QStringList*)0; |
462 | } | 470 | } |
@@ -499,14 +507,15 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
499 | { | 507 | { |
500 | 508 | ||
501 | QString sourceFile = baseDir + file; | 509 | QString sourceFile = baseDir; |
510 | sourceFile.append( file ); | ||
502 | 511 | ||
503 | QString linkFile = destDir; | 512 | QString linkFile = destDir; |
504 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) | 513 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) |
505 | { | 514 | { |
506 | linkFile += file.mid( 1 ); | 515 | linkFile.append( file.mid( 1 ) ); |
507 | } | 516 | } |
508 | else | 517 | else |
509 | { | 518 | { |
510 | linkFile += file; | 519 | linkFile.append( file ); |
511 | } | 520 | } |
512 | QString text; | 521 | QString text; |
@@ -520,5 +529,7 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
520 | if ( !f.exists() ) | 529 | if ( !f.exists() ) |
521 | { | 530 | { |
522 | emit outputText( QString( "Creating directory " ) + linkFile ); | 531 | QString tempstr = "Creating directory "; |
532 | tempstr.append( linkFile ); | ||
533 | emit outputText( tempstr ); | ||
523 | QDir d; | 534 | QDir d; |
524 | d.mkdir( linkFile, true ); | 535 | d.mkdir( linkFile, true ); |
@@ -532,5 +543,7 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
532 | int rc = symlink( sourceFile, linkFile ); | 543 | int rc = symlink( sourceFile, linkFile ); |
533 | text = (rc == 0 ? "Linked " : "Failed to link "); | 544 | text = (rc == 0 ? "Linked " : "Failed to link "); |
534 | text += sourceFile + " to " + linkFile; | 545 | text.append( sourceFile ); |
546 | text.append( " to " ); | ||
547 | text.append( linkFile ); | ||
535 | emit outputText( text ); | 548 | emit outputText( text ); |
536 | } | 549 | } |
@@ -547,5 +560,5 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
547 | 560 | ||
548 | text = (rc ? "Removed " : "Failed to remove "); | 561 | text = (rc ? "Removed " : "Failed to remove "); |
549 | text += linkFile; | 562 | text.append( linkFile ); |
550 | emit outputText( text ); | 563 | emit outputText( text ); |
551 | } | 564 | } |
@@ -557,5 +570,5 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
557 | { | 570 | { |
558 | text = (rc ? "Removed " : "Failed to remove "); | 571 | text = (rc ? "Removed " : "Failed to remove "); |
559 | text += linkFile; | 572 | text.append( linkFile ); |
560 | emit outputText( text ); | 573 | emit outputText( text ); |
561 | } | 574 | } |
@@ -563,4 +576,3 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
563 | } | 576 | } |
564 | } | 577 | } |
565 | |||
566 | } | 578 | } |