Diffstat (limited to 'noncore/settings/aqpkg/ipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 139 |
1 files changed, 35 insertions, 104 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 3df569b..43eaaae 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
@@ -112,5 +112,5 @@ void Ipkg :: runIpkg() | |||
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | #ifdef X86 | 115 | #ifdef X86 |
116 | commands << "-f"; | 116 | commands << "-f"; |
@@ -128,5 +128,5 @@ void Ipkg :: runIpkg() | |||
128 | 128 | ||
129 | if ( package != "" ) | 129 | if ( package != "" ) |
130 | emit outputText( QString( "Dealing with package " ) + package ); | 130 | emit outputText( tr( "Dealing with package %1" ).arg( package) ); |
131 | 131 | ||
132 | qApp->processEvents(); | 132 | qApp->processEvents(); |
@@ -139,10 +139,10 @@ void Ipkg :: runIpkg() | |||
139 | if ( flags & MAKE_LINKS ) | 139 | if ( flags & MAKE_LINKS ) |
140 | { | 140 | { |
141 | emit outputText( QString( "Removing symbolic links...\n" ) ); | 141 | emit outputText( tr( "Removing symbolic links...\n" ) ); |
142 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 142 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
143 | emit outputText( QString( " " ) ); | 143 | emit outputText( QString( " " ) ); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | // Execute command | 147 | // Execute command |
148 | dependantPackages = new QList<QString>; | 148 | dependantPackages = new QList<QString>; |
@@ -163,5 +163,5 @@ void Ipkg :: createSymLinks() | |||
163 | { | 163 | { |
164 | emit outputText( " " ); | 164 | emit outputText( " " ); |
165 | emit outputText( QString( "Creating symbolic links for " )+ package ); | 165 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); |
166 | 166 | ||
167 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 167 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
@@ -174,5 +174,5 @@ void Ipkg :: createSymLinks() | |||
174 | continue; | 174 | continue; |
175 | emit outputText( " " ); | 175 | emit outputText( " " ); |
176 | emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); | 176 | emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) ); |
177 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); | 177 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); |
178 | } | 178 | } |
@@ -182,5 +182,5 @@ void Ipkg :: createSymLinks() | |||
182 | delete dependantPackages; | 182 | delete dependantPackages; |
183 | 183 | ||
184 | emit outputText( "Finished" ); | 184 | emit outputText( tr("Finished") ); |
185 | emit outputText( "" ); | 185 | emit outputText( "" ); |
186 | } | 186 | } |
@@ -196,17 +196,17 @@ void Ipkg :: removeStatusEntry() | |||
196 | 196 | ||
197 | emit outputText( "" ); | 197 | emit outputText( "" ); |
198 | emit outputText( "Removing status entry..." ); | 198 | emit outputText( tr("Removing status entry...") ); |
199 | QString tempstr = "status file - "; | 199 | QString tempstr = tr("status file - "); |
200 | tempstr.append( statusFile ); | 200 | tempstr.append( statusFile ); |
201 | emit outputText( tempstr ); | 201 | emit outputText( tempstr ); |
202 | tempstr = "package - "; | 202 | tempstr = tr("package - "); |
203 | tempstr.append( package ); | 203 | tempstr.append( package ); |
204 | emit outputText( tempstr ); | 204 | emit outputText( tempstr ); |
205 | 205 | ||
206 | ifstream in( statusFile ); | 206 | ifstream in( statusFile ); |
207 | ofstream out( outStatusFile ); | 207 | ofstream out( outStatusFile ); |
208 | if ( !in.is_open() ) | 208 | if ( !in.is_open() ) |
209 | { | 209 | { |
210 | tempstr = "Couldn't open status file - "; | 210 | tempstr = tr("Couldn't open status file - "); |
211 | tempstr.append( statusFile ); | 211 | tempstr.append( statusFile ); |
212 | emit outputText( tempstr ); | 212 | emit outputText( tempstr ); |
@@ -216,5 +216,5 @@ void Ipkg :: removeStatusEntry() | |||
216 | if ( !out.is_open() ) | 216 | if ( !out.is_open() ) |
217 | { | 217 | { |
218 | tempstr = "Couldn't create tempory status file - "; | 218 | tempstr = tr("Couldn't create tempory status file - "); |
219 | tempstr.append( outStatusFile ); | 219 | tempstr.append( outStatusFile ); |
220 | emit outputText( tempstr ); | 220 | emit outputText( tempstr ); |
@@ -257,5 +257,5 @@ void Ipkg :: removeStatusEntry() | |||
257 | out << line << endl; | 257 | out << line << endl; |
258 | 258 | ||
259 | // Improve UI responsiveness | 259 | // Improve UI responsiveness |
260 | i++; | 260 | i++; |
261 | if ( ( i % 50 ) == 0 ) | 261 | if ( ( i % 50 ) == 0 ) |
@@ -268,11 +268,11 @@ void Ipkg :: removeStatusEntry() | |||
268 | { | 268 | { |
269 | out << (const char *)(*it) << endl; | 269 | out << (const char *)(*it) << endl; |
270 | 270 | ||
271 | // Improve UI responsiveness | 271 | // Improve UI responsiveness |
272 | i++; | 272 | i++; |
273 | if ( ( i % 50 ) == 0 ) | 273 | if ( ( i % 50 ) == 0 ) |
274 | qApp->processEvents(); | 274 | qApp->processEvents(); |
275 | } | 275 | } |
276 | 276 | ||
277 | in.close(); | 277 | in.close(); |
278 | out.close(); | 278 | out.close(); |
@@ -291,5 +291,5 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | |||
291 | proc = 0; | 291 | proc = 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | // OK we're gonna use OProcess to run this thing | 294 | // OK we're gonna use OProcess to run this thing |
295 | proc = new OProcess(); | 295 | proc = new OProcess(); |
@@ -306,5 +306,5 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | |||
306 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 306 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), |
307 | this, SLOT(commandStderr(OProcess *, char *, int))); | 307 | this, SLOT(commandStderr(OProcess *, char *, int))); |
308 | 308 | ||
309 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) | 309 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) |
310 | { | 310 | { |
@@ -316,5 +316,5 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | |||
316 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) | 316 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) |
317 | { | 317 | { |
318 | emit outputText( QString( "Couldn't start ipkg process" ) ); | 318 | emit outputText( tr("Couldn't start ipkg process" ) ); |
319 | } | 319 | } |
320 | } | 320 | } |
@@ -347,5 +347,5 @@ void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | |||
347 | error = true; | 347 | error = true; |
348 | } | 348 | } |
349 | 349 | ||
350 | buffer[0] = '\0'; | 350 | buffer[0] = '\0'; |
351 | } | 351 | } |
@@ -369,5 +369,5 @@ void Ipkg::processFinished() | |||
369 | if ( !error && option == "remove" ) | 369 | if ( !error && option == "remove" ) |
370 | removeStatusEntry(); | 370 | removeStatusEntry(); |
371 | 371 | ||
372 | delete proc; | 372 | delete proc; |
373 | proc = 0; | 373 | proc = 0; |
@@ -387,75 +387,9 @@ void Ipkg :: abort() | |||
387 | } | 387 | } |
388 | 388 | ||
389 | /* | ||
390 | int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) | ||
391 | { | ||
392 | FILE *fp = NULL; | ||
393 | char line[130]; | ||
394 | QString lineStr, lineStrOld; | ||
395 | int ret = false; | ||
396 | |||
397 | fp = popen( (const char *) cmd, "r"); | ||
398 | if ( fp == NULL ) | ||
399 | { | ||
400 | QString text; | ||
401 | text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); | ||
402 | emit outputText( text ); | ||
403 | } | ||
404 | else | ||
405 | { | ||
406 | while ( fgets( line, sizeof line, fp) != NULL ) | ||
407 | { | ||
408 | lineStr = line; | ||
409 | lineStr=lineStr.left( lineStr.length()-1 ); | ||
410 | |||
411 | if ( lineStr != lineStrOld ) | ||
412 | { | ||
413 | //See if we're finished | ||
414 | if ( option == "install" || option == "reinstall" ) | ||
415 | { | ||
416 | // Need to keep track of any dependant packages that get installed | ||
417 | // so that we can create links to them as necessary | ||
418 | if ( lineStr.startsWith( "Installing " ) ) | ||
419 | { | ||
420 | int start = lineStr.find( " " ) + 1; | ||
421 | int end = lineStr.find( " ", start ); | ||
422 | QString *package = new QString( lineStr.mid( start, end-start ) ); | ||
423 | dependantPackages->append( package ); | ||
424 | } | ||
425 | } | ||
426 | |||
427 | if ( option == "update" ) | ||
428 | { | ||
429 | if (lineStr.contains("Updated list")) | ||
430 | ret = true; | ||
431 | } | ||
432 | else if ( option == "download" ) | ||
433 | { | ||
434 | if (lineStr.contains("Downloaded")) | ||
435 | ret = true; | ||
436 | } | ||
437 | else | ||
438 | { | ||
439 | if (lineStr.contains("Done")) | ||
440 | ret = true; | ||
441 | } | ||
442 | |||
443 | emit outputText( lineStr ); | ||
444 | } | ||
445 | lineStrOld = lineStr; | ||
446 | qApp->processEvents(); | ||
447 | } | ||
448 | pclose(fp); | ||
449 | } | ||
450 | |||
451 | return ret; | ||
452 | } | ||
453 | */ | ||
454 | |||
455 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) | 389 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) |
456 | { | 390 | { |
457 | if ( dest == "root" || dest == "/" ) | 391 | if ( dest == "root" || dest == "/" ) |
458 | return; | 392 | return; |
459 | 393 | ||
460 | qApp->processEvents(); | 394 | qApp->processEvents(); |
461 | QStringList *fileList = getList( packFileName, destDir ); | 395 | QStringList *fileList = getList( packFileName, destDir ); |
@@ -477,5 +411,5 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des | |||
477 | // Couldn't open from dest, try from / | 411 | // Couldn't open from dest, try from / |
478 | f.close(); | 412 | f.close(); |
479 | 413 | ||
480 | packageFileDir = "/usr/lib/ipkg/info/"; | 414 | packageFileDir = "/usr/lib/ipkg/info/"; |
481 | packageFileDir.append( packageFilename ); | 415 | packageFileDir.append( packageFilename ); |
@@ -484,5 +418,5 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des | |||
484 | if ( ! f.open(IO_ReadOnly) ) | 418 | if ( ! f.open(IO_ReadOnly) ) |
485 | { | 419 | { |
486 | QString tempstr = "Could not open :"; | 420 | QString tempstr = tr("Could not open :"); |
487 | tempstr.append( packageFileDir ); | 421 | tempstr.append( packageFileDir ); |
488 | emit outputText( tempstr ); | 422 | emit outputText( tempstr ); |
@@ -529,10 +463,10 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
529 | QString sourceFile = baseDir; | 463 | QString sourceFile = baseDir; |
530 | sourceFile.append( file ); | 464 | sourceFile.append( file ); |
531 | 465 | ||
532 | QString linkFile = destDir; | 466 | QString linkFile = destDir; |
533 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) | 467 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) |
534 | { | 468 | { |
535 | linkFile.append( file.mid( 1 ) ); | 469 | linkFile.append( file.mid( 1 ) ); |
536 | } | 470 | } |
537 | else | 471 | else |
538 | { | 472 | { |
@@ -549,5 +483,5 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
549 | if ( !f.exists() ) | 483 | if ( !f.exists() ) |
550 | { | 484 | { |
551 | QString tempstr = "Creating directory "; | 485 | QString tempstr = tr("Creating directory "); |
552 | tempstr.append( linkFile ); | 486 | tempstr.append( linkFile ); |
553 | emit outputText( tempstr ); | 487 | emit outputText( tempstr ); |
@@ -557,13 +491,12 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
557 | // else | 491 | // else |
558 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); | 492 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); |
559 | 493 | ||
560 | } | 494 | } |
561 | else | 495 | else |
562 | { | 496 | { |
563 | int rc = symlink( sourceFile, linkFile ); | 497 | int rc = symlink( sourceFile, linkFile ); |
564 | text = (rc == 0 ? "Linked " : "Failed to link "); | 498 | text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ). |
565 | text.append( sourceFile ); | 499 | arg( sourceFile ). |
566 | text.append( " to " ); | 500 | arg( linkFile ); |
567 | text.append( linkFile ); | ||
568 | emit outputText( text ); | 501 | emit outputText( text ); |
569 | } | 502 | } |
@@ -579,6 +512,5 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
579 | bool rc = f.remove(); | 512 | bool rc = f.remove(); |
580 | 513 | ||
581 | text = (rc ? "Removed " : "Failed to remove "); | 514 | text = ( rc ? tr( "Removed %1" ) : tr( "Failed to remove %1" ) ).arg( linkFile ); |
582 | text.append( linkFile ); | ||
583 | emit outputText( text ); | 515 | emit outputText( text ); |
584 | } | 516 | } |
@@ -589,6 +521,5 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
589 | if ( rc ) | 521 | if ( rc ) |
590 | { | 522 | { |
591 | text = (rc ? "Removed " : "Failed to remove "); | 523 | text = ( rc ? tr( "Removed " ) : tr( "Failed to remove " ) ).arg( linkFile ); |
592 | text.append( linkFile ); | ||
593 | emit outputText( text ); | 524 | emit outputText( text ); |
594 | } | 525 | } |